Cleaning up js files and improving readability to try and trbl shoot PHPSESSION issue

This commit is contained in:
Maxim Stewart 2018-04-22 03:14:40 -05:00
parent 7cc572b78d
commit 3dbbaa063d
2 changed files with 69 additions and 59 deletions

View File

@ -4,7 +4,9 @@ function getDirSSE() {
var path = "";
// Create path from array of items
for (pathNode of pathNodes) { path += pathNode; }
for (pathNode of pathNodes) {
path += pathNode;
}
// For some reason, PHPSESSID= gets inserted when in sub dir.
// temp work arround is to trim it.
@ -19,12 +21,13 @@ function getDirSSE() {
function getDir(query) {
var formULPTH = document.getElementById("DIRPATHUL");
var path = "";
var temp = "";
// push or pop to path list
if (query === "/") {
// Process path from cookie and set to array/list
if (document.cookie) {
var temp = document.cookie.replace("dirQuery=", "");
temp = document.cookie.replace("dirQuery=", "");
temp = temp.split("/");
// Subtract one b/c paths end with / and create empty slot
var size = temp.length - 1;
@ -32,19 +35,24 @@ function getDir(query) {
for (var i = 0; i < size; i++) {
pathNodes.push(temp[i] + "/");
}
// If no cookie, etup path from root
// If no cookie, setup path from root
} else {
pathNodes.push("." + query); // If in root of server
pathNodes.push("." + query);
}
} else if (query === "../") {
if (pathNodes.length > 1) { pathNodes.pop(); } // Only remove while not in root
} else if (query === "./") { // Do nothing since re-scanning dir
} else { pathNodes.push(query); } // Add path
// Only remove while not in root
if (pathNodes.length > 1) {
pathNodes.pop();
}
} else if (query === "./") {
// Do nothing since re-scanning dir
} else {
pathNodes.push(query); // Add path
}
// Create path from array of items
// for (pathNode of pathNodes) { path += pathNode; console.log(pathNode); }
for (var i = 0; i < pathNodes.length; i++) {
path += pathNodes[i];
for (pathNode of pathNodes) {
path += pathNode; console.log(pathNode);
}
// For some reason, PHPSESSID= gets inserted when in sub dir.
@ -53,7 +61,7 @@ function getDir(query) {
path = path.split("; ").pop();
}
formULPTH.value = path; // Used when uploading a file
formULPTH.value = path; // Setup upload path for form
path = "dirQuery=" + path;
console.log("Path : " + path);
process(path);

View File

@ -8,14 +8,18 @@ function updateHTMLDirList(returnData) {
var insertArea = document.getElementById('dynDiv');
var workingDir = dirPath.innerHTML;
var i = 0;
var size = 0;
// Insert dirs
document.getElementById("path").innerHTML = dirPath.innerHTML;
document.getElementById("path").innerHTML = workingDir;
insertArea.innerHTML = "";
if (workingDir === "./") { var i = 2 } // Remove ,. and ../ if in "root"
// Remove . and ../ if in "root"
if (workingDir === "./") {
var i = 2
}
var size = dirs.length;
size = dirs.length;
for (; i < size; i++) {
var dir = dirs[i].innerHTML;
@ -30,10 +34,13 @@ function updateHTMLDirList(returnData) {
}
// Insert videos
size = videos .length;
var thumbnail = "";
var vidNme = "";
size = videos .length;
for (i = 0; i < size; i++) {
var thumbnail = videos[i].children[0].innerHTML;
var vidNme = videos[i].children[1].innerHTML;
thumbnail = videos[i].children[0].innerHTML;
vidNme = videos[i].children[1].innerHTML;
insertArea.innerHTML += "<span class=\"movieStyle\" title=\"" + vidNme + "\" >"
+ "<img id=\"movieID\" class=\"thumbnail\""
@ -45,14 +52,15 @@ function updateHTMLDirList(returnData) {
}
// Insert images
var path = document.getElementById("path").innerHTML;
size = images.length;
var path = document.getElementById("path").innerHTML;
var thumbnail = ""
size = images.length;
for (i = 0; i < size; i++) {
var thumbnail = images[i].children[0].innerHTML;
thumbnail = images[i].children[0].innerHTML;
if (!thumbnail.includes("favicon.png") && !thumbnail.includes("000.png") &&
!thumbnail.includes("000.jpg") && !thumbnail.includes("000.gif")) {
if (thumbnail.match(/000\.(jpg|png|gif)\b/) == null &&
!thumbnail.includes("favicon.png")) {
insertArea.innerHTML += "<img id=\"imageID\" class=\"iconImg\""
+ " src=\"" + path + thumbnail
+ "\" alt=\"" + thumbnail + "\"/>";
@ -60,9 +68,9 @@ function updateHTMLDirList(returnData) {
}
if (images[0] != undefined) {
if (images[0].children[0].innerHTML.includes("000.jpg") ||
images[0].children[0].innerHTML.includes("000.png") ||
images[0].children[0].innerHTML.includes("000.gif")) {
var imgText = images[0].children[0].innerHTML;
if (imgText.match(/000\.(jpg|png|gif)\b/) != null) {
updateBG(path + images[0].children[0].innerHTML);
} else {
updateBG("resources/images/backgrounds/000.jpg");
@ -75,40 +83,34 @@ function updateHTMLDirList(returnData) {
size = files.length;
for (i = 0; i < size; i++) {
var fileName = files[i].children[0].innerHTML;
var iconImg = "<img id=\"fileID\" class=\"systemIcon\"";
var iconImg = "<img id=\"fileID\" class=\"systemIcon\""
+ setFileIconType(fileName);
if (fileName.includes(".doc") || fileName.includes(".docx") ||
fileName.includes(".xls") || fileName.includes(".xlsx") ||
fileName.includes(".rtf")) {
iconImg += " src=\"resources/images/icons/doc.png\" />";
} else if (fileName.includes(".7z") || fileName.includes(".7zip") ||
fileName.includes(".zip") || fileName.includes(".tar.gz") ||
fileName.includes(".tar.xz") || fileName.includes(".gz") ||
fileName.includes(".rar") || fileName.includes(".jar")) {
iconImg += " src=\"resources/images/icons/arc.png\" />";
} else if (fileName.includes(".pdf")) {
iconImg += " src=\"resources/images/icons/pdf.png\" />";
} else if (fileName.includes(".html")) {
iconImg += " src=\"resources/images/icons/html.png\" />";
} else if (fileName.includes(".txt") || fileName.includes(".conf")) {
iconImg += " src=\"resources/images/icons/text.png\" />";
} else if (fileName.includes(".iso") || fileName.includes(".img")) {
iconImg += " src=\"resources/images/icons/img.png\" />";
} else if (fileName.includes(".sh") || fileName.includes(".batch") ||
fileName.includes(".exe")) {
iconImg += " src=\"resources/images/icons/scrip.png\" />";
} else {
iconImg += " src=\"resources/images/icons/bin.png\" />";
}
if (fileName != "sse.php" && fileName != "upload.php" &&
fileName != "open.php" && fileName != "process.php") {
insertArea.innerHTML += "<div class=\"fileStyle\">"
+ iconImg
+ "<input type=\"text\" id=\"titleID\" class=\"fileTitle\""
+ " readonly=\"true\"" + " value=\"" + fileName + "\" "
+ " onfocusout=\"disableEdits(this)\"/>"
+ "</dir>";
}
insertArea.innerHTML += "<div class=\"fileStyle\">"
+ iconImg
+ "<input type=\"text\" id=\"titleID\" class=\"fileTitle\""
+ " readonly=\"true\"" + " value=\"" + fileName + "\" "
+ " onfocusout=\"disableEdits(this)\"/>"
+ "</dir>";
}
}
function setFileIconType(fileName) {
if (fileName.match(/\.(doc|docx|xls|xlsx|rtf)\b/) != null) {
return " src=\"resources/images/icons/doc.png\" />";
} else if (fileName.match(/\.(7z|7zip|zip|tar.gz|tar.xz|gz|rar|jar)\b/) != null) {
return " src=\"resources/images/icons/arc.png\" />";
} else if (fileName.match(/\.(pdf)\b/) != null) {
return " src=\"resources/images/icons/pdf.png\" />";
} else if (fileName.match(/\.(html)\b/) != null) {
return " src=\"resources/images/icons/html.png\" />";
} else if (fileName.match(/\.(txt|conf)\b/) != null) {
return " src=\"resources/images/icons/text.png\" />";
} else if (fileName.match(/\.(iso|img)\b/) != null) {
return " src=\"resources/images/icons/img.png\" />";
} else if (fileName.match(/\.(sh|batch|exe)\b/) != null) {
return " src=\"resources/images/icons/scrip.png\" />";
} else {
return " src=\"resources/images/icons/bin.png\" />";
}
}