From b87f5ba969c68108441f06ad2f190ea7e26236ba Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Tue, 30 Jun 2015 17:18:36 +0100 Subject: [PATCH] Need to declare as function, error handling --- lib/ice-coder.js | 14 ++++++++++---- lib/ice-coder.min.js | 28 +++++++++++++++------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 1187ce3..8a1eb08 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1497,13 +1497,13 @@ var ICEcoder = { }, // Check for existance of a file/dir - checkExists(path) { + checkExists: function(path) { var xhr, statusObj, timeStart; path = path.replace(/\|/g,"/"); - // Start a seperate XHR call. We do a seperate one immediately rather than in the serverQueue because - // we may need to run independently and straight away, eg for checking if a file/dir exists in 'Save As' function + // Start a seperate XHR call. We run seperately rather than add into the serverQueue because we may need to run + // immediately, eg need to if a file/dir exists mid flow in 'Save As' function, so can't go into queue xhr = top.ICEcoder.xhrObj(); xhr.onreadystatechange=function() { if (xhr.readyState==4) { @@ -1528,7 +1528,13 @@ var ICEcoder = { // OK reponse? If error, show that, otherwise do whatever we're required to do next if (xhr.status==200) { - if (!statusObj.status.error) { + if (statusObj.status.error) { + top.ICEcoder.message(statusObj.status.errorMsg); + console.log("ICEcoder error info for your request..."); + console.log(statusObj); + top.ICEcoder.serverMessage(); + top.ICEcoder.serverQueue('del',0); + } else { eval(statusObj.action.doNext); } // Some other response? Display a message about that diff --git a/lib/ice-coder.min.js b/lib/ice-coder.min.js index 13bdcb9..d9ebd64 100644 --- a/lib/ice-coder.min.js +++ b/lib/ice-coder.min.js @@ -1,11 +1,11 @@ var get=function(a){return top.document.getElementById(a)},ICEcoder={filesW:250,minFilesW:14,maxFilesW:250,selectedTab:0,savedPoints:[],canSwitchTabs:!0,openFiles:[],openFileMDTs:[],cMInstances:[],nextcMInstance:1,selectedFiles:[],findMode:!1,scrollbarVisible:!1,mouseDown:!1,draggingFilesW:!1,draggingTab:!1,draggingWithKey:!1,tabLeftPos:[],tabBGcurrent:"#141414",tabBGselected:"#49d",tabBGopen:"#c3c3c3",tabBGnormal:"transparent",tabFGcurrent:"#fff",tabFGselected:"#fff",tabFGopenFile:"#000",tabFGnormalFile:"#eee", tabFGnormalTab:"#888",serverQueueItems:[],previewWindow:!1,previewWindowLoading:!1,pluginIntervalRefs:[],overPopup:!1,cmdKey:!1,fmReady:!1,bugReportStatus:"off",bugReportPath:"",bugFilesSizesSeen:[],bugFilesSizesActual:[],githubDiff:!1,githubAuthTokenSet:!1,splitPane:!1,renderLineStyle:[],renderPaneShiftAmount:0,debounce:"",editorFocusInstance:"",ready:!1,initAliases:function(){for(var a="header files fileOptions optionsFile optionsEdit optionsSource optionsHelp filesFrame editor tabsBar findBar content footer nestValid splitPaneControls charDisplay byteDisplay".split(" "), -b=0;bICEcoder.minFilesW+1?ICEcoder.filesW-=Math.ceil((ICEcoder.filesW-ICEcoder.minFilesW)/2):ICEcoder.filesW=ICEcoder.minFilesW;("expand"==a&&ICEcoder.filesW==ICEcoder.maxFilesW||"contract"==a&&ICEcoder.filesW==ICEcoder.minFilesW)&&clearInterval(ICEcoder.changeFilesInt);ICEcoder.setLayout()},canResizeFilesW:function(){top.ICEcoder.ready&&"w-resize"== top.document.body.style.cursor?top.ICEcoder.mouseDown&&(top.ICEcoder.filesW=top.ICEcoder.maxFilesW=250<=top.ICEcoder.mouseX&&400>=top.ICEcoder.mouseX?top.ICEcoder.mouseX:250>top.ICEcoder.mouseX?250:400,top.ICEcoder.files.style.width=top.ICEcoder.filesFrame.style.width=top.ICEcoder.filesW+"px",top.ICEcoder.setLayout(),top.ICEcoder.draggingFilesW=!0):top.ICEcoder.draggingFilesW=!1},lockUnlockNav:function(){var a;a=top.ICEcoder.filesFrame.contentWindow.document.getElementById("fmLock");ICEcoder.lockedNav= !ICEcoder.lockedNav;a.style.backgroundPosition=ICEcoder.lockedNav?"0 0":"-16px 0"},showHidePlugins:function(a){get("plugins").style.width="show"==a?"55px":"3px";get("plugins").style.background="show"==a?"#333":"transparent";"show"==a&&ICEcoder.changeFilesW("expand")},cMonFocus:function(a,b){top.ICEcoder.getCaretPosition();top.ICEcoder.updateCharDisplay();top.ICEcoder.updateByteDisplay();top.ICEcoder.editorFocusInstance=b;top.ICEcoder.getCaretPosition()},cMonBlur:function(a,b){},cMonKeyUp:function(a, @@ -62,11 +62,13 @@ b),top.ICEcoder.ask("Are you sure you want to move file "+a+" to "+b+" ?")&&(top "lib/file-control-xhr.php?action=paste&location="+a+"&csrf="+top.ICEcoder.csrf,top.ICEcoder.copiedFiles[b]),top.ICEcoder.serverMessage(""+top.t["Pasting File"]+"
"+top.ICEcoder.copiedFiles[b].toString().replace(/\|/g,"/").replace(/,/g,"\n"))):top.ICEcoder.message(top.t["Sorry cannot paste..."]);else top.ICEcoder.message(top.t["Nothing to paste..."])},duplicateFiles:function(a){var b;top.ICEcoder.copiedFiles&&(b=top.ICEcoder.copiedFiles);top.ICEcoder.copyFiles(a,"dontShowPaste","dontHide"); a=a[0].substr(0,a[0].lastIndexOf("|"));top.ICEcoder.pasteFiles(a);"undefined"!=typeof b&&(top.ICEcoder.copiedFiles=b)},uploadFilesSelect:function(a){top.get("uploadDir").value=a;top.get("fileInput").click()},uploadFilesSubmit:function(a){""!=top.get("fileInput").value&&(top.ICEcoder.showHide("show",top.get("loadingMask")),top.get("uploadFilesForm").submit(),event.preventDefault())},showHideFileNav:function(a,b){var c=["optionsFile","optionsEdit","optionsSource","optionsHelp"];if("hide"==a)fileNavInt= setTimeout(function(){for(var a=0;ac&&(b-=b+a-c),top.get("fileMenu").style.top=b+"px");return!1},showFileMenu:function(){top.get("fileMenu").style.display="inline-block";setTimeout(function(){top.get("fileMenu").style.opacity="1"},4)},hideFileMenu:function(){top.get("fileMenu").style.display="none";top.get("fileMenu").style.opacity= -"0"},updateFileManagerList:function(a,b,c,d,e,f,g){var h,k,l,p,n,m,q;if("add"==a&&!top.get("filesFrame").contentWindow.document.getElementById(b.replace(top.iceRoot,"").replace(/\/$/,"").replace(/\//g,"|")+"|"+c)){h="file"==g?"pft-file ext-"+c.substr(c.indexOf(".")+1):"pft-directory";d="file"==g?top.ICEcoder.newFilePerms:top.ICEcoder.newDirPerms;b||(b="/");b=b.replace(top.iceRoot,"/");b=b.replace("//","/");k=top.get("filesFrame").contentWindow.document.getElementById(b.replace(/\//g,"|"));l=k.parentNode.parentNode.nextSibling; -p=document.createTextNode("\n");n=777==d?"background: #800; color: #eee":"color: #888";n='c&&(b-=b+a-c),top.get("fileMenu").style.top=b+"px");return!1},showFileMenu:function(){top.get("fileMenu").style.display="inline-block";setTimeout(function(){top.get("fileMenu").style.opacity="1"},4)},hideFileMenu:function(){top.get("fileMenu").style.display= +"none";top.get("fileMenu").style.opacity="0"},updateFileManagerList:function(a,b,c,d,e,f,g){var h,k,l,p,n,m,q;if("add"==a&&!top.get("filesFrame").contentWindow.document.getElementById(b.replace(top.iceRoot,"").replace(/\/$/,"").replace(/\//g,"|")+"|"+c)){h="file"==g?"pft-file ext-"+c.substr(c.indexOf(".")+1):"pft-directory";d="file"==g?top.ICEcoder.newFilePerms:top.ICEcoder.newDirPerms;b||(b="/");b=b.replace(top.iceRoot,"/");b=b.replace("//","/");k=top.get("filesFrame").contentWindow.document.getElementById(b.replace(/\//g, +"|"));l=k.parentNode.parentNode.nextSibling;p=document.createTextNode("\n");n=777==d?"background: #800; color: #eee":"color: #888";n='        '+c+' '+ d+"";if(3>l.childNodes.length)m=document.createElement("ul"),l=k.parentNode.parentNode,l.parentNode.insertBefore(m,l.nextSibling),m=document.createElement("li"),m.className=h,m.draggable=!1,m.ondrag=function(a){top.ICEcoder.draggingWithKeyTest(a);top.ICEcoder.getcMInstance()&&(-1==top.ICEcoder.editorFocusInstance.indexOf("diff")?top.ICEcoder.getcMInstance().focus():top.ICEcoder.getcMdiffInstance().focus())},m.ondragend=function(){top.ICEcoder.dropFile(this)},m.innerHTML=n,l.nextSibling.appendChild(m), l.nextSibling.appendChild(p);else for(k=0;kc||"folder"==g&&"file"==m||k==l.childNodes.length-1)){m=document.createElement("li");m.className=h;m.draggable=!1;m.ondrag=function(a){top.ICEcoder.draggingWithKeyTest(a);top.ICEcoder.getcMInstance()&&(-1==top.ICEcoder.editorFocusInstance.indexOf("diff")?top.ICEcoder.getcMInstance().focus(): @@ -104,8 +106,8 @@ top.ICEcoder.codeAssist?"0 0":"-16px 0";top.ICEcoder.cssColorPreview();top.ICEco e).value=d.getValue());else if("del"==a){if(ICEcoder.serverQueueItems[0]&&0'+top.t["Cancelled tasks"]+"");setTimeout(function(){top.ICEcoder.serverMessage()},2E3)},setPreviousFiles:function(){var a; -a=top.ICEcoder.openFiles.join(",").replace(/\//g,"|").replace(/(\|\[NEW\])|(,\|\[NEW\])/g,"").replace(/(^,)|(,$)/g,"");""==a&&(a="CLEAR");top.ICEcoder.serverQueue("add","lib/settings.php?saveFiles="+a+"&csrf="+top.ICEcoder.csrf);top.ICEcoder.updateLast10List(a)},updateLast10List:function(a){var b,c,d;a=a.split(",");for(var e=0;e'+top.t["Cancelled tasks"]+"");setTimeout(function(){top.ICEcoder.serverMessage()}, +2E3)},setPreviousFiles:function(){var a;a=top.ICEcoder.openFiles.join(",").replace(/\//g,"|").replace(/(\|\[NEW\])|(,\|\[NEW\])/g,"").replace(/(^,)|(,$)/g,"");""==a&&(a="CLEAR");top.ICEcoder.serverQueue("add","lib/settings.php?saveFiles="+a+"&csrf="+top.ICEcoder.csrf);top.ICEcoder.updateLast10List(a)},updateLast10List:function(a){var b,c,d;a=a.split(",");for(var e=0;e"+a[e].replace(/\|/g,"/")+"\n",c=top.ICEcoder.content.contentWindow.document.getElementById("last10Files"),-1==c.innerHTML.indexOf(b)&&(d=c.innerHTML.split("\n"),(10<=d.length||'
[none]


'==d[0]||""==d[d.length-1])&&d.pop(),c.innerHTML=b+d.join("\n")))},autoOpenFiles:function(){if(0');top.ICEcoder.showHide(a? "hide":"show",top.get("blackMask"))},helpScreen:function(){top.get("mediaContainer").innerHTML='';top.ICEcoder.showHide("show",top.get("blackMask"))},showManual:function(a,b){var c;c=b?"#"+b:"";top.get("mediaContainer").innerHTML='';top.ICEcoder.showHide("show",top.get("blackMask"))},propertiesScreen:function(a){top.get("mediaContainer").innerHTML=