diff --git a/lib/coder.js b/lib/coder.js
index 48aab61..4957461 100644
--- a/lib/coder.js
+++ b/lib/coder.js
@@ -24,6 +24,7 @@ var ICEcoder = {
codeAssist: true, // Assist user with their coding
mouseDown: false, // If the mouse is down or not
draggingFilesW: false, // If we're dragging the file manager width or not
+ serverQueueItems: [], // Array of URLs to call in order
// Don't consider these tags as part of nesting as they're singles, JS or PHP code blocks
tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?"],
@@ -322,9 +323,10 @@ var ICEcoder = {
}
cM.setOption('theme','icecoder visible');
- // Focus on our selected instance
+ // Focus on & refresh our selected instance
cM = ICEcoder.getcMInstance();
cM.focus();
+ cM.refresh();
// Highlight the selected tab
ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
@@ -655,7 +657,7 @@ var ICEcoder = {
if (newFolder) {
newFolder = shortURL + "/" + newFolder;
- filesFrame.contentWindow.frames['fileControl'].location.href="lib/file-control.php?action=newFolder&file="+newFolder.replace(/\//g,"|");
+ top.ICEcoder.serverQueue("add","lib/file-control.php?action=newFolder&file="+newFolder.replace(/\//g,"|"));
top.ICEcoder.serverMessage('Creating Folder
'+newFolder);
}
},
@@ -695,7 +697,7 @@ var ICEcoder = {
if (shortURL!="/[NEW]") {
// replace forward slashes with pipes so it get be placed in a querystring
top.ICEcoder.thisFileFolderLink = top.ICEcoder.thisFileFolderLink.replace(/\//g,"|");
- ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = "lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink;
+ top.ICEcoder.serverQueue("add","lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink);
top.ICEcoder.serverMessage('Opening File
'+top.ICEcoder.shortURL);
} else {
top.ICEcoder.createNewTab();
@@ -709,7 +711,7 @@ var ICEcoder = {
var saveType;
if (saveAs) {saveType = "saveAs"} else {saveType = "save"};
- filesFrame.contentWindow.frames['fileControl'].location.href="lib/file-control.php?action=save&file="+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(/\//g,"|")+"&saveType="+saveType;
+ top.ICEcoder.serverQueue("add","lib/file-control.php?action=save&file="+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(/\//g,"|")+"&saveType="+saveType);
top.ICEcoder.serverMessage('Saving
'+ICEcoder.openFiles[ICEcoder.selectedTab-1]);
},
@@ -732,7 +734,7 @@ var ICEcoder = {
top.document.getElementById('tab'+(i+1)).innerHTML = top.ICEcoder.openFiles[i] + " " + closeTabLink;
}
}
- ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = "lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.rightClickedFile.replace(/\|/g,"/");
+ top.ICEcoder.serverQueue("add","lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.rightClickedFile.replace(/\|/g,"/"));
top.ICEcoder.serverMessage('Renaming to
'+renamedFile);
}
},
@@ -750,7 +752,7 @@ var ICEcoder = {
selectedFilesList += top.ICEcoder.selectedFiles[i];
if (iDeleting File
'+top.ICEcoder.selectedFiles.toString().replace(/\|/g,"/").replace(/,/g,"\n"));
};
},
@@ -919,14 +921,13 @@ var ICEcoder = {
// Start running plugin intervals according to given specifics
startPluginIntervals: function(plugURL,plugTarget,plugTimer) {
-
// For this window instances
if (plugTarget=="_parent"||plugTarget=="_top"||plugTarget=="_self"||plugTarget=="") {
setInterval('window.location=\''+plugURL+'\'',plugTimer*1000*60);
// for pluginActions iframe instances
- } else if (plugTarget=="pluginActions") {
- setInterval('document.getElementById(\'pluginActions\').src=\''+plugURL+'\'',plugTimer*1000*60);
+ } else if (plugTarget.indexOf("fileControl")==0) {
+ setInterval(function() {top.ICEcoder.serverQueue("add",plugURL);top.ICEcoder.serverMessage(plugTarget.split(":")[1]);},plugTimer*1000*60);
// for _blank or named target window instances
} else {
@@ -986,6 +987,7 @@ var ICEcoder = {
top.ICEcoder.dragCursorTest();
},
+ // Test if we need to show a drag cursor or not
dragCursorTest: function() {
var winH;
@@ -1093,7 +1095,14 @@ var ICEcoder = {
// Turning on/off the Code Assist
codeAssistToggle: function() {
+ var cM;
+
+ cM = ICEcoder.getcMInstance();
+
top.ICEcoder.codeAssist ? top.ICEcoder.codeAssist = false : top.ICEcoder.codeAssist = true;
+
+ top.ICEcoder.cssColorPreview();
+ cM.focus();
},
// Show or hide a server message
@@ -1107,5 +1116,76 @@ var ICEcoder = {
} else {
serverMessage.style.opacity = 0;
}
+ },
+
+ // Queue items up for processing in turn
+ serverQueue: function(action,item) {
+ var cM,nextSaveID,txtArea,topSaveID,element;
+
+ cM = ICEcoder.getcMInstance();
+
+ // Firstly, work out how many saves we have to carry out
+ nextSaveID=0;
+ for (i=0;i0) {
+ nextSaveID++;
+ }
+ }
+ nextSaveID++;
+
+ // Add to end of array or remove from beginning on demand, plus add or remove if necessary
+ if (action=="add") {
+ ICEcoder.serverQueueItems.push(item);
+ if (item.indexOf('action=save')>0) {
+ txtArea = document.createElement('textarea');
+ txtArea.setAttribute('id', 'saveTemp'+nextSaveID);
+ document.body.appendChild(txtArea);
+ document.getElementById('saveTemp'+nextSaveID).value = cM.getValue();
+ }
+ }
+ if (action=="del") {
+ if (ICEcoder.serverQueueItems[0].indexOf('action=save')>0) {
+ topSaveID = nextSaveID-1;
+ for (i=1;i=1 || ICEcoder.serverQueueItems.length==1) {
+ setTimeout(function() {top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href=ICEcoder.serverQueueItems[0]},1);
+ }
+ },
+
+ // Show a CSS color block next to our text cursor
+ cssColorPreview: function() {
+ var cM,string,startPosAdj,endPosAdj,nextSpace,oldBlock,newBlock;
+
+ cM = ICEcoder.getcMInstance();
+
+ string = cM.getLine(cM.getCursor().line);
+ startPosAdj = string.slice(0,cM.getCursor().ch).length - string.slice(0,cM.getCursor().ch).lastIndexOf(' ') - 1;
+ nextSpace = string.slice(cM.getCursor().ch,string.length).indexOf(' ');
+ nextSpace > -1 ? endPosAdj = nextSpace : endPosAdj = string.length - cM.getCursor().ch;
+ string = string.slice(cM.getCursor().ch-startPosAdj,cM.getCursor().ch+endPosAdj);
+ string = string.replace(/[^a-z0-9#(),.]/gi,'');
+
+ oldBlock = top.document.getElementById('content').contentWindow.document.getElementById('cssColor');
+ if (oldBlock) {oldBlock.parentNode.removeChild(oldBlock)};
+ if (top.ICEcoder.codeAssist) {
+ newBlock = top.document.createElement("div");
+ newBlock.id="cssColor";
+ newBlock.style.position = "absolute";
+ newBlock.style.display = "block";
+ newBlock.style.width = newBlock.style.height = "20px";
+ newBlock.style.backgroundColor = string;
+ top.document.getElementById('header').appendChild(newBlock);
+ cM.addWidget(cM.getCursor(), top.document.getElementById('cssColor'), true);
+ }
}
};
\ No newline at end of file