mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-10 10:36:47 +01:00
XHR and JSON now used when saving
First step towards replacing the old HTTP & form posting looparound method, with a much more efficient XHR and JSON response system. For now, only save uses this, load, delete, perms etc use old system until save is stablised and fully tested. Starts XHR call and when we have a response, if there's an error, show that, otherwise, do the items listed in the doNext value.
This commit is contained in:
@@ -1178,7 +1178,7 @@ var ICEcoder = {
|
||||
: "|[NEW]";
|
||||
}
|
||||
filePath = filePath.replace("||","|");
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=save&file="+filePath+"&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&saveType="+saveType+"&csrf="+top.ICEcoder.csrf);
|
||||
top.ICEcoder.serverQueue("add","lib/file-control-xhr.php?action=save&file="+filePath+"&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&saveType="+saveType+"&csrf="+top.ICEcoder.csrf);
|
||||
top.ICEcoder.serverMessage('<b>'+top.t['Saving']+'</b><br>'+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,""));
|
||||
},
|
||||
|
||||
@@ -2060,7 +2060,36 @@ var ICEcoder = {
|
||||
// If we've just removed from the array and there's another action queued up, or we're triggering for the first time
|
||||
// then do the next requested process, stored at array pos 0
|
||||
if (action=="del" && ICEcoder.serverQueueItems.length>=1 || ICEcoder.serverQueueItems.length==1) {
|
||||
setTimeout(function() {top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href=ICEcoder.serverQueueItems[0]},1);
|
||||
if (item && item.indexOf('action=save')>0) {
|
||||
|
||||
saveURL = ICEcoder.serverQueueItems[0];
|
||||
|
||||
var xhr = top.ICEcoder.xhrObj();
|
||||
|
||||
xhr.onreadystatechange=function() {
|
||||
if (xhr.readyState==4 && xhr.status==200) {
|
||||
// console.log(xhr.responseText);
|
||||
var statusArray = JSON.parse(xhr.responseText);
|
||||
// console.log(statusArray);
|
||||
|
||||
if (statusArray.status.error) {
|
||||
top.ICEcoder.message(statusArray.status.errorMsg);
|
||||
} else {
|
||||
eval(statusArray.action.doNext);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
// console.log('Calling '+saveURL+' via XHR');
|
||||
xhr.open("POST",saveURL,true);
|
||||
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xhr.send('contents='+top.document.getElementById('saveTemp1').value);
|
||||
|
||||
|
||||
} else {
|
||||
setTimeout(function() {top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href=ICEcoder.serverQueueItems[0]},1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user