Compare commits

...

9 Commits

Author SHA1 Message Date
Matt Pass
d2bf52e5a3 CSS for new multiple results screen 2012-05-05 17:48:34 +01:00
Matt Pass
f39b8e2a35 New multiple results screen
Shows multiple find results & allows user to replace singally, or all
Also shows count of found results, updates text & button vis on interaction
2012-05-05 17:48:13 +01:00
Matt Pass
8c97be00dc 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
2012-05-05 17:36:13 +01:00
Matt Pass
83085c4c1f Update to always return and provide error message
Alert message now displays if a zip could not be created
Will now always return, success or fail to stop server queue jams
2012-05-05 15:44:01 +01:00
Matt Pass
8adec9a48b 'replace'/'replace all' select menu & show/hide results display switching
New select menu in find & replace, allowing you to replace or replace all
Results count displays only if you select 'this document'
New param on findReplace function to indicate clicking button or not
2012-05-05 15:42:27 +01:00
Matt Pass
c177374d23 Extra param to signify we're not triggering from button click 2012-05-05 15:19:12 +01:00
Matt Pass
334ced8627 Version number update only 2012-05-05 15:17:07 +01:00
Matt Pass
d8229d79a5 New class for replace select menu 2012-05-05 15:16:12 +01:00
Matt Pass
c8665584e9 Minor fix to stop matching on whitespace chars only
Whitespace only chars are now trimmed and so not matched
This is a future update (in next version of CodeMirror) that I'm adding now
2012-05-05 15:14:57 +01:00
9 changed files with 178 additions and 26 deletions

View File

