mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
Pass charCount along with save request as a check
This commit is contained in:
@@ -1470,13 +1470,17 @@ var ICEcoder = {
|
||||
|
||||
// Save a file
|
||||
saveFile: function(saveAs) {
|
||||
var changes, saveType, filePath, pathPrefix;
|
||||
var changes, cM, charCount, saveType, filePath, pathPrefix;
|
||||
|
||||
// If we're not 'saving as', establish changes between current and known saved version from array
|
||||
if (!saveAs) {
|
||||
changes = top.ICEcoder.getChangesToSave();
|
||||
}
|
||||
|
||||
// Get the character count as a size check of sorts
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
charCount = cM.getValue().length;
|
||||
|
||||
saveType = saveAs ? "saveAs" : "save";
|
||||
filePath = ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,"").replace(/\//g,"|");
|
||||
if (filePath=="|[NEW]" && top.ICEcoder.selectedFiles.length>0) {
|
||||
@@ -1486,7 +1490,7 @@ var ICEcoder = {
|
||||
: "|[NEW]";
|
||||
}
|
||||
filePath = filePath.replace("||","|");
|
||||
top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=save&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&fileVersion="+ICEcoder.openFileVersions[ICEcoder.selectedTab-1]+"&saveType="+saveType+"&csrf="+top.ICEcoder.csrf,filePath.replace(/\+/g,"%2B"),changes);
|
||||
top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=save&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&fileVersion="+ICEcoder.openFileVersions[ICEcoder.selectedTab-1]+"&saveType="+saveType+"&charCount="+charCount+"&csrf="+top.ICEcoder.csrf,filePath.replace(/\+/g,"%2B"),changes);
|
||||
top.ICEcoder.serverMessage('<b>'+top.t['Saving']+'</b><br>'+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,""));
|
||||
},
|
||||
|
||||
|
||||
6
lib/ice-coder.min.js
vendored
6
lib/ice-coder.min.js
vendored
@@ -57,9 +57,9 @@ a.split(":")[2],a=a.substr(0,a.lastIndexOf(":"))):0<a.indexOf(":")&&(b=a.split("
|
||||
1),1<b&&top.ICEcoder.goToLine(b)):""!=top.ICEcoder.thisFileFolderLink&&"file"==top.ICEcoder.thisFileFolderType&&(a=top.ICEcoder.thisFileFolderLink.replace(/\|/g,"/"),c=!0,100<=top.ICEcoder.openFiles.length&&(top.ICEcoder.message(top.t["Sorry you can..."]),c=!1),c&&(top.ICEcoder.shortURL=a,"/[NEW]"!=a?(top.ICEcoder.thisFileFolderLink=top.ICEcoder.thisFileFolderLink.replace(/\//g,"|"),top.ICEcoder.serverQueue("add","lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink.replace(/\+/g,
|
||||
"%2B")+"&csrf="+top.ICEcoder.csrf+"&lineNumber="+b),top.ICEcoder.serverMessage("<b>"+top.t["Opening File"]+"</b><br>"+top.ICEcoder.shortURL)):top.ICEcoder.createNewTab("new"),top.ICEcoder.fMIconVis("fMView",1)))},openFilesFromList:function(a){for(var b=0;b<a.length;b++)top.ICEcoder.thisFileFolderLink=a[b].replace("|","/"),top.ICEcoder.thisFileFolderType="file",top.ICEcoder.openFile()},openPrompt:function(){var a;if(a=top.ICEcoder.getInput(top.t["Enter relative file..."],""))-1<a.indexOf("://")?top.ICEcoder.getRemoteFile(a):
|
||||
top.ICEcoder.openFile(a)},getRemoteFile:function(a){var b;"undefined"!=typeof a&&(b=top.ICEcoder.returnFileAndLine(a),a=b[0],b=b[1]);top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=getRemoteFile&csrf="+top.ICEcoder.csrf+"&lineNumber="+b,a.replace(/\+/g,"%2B"));top.ICEcoder.serverMessage("<b>"+top.t.Getting+"</b><br>"+a)},getChangesToSave:function(){var a,b;a=top.ICEcoder.getcMInstance();b=top.ICEcoder.savedContents[top.ICEcoder.selectedTab-1];a=difflib.stringAsLines(a.getValue());
|
||||
b=difflib.stringAsLines(b);b=(new difflib.SequenceMatcher(b,a)).get_opcodes();for(var c=0;c<b.length;c++)for(j=b[c][3];j<b[c][4];j++)"equal"!=b[c][0]&&("undefined"==typeof b[c][5]&&(b[c][5]=""),b[c][5]+=a[j]+"\n");return JSON.stringify(b)},saveFile:function(a){var b,c,d;a||(b=top.ICEcoder.getChangesToSave());a=a?"saveAs":"save";c=ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,"").replace(/\//g,"|");"|[NEW]"==c&&0<top.ICEcoder.selectedFiles.length&&(d=top.ICEcoder.selectedFiles[0],
|
||||
c=-1==d.lastIndexOf(".")||d.lastIndexOf(".")<d.lastIndexOf("|")?d+c:"|[NEW]");c=c.replace("||","|");top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=save&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&fileVersion="+ICEcoder.openFileVersions[ICEcoder.selectedTab-1]+"&saveType="+a+"&csrf="+top.ICEcoder.csrf,c.replace(/\+/g,"%2B"),b);top.ICEcoder.serverMessage("<b>"+top.t.Saving+"</b><br>"+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,""))},renameFile:function(a,
|
||||
b){var c,d;a?c=a.replace(/\|/g,"/"):(c=top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/"),a=top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/"));b||(b=top.ICEcoder.getInput(top.t["Please enter the..."],c));b&&(d=top.ICEcoder.openFiles.indexOf(c.replace(/\|/g,"/")),-1<d&&(top.ICEcoder.openFiles[d]=b,closeTabLink='<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'; top.ICEcoder.overCloseLink=true" onMouseOut="this.style.backgroundColor=prevBG; top.ICEcoder.overCloseLink=false"></a>',
|
||||
b=difflib.stringAsLines(b);b=(new difflib.SequenceMatcher(b,a)).get_opcodes();for(var c=0;c<b.length;c++)for(j=b[c][3];j<b[c][4];j++)"equal"!=b[c][0]&&("undefined"==typeof b[c][5]&&(b[c][5]=""),b[c][5]+=a[j]+"\n");return JSON.stringify(b)},saveFile:function(a){var b,c,d,e;a||(b=top.ICEcoder.getChangesToSave());c=top.ICEcoder.getcMInstance().getValue().length;a=a?"saveAs":"save";d=ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,"").replace(/\//g,"|");"|[NEW]"==d&&0<top.ICEcoder.selectedFiles.length&&
|
||||
(e=top.ICEcoder.selectedFiles[0],d=-1==e.lastIndexOf(".")||e.lastIndexOf(".")<e.lastIndexOf("|")?e+d:"|[NEW]");d=d.replace("||","|");top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=save&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&fileVersion="+ICEcoder.openFileVersions[ICEcoder.selectedTab-1]+"&saveType="+a+"&charCount="+c+"&csrf="+top.ICEcoder.csrf,d.replace(/\+/g,"%2B"),b);top.ICEcoder.serverMessage("<b>"+top.t.Saving+"</b><br>"+ICEcoder.openFiles[ICEcoder.selectedTab-
|
||||
1].replace(top.iceRoot,""))},renameFile:function(a,b){var c,d;a?c=a.replace(/\|/g,"/"):(c=top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/"),a=top.ICEcoder.selectedFiles[top.ICEcoder.selectedFiles.length-1].replace(/\|/g,"/"));b||(b=top.ICEcoder.getInput(top.t["Please enter the..."],c));b&&(d=top.ICEcoder.openFiles.indexOf(c.replace(/\|/g,"/")),-1<d&&(top.ICEcoder.openFiles[d]=b,closeTabLink='<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'; top.ICEcoder.overCloseLink=true" onMouseOut="this.style.backgroundColor=prevBG; top.ICEcoder.overCloseLink=false"></a>',
|
||||
c=top.ICEcoder.openFiles[d],top.get("tab"+(d+1)).innerHTML=closeTabLink+" "+c.slice(c.lastIndexOf("/")).replace(/\//,""),top.get("tab"+(d+1)).title=b),top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=rename&oldFileName="+a.replace(/\|/g,"/").replace(/\+/g,"%2B")+"&csrf="+top.ICEcoder.csrf,b.replace(/\+/g,"%2B")),top.ICEcoder.serverMessage("<b>"+top.t["Renaming to"]+"</b><br>"+b),top.ICEcoder.setPreviousFiles())},moveFile:function(a,b){var c,d;b&&(d=top.ICEcoder.openFiles.indexOf(a.replace(/\|/g,
|
||||
"/")),-1<d&&(top.ICEcoder.openFiles[d]=b,closeTabLink='<a nohref onClick="top.ICEcoder.closeTab(parseInt(this.parentNode.id.slice(3),10))"><img src="images/nav-close.gif" class="closeTab" onMouseOver="prevBG=this.style.backgroundColor;this.style.backgroundColor=\'#333\'; top.ICEcoder.overCloseLink=true" onMouseOut="this.style.backgroundColor=prevBG; top.ICEcoder.overCloseLink=false"></a>',c=top.ICEcoder.openFiles[d],top.get("tab"+(d+1)).innerHTML=closeTabLink+" "+c.slice(c.lastIndexOf("/")).replace(/\//,
|
||||
""),top.get("tab"+(d+1)).title=b),top.ICEcoder.ask("Are you sure you want to move file "+a+" to "+b+" ?")&&(top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=move&oldFileName="+a.replace(/\//g,"|").replace(/\+/g,"%2B")+"&csrf="+top.ICEcoder.csrf,b.replace(/\//g,"|").replace(/\+/g,"%2B")),top.ICEcoder.serverMessage("<b>"+top.t["Moving to"]+"</b><br>"+b)),top.ICEcoder.setPreviousFiles())},deleteFiles:function(a){var b;a=a?a:top.ICEcoder.selectedFiles;b=a.toString().replace(/\|/g,"/").replace(/,/g,
|
||||
|
||||
Reference in New Issue
Block a user