From ce62da5b5cc9ca4be567357e48f3ecda6ec3a493 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 7 Aug 2013 18:47:21 +0100 Subject: [PATCH] Populate new results bar. plus tweak & bug fix lineCount and charCount are var's no longer used, removed Add scrollBarVisible var, is true or false depending on if we have a scrollbar Removed numChars and charsToCursor vars as we're now using cM.indexFromPos which gives the same result, but using CodeMirror so probably more efficient A new ICEcoder.resultsLines array is now available, populated with unique line numbers of found results 4 other new vars added for new functionality and also filesQS which I'd missed adding before New functionality to create colored blocks and add into the container, at heights determined by the amount of content and colored according to which line we're on Else clause added to clear results and this container if we have a blank find string --- lib/ice-coder.js | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index ec7720b..4c6971f 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1041,7 +1041,7 @@ var ICEcoder = { // Find & replace text according to user selections findReplace: function(findString,resultsOnly,buttonClick) { - var find, replace, results, cM, content, lineCount, numChars, charsToCursor, charCount, cursor, replaceQS, targetQS; + var find, replace, results, cM, content, scrollBarVisible, cursor, avgBlockH, addPadding, rBlocks, blockColor, replaceQS, targetQS, filesQS; // Determine our find & replace strings and results display find = findString.toLowerCase(); @@ -1066,10 +1066,14 @@ var ICEcoder = { content = cM.getValue().toLowerCase(); if (!top.ICEcoder.findMode||find!=top.ICEcoder.lastsearch) { ICEcoder.results = []; + ICEcoder.resultsLines = []; for (var i=0;i0) { + // Detect if we have a scrollbar + scrollBarVisible = cM.getScrollInfo().height > cM.getScrollInfo().clientHeight; + // Show results only if (resultsOnly) { results.innerHTML = ICEcoder.results.length + " results"; // We need to take action instead } else { - // Get the no of chars to our cursor - numChars=-1; - for (var i=0;i-1 ? cM.getCursor().line+1 == i ? "#b00" : "#888" : "transparent" + rBlocks += '
'; + } + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').innerHTML = rBlocks; + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').style.display = "inline-block"; return true; + } else { results.innerHTML = "No results"; + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').innerHTML = ""; + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').style.display = "none"; return false; } } else { @@ -1139,6 +1156,11 @@ var ICEcoder = { find != encodeURIComponent(find) ? find = 'ICEcoder:'+encodeURIComponent(find) : find; top.ICEcoder.showHide('show',top.get('loadingMask')); top.get('mediaContainer').innerHTML = ''; + // We have nothing to search for, blank it all out + } else { + results.innerHTML = "No results"; + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').innerHTML = ""; + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').style.display = "none"; } } },