From fabed98033ea963b01bda0643fb5c930152030fb Mon Sep 17 00:00:00 2001 From: mattpass Date: Sat, 26 Sep 2020 08:30:02 +0100 Subject: [PATCH] iceLoc now part of ICEcoder object --- assets/js/icecoder.js | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/assets/js/icecoder.js b/assets/js/icecoder.js index 0814307..6fecb11 100644 --- a/assets/js/icecoder.js +++ b/assets/js/icecoder.js @@ -3,9 +3,6 @@ const get = function(elem) { return document.getElementById(elem); }; -// URL we're viewing ICEcoder from -const iceLoc = window.location.origin + window.location.pathname.replace(/\/$/, ""); - // Main ICEcoder object var ICEcoder = { @@ -13,6 +10,9 @@ var ICEcoder = { // INIT // ==== + // URL we're viewing ICEcoder from + iceLoc: window.location.origin + window.location.pathname.replace(/\/$/, ""), + // Define settings filesW: 250, // Width of files pane minFilesW: 14, // Min width of files pane @@ -144,7 +144,7 @@ var ICEcoder = { // Every 5 mins, ping our file to keep the session alive if (0 === ic.openSeconds % 300) { - ic.filesFrame.contentWindow.frames['pingActive'].location.href = iceLoc + "/lib/session-active-ping.php"; + ic.filesFrame.contentWindow.frames['pingActive'].location.href = ic.iceLoc + "/lib/session-active-ping.php"; } // Every 3 seconds, re-index if we're not already busy @@ -154,7 +154,7 @@ var ICEcoder = { let timestampExtra = ic.indexData ? "?timestamp=" + ic.indexData.timestamps.indexed + "&csrf=" + ic.csrf : ""; - fetch(iceLoc + '/lib/indexer.php' + timestampExtra) + fetch(ic.iceLoc + '/lib/indexer.php' + timestampExtra) .then(function(response) { // Convert to JSON return response.json(); @@ -1668,7 +1668,7 @@ var ICEcoder = { dir.parentNode.className = dir.className = "pft-directory"; } if (load) { - this.filesFrame.contentWindow.frames['fileControl'].location.href = iceLoc + "/lib/get-branch.php?location=" + dir.childNodes[1].id + "&csrf=" + this.csrf; + this.filesFrame.contentWindow.frames['fileControl'].location.href = this.iceLoc + "/lib/get-branch.php?location=" + dir.childNodes[1].id + "&csrf=" + this.csrf; } else if("UL" === node.tagName) { node.parentNode.removeChild(node); } @@ -1883,7 +1883,7 @@ var ICEcoder = { newFolder = this.getInput('Enter new folder name at ' + shortURL, ''); if (newFolder) { newFolder = (shortURL + "/" + newFolder).replace(/\/\//, "/"); - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=newFolder&csrf=" + this.csrf, encodeURIComponent(newFolder.replace(/\//g, "|"))); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=newFolder&csrf=" + this.csrf, encodeURIComponent(newFolder.replace(/\//g, "|"))); this.serverMessage('' + t['Creating Folder'] + ' ' + newFolder.replace(/^\/|/g, '')); } }, @@ -1947,7 +1947,7 @@ var ICEcoder = { if ("/[NEW]" !== shortURL) { fileLink = fileLink.replace(/\//g, "|"); - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=load&file=" + encodeURIComponent(fileLink) + "&csrf=" + this.csrf + "&lineNumber=" + line, encodeURIComponent(fileLink)); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=load&file=" + encodeURIComponent(fileLink) + "&csrf=" + this.csrf + "&lineNumber=" + line, encodeURIComponent(fileLink)); this.serverMessage('' + t['Opening File'] + ' ' + shortURL.substr(shortURL.lastIndexOf("/") + 1)); } else { this.createNewTab(true, shortURL); @@ -1985,7 +1985,7 @@ var ICEcoder = { line = flSplit[1]; } - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=getRemoteFile&csrf=" + this.csrf + "&lineNumber=" + line, encodeURIComponent(remoteFile)); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=getRemoteFile&csrf=" + this.csrf + "&lineNumber=" + line, encodeURIComponent(remoteFile)); this.serverMessage('' + t['Getting'] + ' ' + remoteFile); }, @@ -2138,7 +2138,7 @@ var ICEcoder = { : "|[NEW]"; } filePath = filePath.replace("||", "|"); - ic.serverQueue("add", iceLoc + "/lib/file-control.php?action=save&fileMDT=" + ic.openFileMDTs[ic.selectedTab - 1] + "&fileVersion=" + ic.openFileVersions[ic.selectedTab - 1] + "&saveType=" + saveType + "&newFileAutoSave=" + newFileAutoSave + "&tabNum=" + ic.selectedTab + "&csrf=" + ic.csrf,encodeURIComponent(filePath), changes); + ic.serverQueue("add", ic.iceLoc + "/lib/file-control.php?action=save&fileMDT=" + ic.openFileMDTs[ic.selectedTab - 1] + "&fileVersion=" + ic.openFileVersions[ic.selectedTab - 1] + "&saveType=" + saveType + "&newFileAutoSave=" + newFileAutoSave + "&tabNum=" + ic.selectedTab + "&csrf=" + ic.csrf,encodeURIComponent(filePath), changes); ic.serverMessage('' + t['Saving'] + ' ' + ic.openFiles[ic.selectedTab - 1].replace(iceRoot, "").replace(/^\/|/g, '')); }, 0, ic); }, @@ -2157,7 +2157,7 @@ var ICEcoder = { newName = this.getInput(t['Please enter the...'], shortURL); } if (newName) { - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=rename&oldFileName=" + encodeURIComponent(oldName.replace(/\|/g, "/")) + "&csrf=" + this.csrf,encodeURIComponent(newName)); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=rename&oldFileName=" + encodeURIComponent(oldName.replace(/\|/g, "/")) + "&csrf=" + this.csrf,encodeURIComponent(newName)); this.serverMessage('' + t['Renaming to'] + ' ' + newName.replace(/^\/|/g, '')); this.setPreviousFiles(); } @@ -2169,7 +2169,7 @@ var ICEcoder = { if (newName && newName !== oldName) { if (this.ask("Are you sure you want to move file " + oldName + " to " + newName + " ?")){ - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=move&oldFileName=" + encodeURIComponent(oldName.replace(/\//g, "|")) + "&csrf=" + this.csrf, encodeURIComponent(newName.replace(/\//g, "|"))); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=move&oldFileName=" + encodeURIComponent(oldName.replace(/\//g, "|")) + "&csrf=" + this.csrf, encodeURIComponent(newName.replace(/\//g, "|"))); this.serverMessage('' + t['Moving to'] + ' ' + newName.replace(/^\/|/g, '')); } @@ -2184,7 +2184,7 @@ var ICEcoder = { tgtFiles = fileList ? fileList : this.selectedFiles; tgtListDisplay = tgtFiles.toString().replace(/\|/g, "/").replace(/,/g, "\n"); if (0 < tgtFiles.length && this.ask('Delete:\n\n' + tgtListDisplay + '?')) { - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=delete&csrf=" + this.csrf,encodeURIComponent(tgtFiles.join(";"))); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=delete&csrf=" + this.csrf,encodeURIComponent(tgtFiles.join(";"))); this.serverMessage('' + t['Deleting File'] + ' ' + tgtListDisplay.replace(/^\/|/g, '')); } }, @@ -2208,7 +2208,7 @@ var ICEcoder = { if (this.copiedFiles) { for (let i = 0; i < this.copiedFiles.length; i++) { if ("|" !== this.copiedFiles[i]) { - this.serverQueue("add", iceLoc + "/lib/file-control.php?action=paste&location=" + location + "&csrf=" + this.csrf, encodeURIComponent(this.copiedFiles[i])); + this.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=paste&location=" + location + "&csrf=" + this.csrf, encodeURIComponent(this.copiedFiles[i])); this.serverMessage('' + t['Pasting File'] + ' ' + this.copiedFiles[i].toString().replace(/\|/g, "/").replace(/,/g, "\n").replace(/^\/|/g, '')); } else { this.message(t['Sorry cannot paste...']); @@ -2359,7 +2359,7 @@ var ICEcoder = { } } }; - xhr.open("POST", iceLoc + "/lib/file-control.php?action=checkExists&csrf=" + this.csrf, true); + xhr.open("POST", this.iceLoc + "/lib/file-control.php?action=checkExists&csrf=" + this.csrf, true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); timeStart = new Date().getTime(); xhr.send('timeStart=' + timeStart + '&file=' + encodeURIComponent(path)); @@ -2907,7 +2907,7 @@ var ICEcoder = { // Finally, show loading mask and open multiple results pane using QS params this.showHide('show',get('loadingMask')); get('mediaContainer').innerHTML = ''; @@ -2927,7 +2927,7 @@ var ICEcoder = { replaceInFile: function(fileRef, find, replace) { this.serverQueue( "add", - iceLoc + + this.iceLoc + "/lib/file-control.php?action=replaceText&find=" + find + "&replace=" + replace + "&csrf=" + this.csrf, @@ -3496,7 +3496,7 @@ var ICEcoder = { // Then send through to the settings page to update setting this.serverQueue( "add", - iceLoc + "/lib/settings.php?saveFiles=" + encodeURIComponent(previousFiles) + "&csrf=" + this.csrf, + this.iceLoc + "/lib/settings.php?saveFiles=" + encodeURIComponent(previousFiles) + "&csrf=" + this.csrf, encodeURIComponent(previousFiles) ); this.updateLast10List(previousFiles); @@ -3566,7 +3566,7 @@ var ICEcoder = { tabExtra = tab ? '?tab=' + tab + '&csrf=' + this.csrf : ''; get('mediaContainer').innerHTML = ''; @@ -3578,7 +3578,7 @@ var ICEcoder = { helpScreen: function() { get('mediaContainer').innerHTML = ''; this.showHide('show', get('blackMask')); }, @@ -3587,7 +3587,7 @@ var ICEcoder = { versionsScreen: function(file) { get('mediaContainer').innerHTML = ''; this.showHide('show', get('blackMask')); }, @@ -3632,7 +3632,7 @@ var ICEcoder = { // Show the auto-logout warning screen bugReportScreen: function() { get('mediaContainer').innerHTML = ''; this.showHide('show', get('blackMask')); }, @@ -3640,7 +3640,7 @@ var ICEcoder = { // Show the plugins manager pluginsManager: function() { get('mediaContainer').innerHTML = ''; this.showHide('show', get('blackMask')); }, @@ -3648,14 +3648,14 @@ var ICEcoder = { // Go to localhost root goLocalhostRoot: function() { this.filesFrame.contentWindow.frames['fileControl'].location.href = - iceLoc + + this.iceLoc + "/lib/go-localhost-root.php"; }, // Show the FTP manager ftpManager: function() { get('mediaContainer').innerHTML = ''; this.showHide('show', get('blackMask')); }, @@ -3820,20 +3820,20 @@ var ICEcoder = { // Pass target file/folder to Zip It! zipIt: function(tgt) { tgt=tgt.replace(/\//g, "|"); - this.filesFrame.contentWindow.frames['fileControl'].location.href = iceLoc + "/plugins/zip-it/index.php?zip=" + tgt + "&csrf=" + this.csrf; + this.filesFrame.contentWindow.frames['fileControl'].location.href = this.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; + this.filesFrame.contentWindow.frames['fileControl'].location.href = this.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.serverQueue("add", this.iceLoc + "/lib/file-control.php?action=perms&perms=" + perms + "&csrf=" + this.csrf, encodeURIComponent(file)); this.serverMessage('chMod ' + perms + ' on ' + file.replace(/\|/g, "/").replace(/^\/|/g, "")); }, @@ -3921,7 +3921,7 @@ var ICEcoder = { // update: function() { // if (true == confirm(t['Please note for...'])) { // this.showHide('show', get('loadingMask')); - // window.location = iceLoc + "/lib/updater.php"; + // window.location = this.iceLoc + "/lib/updater.php"; // } else { // window.open("https://icecoder.net"); // } @@ -3971,7 +3971,7 @@ var ICEcoder = { this.bugFilesSizesSeen = []; this.bugFileCheckInt = setInterval(function(ic) { bugCheckURL = - iceLoc + + ic.iceLoc + "/lib/bug-files-check.php?" + "files=" + ("" !== ic.bugFilePaths[0] ? ic.bugFilePaths.join() : "null").replace(/\//g, "|") + "&filesSizesSeen="; @@ -4175,7 +4175,7 @@ var ICEcoder = { this.openFiles.push(shortURL); // Setup a new tab - closeTabLink = ''; + closeTabLink = ''; get('tab' + (this.openFiles.length)).style.display = "inline-block"; fileName = this.openFiles[this.openFiles.length - 1]; fileExt = fileName.substr(fileName.lastIndexOf(".") + 1); @@ -4223,7 +4223,7 @@ var ICEcoder = { this.openFiles[tabNum - 1] = newName; // Setup a new tab - closeTabLink = ''; + closeTabLink = ''; fileName = this.openFiles[tabNum - 1]; fileExt = fileName.substr(fileName.lastIndexOf(".") + 1); get('tab' + tabNum).innerHTML = closeTabLink + "" + fileName.slice(fileName.lastIndexOf("/")).replace(/\//, ""); @@ -5151,7 +5151,7 @@ var ICEcoder = { }, 500); // Mark tutorial as done in users settings and return xhr = this.xhrObj(); - xhr.open("POST",iceLoc+"/lib/settings.php?action=turnOffTutorialOnLogin&csrf="+this.csrf,true); + xhr.open("POST",this.iceLoc+"/lib/settings.php?action=turnOffTutorialOnLogin&csrf="+this.csrf,true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send(); } @@ -5185,7 +5185,7 @@ var ICEcoder = { startSnake: function() { this.snakePlaying = true; this.showHide('show',get('blackMask')); - get('mediaContainer').innerHTML = 'Let\'s play
snake


Use arrow keys to eat your code

(it returns afterwards of course) :-)
'; + get('mediaContainer').innerHTML = 'Let\'s play
snake


Use arrow keys to eat your code

(it returns afterwards of course) :-)
'; setTimeout(function(ic) { ic.showHide('hide',get('blackMask')); get('mediaContainer').innerHTML = '';