From 374178ad14c869d6bfcbdc8fe438dcbf3e0b34ae Mon Sep 17 00:00:00 2001 From: mattpass Date: Sun, 20 Sep 2020 09:57:42 +0100 Subject: [PATCH] Format updates on some core functions in icecoder.js --- assets/js/icecoder.js | 102 ++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/assets/js/icecoder.js b/assets/js/icecoder.js index 04ee22d..149eb80 100644 --- a/assets/js/icecoder.js +++ b/assets/js/icecoder.js @@ -3819,40 +3819,42 @@ var ICEcoder = { // Pass target file/folder to Zip It! zipIt: function(tgt) { - tgt=tgt.replace(/\//g,"|"); - this.filesFrame.contentWindow.frames['fileControl'].location.href="plugins/zip-it/index.php?zip="+tgt+"&csrf="+this.csrf; + tgt=tgt.replace(/\//g, "|"); + this.filesFrame.contentWindow.frames['fileControl'].location.href = iceLoc + "/plugins/zip-it/index.php?zip=" + tgt + "&csrf=" + this.csrf; }, // Prompt to download our file downloadFile: function(file) { - file=file.replace(/\//g,"|"); - this.filesFrame.contentWindow.frames['fileControl'].location.href=iceLoc+"/lib/download.php?file="+file+"&csrf="+this.csrf; + file=file.replace(/\//g, "|"); + this.filesFrame.contentWindow.frames['fileControl'].location.href = iceLoc + "/lib/download.php?file=" + file + "&csrf=" + this.csrf; }, // Change permissions on a file/folder - chmod: function(file,perms) { - file = file.replace(iceRoot,""); - this.showHide('hide',get('blackMask')); - this.serverQueue("add",iceLoc+"/lib/file-control.php?action=perms&perms="+perms+"&csrf="+this.csrf,encodeURIComponent(file)); - this.serverMessage('chMod '+perms+' on '+file.replace(/\|/g,"/").replace(/^\/|/g, '')); + chmod: function(file, perms) { + file = file.replace(iceRoot, ""); + this.showHide('hide', get('blackMask')); + this.serverQueue("add", iceLoc + "/lib/file-control.php?action=perms&perms=" + perms + "&csrf=" + this.csrf, encodeURIComponent(file)); + this.serverMessage('chMod ' + perms + ' on ' + file.replace(/\|/g, "/").replace(/^\/|/g, "")); }, // Open/show the preview window openPreviewWindow: function() { - if (this.openFiles.length>0) { - var filepath, filename, fileExt; + if (0 < this.openFiles.length) { + let filepath, filename, fileExt; - filepath = this.openFiles[this.selectedTab-1]; - filename = filepath.substr(filepath.lastIndexOf("/")+1); - fileExt = filename.substr(filename.lastIndexOf(".")+1); + filepath = this.openFiles[this.selectedTab - 1]; + filename = filepath.substr(filepath.lastIndexOf("/") + 1); + fileExt = filename.substr(filename.lastIndexOf(".") + 1); this.previewWindowLoading = true; - this.previewWindow = window.open(filepath,"previewWindow",500,500); - if (["md"].indexOf(fileExt) > -1) { + this.previewWindow = window.open(filepath, "previewWindow", 500, 500); + if (-1 < ["md"].indexOf(fileExt)) { this.previewWindow.addEventListener('load', function(ic, content) { ic.previewWindowLoading = false; ic.previewWindow.document.documentElement.innerHTML = "" - setTimeout(function() {ic.previewWindow.document.documentElement.innerHTML = content}, 100); + setTimeout(function() { + ic.previewWindow.document.documentElement.innerHTML = content; + }, 100); }(ic, mmd(ic.getThisCM().getValue())), false); } else { this.previewWindow.onload = function() { @@ -3870,20 +3872,20 @@ var ICEcoder = { // Reset auto-logout timer resetAutoLogoutTimer: function() { - if(this.autoLogoutMins > 1 && this.autoLogoutTimer > (this.autoLogoutMins*60)-60) { - this.showHide('hide',get('blackMask')); + if (1 < this.autoLogoutMins && this.autoLogoutTimer > (this.autoLogoutMins * 60) - 60) { + this.showHide('hide', get('blackMask')); } this.autoLogoutTimer = 0; }, // Logout of ICEcoder logout: function(type) { - window.location = window.location + "?logout&"+(type ? "type="+type+"&" : "")+"csrf="+this.csrf; + window.location = window.location + "?logout&" + (type ? "type=" + type + "&" : "") + "csrf=" + this.csrf; }, // Show a message outputMsg: function(msg) { - var output = this.output.innerHTML; + let output = this.output.innerHTML; // If only placeholder, clear that if ("Output
via ICEcoder.output(message);

" === output) { output = ""; @@ -3902,13 +3904,13 @@ var ICEcoder = { }, // Get the users input - getInput: function(question,defaultValue) { - return prompt(question,defaultValue); + getInput: function(question, defaultValue) { + return prompt(question, defaultValue); }, // Show a data screen message dataMessage: function(message) { - var dM; + let dM; dM = this.content.contentWindow.document.getElementById('dataMessage'); dM.style.display = "block"; @@ -3917,47 +3919,39 @@ var ICEcoder = { // Update ICEcoder // update: function() { - // var autoUpdate; - // - // autoUpdate = confirm(t['Please note for...']); - // if (autoUpdate) { - // this.showHide('show',get('loadingMask')); - // window.location = iceLoc+"/lib/updater.php"; + // if (true == confirm(t['Please note for...'])) { + // this.showHide('show', get('loadingMask')); + // window.location = iceLoc + "/lib/updater.php"; // } else { - // window.open("https://this.net"); + // window.open("https://icecoder.net"); // } // }, // ICEcoder just updated updated: function() { get('blackMask').style.visibility = "visible"; - get('mediaContainer').innerHTML = '

Thanks for updating to v'+this.versionNo+'!

' + get('mediaContainer').innerHTML = '

Thanks for updating to v' + this.versionNo + '!

' + '

Click anywhere to continue using this...

'; }, // XHR object xhrObj: function(){ try {return new XMLHttpRequest();}catch(e){} - try {return new ActiveXObject("Msxml3.XMLHTTP");}catch(e){} - try {return new ActiveXObject("Msxml2.XMLHTTP.6.0");}catch(e){} - try {return new ActiveXObject("Msxml2.XMLHTTP.3.0");}catch(e){} - try {return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){} - try {return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){} return null; }, // Open bug report openBugReport: function() { - if(this.bugReportStatus=="off") { + if ("off" === this.bugReportStatus) { this.message(t['You can start...']); } - if(this.bugReportStatus=="error") { + if ("error" === this.bugReportStatus) { this.message(t['Error cannot find...']); } - if(this.bugReportStatus=="ok") { + if ("ok" === this.bugReportStatus) { this.message(t['No new errors...']); } - if(this.bugReportStatus=="bugs") { + if ("bugs" === this.bugReportStatus) { // Show bug report screen and set the bugs state as seen this.bugReportScreen(); this.bugFilesSizesSeen = this.bugFilesSizesActual; @@ -3968,7 +3962,7 @@ var ICEcoder = { startBugChecking: function() { var bugCheckURL; - if (this.bugFileCheckTimer !== 0) { + if (0 !== this.bugFileCheckTimer) { // Clear any existing interval if ("undefined" != typeof this.bugFileCheckInt) { clearInterval(this.bugFileCheckInt); @@ -3976,23 +3970,23 @@ var ICEcoder = { // Start a new timer this.bugFilesSizesSeen = []; this.bugFileCheckInt = setInterval(function(ic) { - bugCheckURL = iceLoc+"/lib/bug-files-check.php?"; - bugCheckURL += "files="+(ic.bugFilePaths[0] !== "" ? ic.bugFilePaths.join() : "null").replace(/\//g,"|"); - bugCheckURL += "&filesSizesSeen="; - if (ic.bugFilesSizesSeen.length != ic.bugFilePaths.length) { + bugCheckURL = + iceLoc + + "/lib/bug-files-check.php?" + + "files=" + ("" !== ic.bugFilePaths[0] ? ic.bugFilePaths.join() : "null").replace(/\//g, "|") + + "&filesSizesSeen="; + if (ic.bugFilesSizesSeen.length !== ic.bugFilePaths.length) { // Fill the array with nulls - for (var i=0; i