From 8c97be00dc92f7d07f32904a3d246a7172e12824 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Sat, 5 May 2012 17:36:13 +0100 Subject: [PATCH] Nest display & find/replace improvements Loaded code no longer has & converted to & so code is not messed with Nesting only displays if you don't have include, include_once (PHP), plus must have html or body tag (HTML) Found count display now updates on switching tabs findReplace updated to take 3rd param, detecting how it was triggered Find is now case-sensitive by default Code realigned in findReplace to work more specifically with 'this document' Extra code also added to replace all Display count now fixed to be accurate Multiple results screen show shows when not finding within current document Function to deal with updating and showing/hiding of results count display --- lib/coder.js | 66 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index 22dc755..581214b 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -93,7 +93,6 @@ var ICEcoder = { if (fileName.indexOf(".js")<0&&fileName.indexOf(".rb")&&fileName.indexOf(".css")<0) { cM = ICEcoder.getcMInstance(); content = cM.getValue(); - if (top.ICEcoder.codeAssist) {content = content.replace(/ & /g,' & ');}; content = content.replace(//g,''); // Then set the content in the editor & clear the history @@ -178,12 +177,13 @@ var ICEcoder = { // Now we've built up our nest depth array, if we're due to show it in the display if (updateNestDisplay && !top.ICEcoder.dontUpdateNest) { - // Clear the display ICEcoder.nestDisplay.innerHTML = ""; if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) { fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1]; - if (fileName.indexOf(".js")<0&&fileName.indexOf(".rb")<0&&fileName.indexOf(".css")<0) { + if (fileName.indexOf(".js")<0&&fileName.indexOf(".rb")<0&&fileName.indexOf(".css")<0&& + (nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&& + (nestCheck.indexOf("-1||nestCheck.indexOf("-1)) { // Then for all the array items, output as the nest display for (var i=0;i0) { + // If we have something to find in currrent document + if (findLen>0 && document.findAndReplace.target.value=="this document") { cM = ICEcoder.getcMInstance(); - content = cM.getValue().toLowerCase(); + content = cM.getValue(); - // Find & replace the next instance? - if (document.findAndReplace.connector.value=="and" && cM.getSelection()==find) { - cM.replaceSelection(document.getElementById('replace').value); + // Find & replace the next instance, or all? + if (document.findAndReplace.connector.value=="and") { + if (document.findAndReplace.replaceAction.value=="replace" && cM.getSelection()==find) { + cM.replaceSelection(document.getElementById('replace').value); + } + if (document.findAndReplace.replaceAction.value=="replace all" && buttonClick) { + var rExp = new RegExp(find,"g"); + cM.setValue(cM.getValue().replace(rExp,document.getElementById('replace').value)); + } } + // Get the content again, as it might of changed + content = cM.getValue(); if (!top.ICEcoder.findMode||parent.parent.document.getElementById('find').value!=ICEcoder.lastsearch) { ICEcoder.results = []; + for (var i=0;i'; + } } }, @@ -1447,5 +1471,11 @@ var ICEcoder = { // Finally, refresh the file manager if we need to if (refreshFM) {top.ICEcoder.refreshFileManager()}; + }, + + // Update and show/hide found results display? + updateResultsDisplay: function(showHide) { + ICEcoder.findReplace('find',true,false); + document.getElementById('results').style.display = showHide == "show" ? 'inline-block' : 'none'; } }; \ No newline at end of file