X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=pkgs%2Fwebapps%2Fetherpad-lite%2Fmodules%2Fep_immae_buttons%2Fstatic%2Fjs%2Fmain.js;fp=pkgs%2Fwebapps%2Fetherpad-lite%2Fmodules%2Fep_immae_buttons%2Fstatic%2Fjs%2Fmain.js;h=0000000000000000000000000000000000000000;hb=1a64deeb894dc95e2645a75771732c6cc53a79ad;hp=07f7b9c932085ee541652a06500d13f267760e9b;hpb=fa25ffd4583cc362075cd5e1b4130f33306103f0;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/pkgs/webapps/etherpad-lite/modules/ep_immae_buttons/static/js/main.js b/pkgs/webapps/etherpad-lite/modules/ep_immae_buttons/static/js/main.js deleted file mode 100644 index 07f7b9c..0000000 --- a/pkgs/webapps/etherpad-lite/modules/ep_immae_buttons/static/js/main.js +++ /dev/null @@ -1,67 +0,0 @@ -exports.postAceInit = function(hook, context){ - $(document).ready(function () { - $('.clearFormatting').click(function(){ - context.ace.callWithAce(function(ace){ - - var rep = ace.ace_getRep(); // get the current user selection - var isSelection = (rep.selStart[0] !== rep.selEnd[0] || rep.selStart[1] !== rep.selEnd[1]); - if(!isSelection) return false; // No point proceeding if no selection.. - - var attrs = rep.apool.attribToNum; // get the attributes on this document - $.each(attrs, function(k, v){ // for each attribute - var attr = k.split(",")[0]; // get the name of the attribute - if(attr !== "author"){ // if its not an author attribute - ace.ace_setAttributeOnSelection(attr, false); // set the attribute to false - } - }); - },'clearFormatting' , true); - }); - - $('.findAndReplace').click(function(){ - var from = prompt("Search for..."); - var to = prompt("Replace with..."); - var HTMLLines = $('iframe[name="ace_outer"]').contents().find('iframe').contents().find("#innerdocbody").children("div"); - $(HTMLLines).each(function(){ // For each line - findAndReplace(from, to, this); - }); - }); - - }); -} - -function findAndReplace(searchText, replacement, searchNode) { - if (!searchText || typeof replacement === 'undefined') { - // Throw error here if you want... - return; - } - var regex = typeof searchText === 'string' ? - new RegExp(searchText, 'gi') : searchText, - childNodes = (searchNode || document.body).childNodes, - cnLength = childNodes.length, - excludes = ["html","head","style","title","meta","script","object","iframe","link"]; - - while (cnLength--) { - var currentNode = childNodes[cnLength]; - if (currentNode.nodeType === 1){ - if(excludes.indexOf(currentNode.nodeName.toLowerCase() === -1)){ - arguments.callee(searchText, replacement, currentNode); - } - } - if (currentNode.nodeType !== 3 || !regex.test(currentNode.data) ) { - continue; - } - var parent = currentNode.parentNode, - frag = (function(){ - var html = currentNode.data.replace(regex, replacement), - wrap = document.createElement('div'), - frag = document.createDocumentFragment(); - wrap.innerHTML = html; - while (wrap.firstChild) { - frag.appendChild(wrap.firstChild); - } - return frag; - })(); - parent.insertBefore(frag, currentNode); - parent.removeChild(currentNode); - } -}