@@ -23,7 +23,7 @@
function markDocument(cm, className, minChars) {
clearMarks(cm);
minChars = (typeof minChars !== 'undefined' ? minChars : DEFAULT_MIN_CHARS);
if (cm.somethingSelected() && cm.getSelection().length >= minChars) {
if (cm.somethingSelected() && cm.getSelection().replace(/^\s+|\s+$/g, "").length >= minChars) {
var state = getMatchHighlightState(cm);
var query = cm.getSelection();
cm.operation(function() {

View File

@@ -79,7 +79,7 @@ function createNewCMInstance(num) {
},
onKeyEvent: function(instance, e) {
top.ICEcoder.redoChangedContent(event);
top.ICEcoder.findReplace('find',true);
top.ICEcoder.findReplace('find',true,false);
top.ICEcoder.getCaretPosition();
top.ICEcoder.updateCharDisplay();
tok = window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].getTokenAt(window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].getCursor());

View File

@@ -132,22 +132,28 @@ lastOpenFiles = [<?php
<form name="findAndReplace">
<div class="findReplace">
<div class="findText">Find</div>
<input type="text" name="find" value="" id="find" class="textbox find" onKeyUp="ICEcoder.findReplace('find',true)">
<input type="text" name="find" value="" id="find" class="textbox find" onKeyUp="ICEcoder.findReplace('find',true,false)">
<div class="findTextPlural">'s</div>
<select name="connector" onChange="ICEcoder.findReplaceOptions()">
<option>in</option>
<option>and</option>
</select>
<div class="replaceText" id="rText" style="display: none">replace with</div>
<div class="replaceText" id="rText" style="display: none">
<select name="replaceAction" class="replaceAction">
<option>replace</option>
<option>replace all</option>
</select>
with
</div>
<input type="text" name="replace" value="" id="replace" class="textbox replace" style="display: none">
<div class="targetText" id="rTarget" style="display: none">in</div>
<select name="target">
<select name="target" onChange="ICEcoder.updateResultsDisplay(this.value=='this document' ? 'show' : 'hide')">
<option>this document</option>
<option>open documents</option>
<option>all files</option>
<option>all filenames</option>
</select>
<input type="button" name="submit" value="&gt;&gt;" class="submit" onClick="ICEcoder.findReplace('findReplace',false)">
<input type="button" name="submit" value="&gt;&gt;" class="submit" onClick="ICEcoder.findReplace('findReplace',false,true)">
<div class="results" id="results"></div>
</div>
</form>

View File

@@ -127,6 +127,7 @@ h2 {font-size: 18px; font-weight: normal; color: #ffffff}
.findReplace .findText {display: inline-block; height: 21px; font-size: 10px; margin: 8px 2px 0px 2px; margin-left: 43px}
.findReplace .find {position: relative; width: 120px; height: 16px; border: 0; top: -2px; font-size: 10px; padding-left: 5px}
.findReplace .findTextPlural {display: inline-block; height: 21px; font-size: 10px; margin: 8px 2px 0px 0px}
.findReplace .replaceAction {margin: 0px 2px 0px 0px; top: -2px}
.findReplace .replaceText {height: 21px; font-size: 10px; margin: 8px 2px 0px 2px}
.findReplace .replace {position: relative; width: 120px; height: 16px; border: 0; top: -2px; font-size: 10px; padding-left: 5px}
.findReplace .targetText {height: 21px; font-size: 10px; margin: 8px 2px 0px 2px}

View File

@@ -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,' &amp; ');};
content = content.replace(/<ICEcoder:\/:textarea>/g,'</textarea>');
// 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("<html")>-1||nestCheck.indexOf("<body")>-1)) {
// Then for all the array items, output as the nest display
for (var i=0;i<ICEcoder.htmlTagArray.length;i++) {
@@ -360,7 +360,8 @@ var ICEcoder = {
ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
// Redo our find display
ICEcoder.findReplace('find',true);
top.ICEcoder.findMode = false;
ICEcoder.findReplace('find',true,false);
}
},
@@ -845,30 +846,42 @@ var ICEcoder = {
},
// Find & replace text according to user selections
findReplace: function(action,resultsOnly) {
var find, findLen, cM, content, lineCount, numChars, charsToCursor, charCount, startPos, endPos;
findReplace: function(action,resultsOnly,buttonClick) {
var find, findLen, replaceLen, cM, content, lineCount, numChars, charsToCursor, charCount, startPos, endPos, replaceQS;
// Determine our find string, in lowercase and the length of that
find = parent.parent.document.getElementById('find').value.toLowerCase();
find = top.document.getElementById('find').value;
findLen = find.length;
replaceLen = top.document.getElementById('replace').value.length;
// If we have something to find
if (findLen>0) {
// 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<content.length;i++) {
if (content.substr(i,findLen)==find) {
if (content.substr(i,findLen)==find && i!= ICEcoder.findResult) {
ICEcoder.results.push(i);
i+=findLen-1;
}
}
// Also remember the last search term made
ICEcoder.lastsearch = find;
}
@@ -893,7 +906,7 @@ var ICEcoder = {
charsToCursor = numChars+cM.getCursor().ch;
ICEcoder.findResult = 0;
for (var i=0;i<ICEcoder.results.length;i++) {
if (ICEcoder.results[i]<=charsToCursor) {
if (ICEcoder.results[i]<charsToCursor) {
ICEcoder.findResult++;
}
}
@@ -908,13 +921,17 @@ var ICEcoder = {
}
}
charCount = ICEcoder.results[ICEcoder.findResult]-content.lastIndexOf('\n',ICEcoder.results[ICEcoder.findResult])-1;
charCount = ICEcoder.results[ICEcoder.findResult];
startPos = new Object();
startPos.line = lineCount;
startPos.ch = charCount;
endPos = new Object();
endPos.line = lineCount;
endPos.ch = charCount+findLen;
if (document.findAndReplace.connector.value=="and" && document.findAndReplace.replaceAction.value=="replace all" && buttonClick) {
endPos.ch = charCount+replaceLen;
} else {
endPos.ch = charCount+findLen;
}
// Finally, highlight our selection
cM = ICEcoder.getcMInstance();
@@ -926,7 +943,14 @@ var ICEcoder = {
parent.parent.document.getElementById('results').innerHTML = "No results";
}
} else {
parent.parent.document.getElementById('results').innerHTML = "";
// Show the relevant multiple results popup
if (find != "" && buttonClick) {
replaceQS = "";
if (document.findAndReplace.connector.value=="and") {
replaceQS = "&replace="+document.getElementById('replace').value;
}
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/multiple-results.php?find='+find+replaceQS+'" class="whiteGlow" style="width: 700px; height: 500px"></iframe>';
}
}
},
@@ -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';
}
};

35
lib/multiple-results.css Normal file
View File

@@ -0,0 +1,35 @@
/* First, reset everything to a standard */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
border: 0px;
margin: 0px;
padding: 0px;
outline: 0px;
font-size: 12px;
vertical-align: top;
}
body {overflow: hidden;
-webkit-user-select: none;
-moz-user-select: none;
-o-user-select:none;
user-select: none;
}
h1 {font-size: 36px; font-weight: normal; color: #888888; margin-bottom: 20px}
h2 {font-size: 18px; font-weight: normal; color: #ffffff}
hr {border: 0; height: 1px; background-color: #888888}
.results {font-family: arial, verdana, helvetica, sans-serif; background-color: #1c1c19; color: #ffffff}
.results .resultsPane {position: relative; width: 660px; height: 560px; font-size: 10px; padding: 20px; float: left}
.results .resultsPane a {color: rgba(0,198,255,0.7); text-decoration: none}
.results .resultsPane a:hover {text-decoration: underline}
.replace {position: absolute; margin-top: -28px; right: 20px; padding: 5px 10px; font-size: 14px; background-color: rgba(0,198,255,0.7); cursor: pointer}
.replaceAll {position: absolute; bottom: 0px; right: 20px; padding: 5px 10px; font-size: 18px; background-color: rgba(0,198,255,0.7); cursor: pointer}

75
lib/multiple-results.php Normal file
View File

@@ -0,0 +1,75 @@
<?php include("settings.php");?>
<!DOCTYPE html>
<html>
<head>
<title>ICE Coder - <?php echo $versionNo;?> :: Multiple Results Screen</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="multiple-results.css">
</head>
<body class="results">
<div class="resultsPane">
<h1 id="title"></h1>
<div id="results"></div>
</div>
<?php if (isset($_GET['replace'])) { ?>
<div class="replaceAll" id="replaceAll" onClick="replaceAll()" style="opacity: 0.1">replace all</div>
<?php ;}; ?>
<script>
var resultsDisplay = "";
var foundTabArray = [];
var startTab = top.ICEcoder.selectedTab;
var rExp = new RegExp("<?php echo $_GET['find']; ?>","g");
for (var i=1;i<=top.ICEcoder.openFiles.length;i++) {
top.ICEcoder.switchTab(i);
var cM = top.ICEcoder.getcMInstance();
var content = cM.getValue();
if (content.match(rExp)) {
resultsDisplay += '<a href="javascript:gotoTab('+i+')">'+ top.ICEcoder.openFiles[i-1]+ '</a><br><div id="foundCount'+i+'">Found '+content.match(rExp).length+' times</div>';
<?php if (isset($_GET['replace'])) { ?>
resultsDisplay += '<div class="replace" id="replace" onClick="replaceSingle('+i+');this.style.display=\'none\'">replace</div>';
<?php ;}; ?>
resultsDisplay += '<hr>';
foundTabArray.push(i);
}
}
if (startTab!=top.ICEcoder.selectedTab) {
top.ICEcoder.switchTab(startTab);
}
foundTabArray.length==0 ? showHide = "hide" : showHide = "show";
top.ICEcoder.showHide(showHide,top.document.getElementById('blackMask'));
if (foundTabArray.length==0) {alert('No matches found')};
<?php if (isset($_GET['replace'])) { ?>
if (foundTabArray.length!=0) {document.getElementById('replaceAll').style.opacity = 1};
<?php ;}; ?>
foundTabArray.length >= 2 ? plural = "s" : plural = "";
document.getElementById('title').innerHTML = "'<?php echo $_GET['find']; ?>' found in "+foundTabArray.length+" file"+plural;
document.getElementById('results').innerHTML = resultsDisplay;
var gotoTab = function(tab) {
top.ICEcoder.switchTab(tab);
top.ICEcoder.showHide('hide',top.document.getElementById('blackMask'));
}
var replaceSingle = function(tab) {
top.ICEcoder.switchTab(tab);
cM = top.ICEcoder.getcMInstance();
content = cM.getValue();
cM.setValue(cM.getValue().replace(rExp,top.document.getElementById('replace').value));
document.getElementById('foundCount'+tab).innerHTML = document.getElementById('foundCount'+tab).innerHTML.replace('Found','Replaced');
}
var replaceAll = function() {
for (var i=0;i<=foundTabArray.length-1;i++) {
replaceSingle(foundTabArray[i]);
}
top.ICEcoder.showHide('hide',top.document.getElementById('blackMask'));
}
</script>
</body>
</html>

View File

@@ -16,7 +16,7 @@ function generateHash($plainText,$salt=null) {
// Start of settings
// -----------------
$versionNo = "v 0.6.5";
$versionNo = "v 0.6.6";
$codeMirrorDir = "CodeMirror-2.24";
$cMThisVer = 2.24;
$tabsIndent = true;

View File

@@ -74,9 +74,14 @@ Class zipIt {
// Trigger the class
$zipItDoZip = new zipIt();
$zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation.$zipItFileName);
if ($zipItAddToZip) {echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);</script>';};
if (!$zipItAddToZip) {echo '<script>alert("Could not zip files up!");</script>';};
;};
?>
<script>
top.ICEcoder.serverMessage();
top.ICEcoder.serverQueue("del",0);
</script>
</body>
</html>