2018-05-03 08:14:28 +00:00
|
|
|
const insertArea = document.getElementById('dynDiv');
|
2018-04-22 06:03:43 +00:00
|
|
|
|
2018-07-29 03:55:02 +00:00
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const handleXMLReturnData = (data) => {
|
2018-08-19 18:51:20 +00:00
|
|
|
if (data.activeElement.tagName == "DIR_LIST") {
|
|
|
|
updateHTMLDirList(data);
|
|
|
|
} else if (data.activeElement.tagName == "LOCK_MESSAGE") {
|
|
|
|
createPassField(data);
|
|
|
|
} else if (data.activeElement.tagName == "SERV_MSG") {
|
|
|
|
document.getElementById("serverMsgView").appendChild(data.activeElement);
|
2018-08-25 21:10:09 +00:00
|
|
|
} else if (data.activeElement.tagName == "FAVES_LIST") {
|
|
|
|
generateFavesList(data);
|
2018-08-19 18:51:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const generateFavesList = (data) => {
|
|
|
|
let listView = document.getElementById("favesList");
|
|
|
|
let favesList = data.getElementsByTagName("FAVE_LINK");
|
2018-12-09 21:40:23 +00:00
|
|
|
let size = favesList.length;
|
2018-11-23 23:46:40 +00:00
|
|
|
listView.innerHTML = "";
|
2018-08-25 21:10:09 +00:00
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
2018-12-09 21:40:23 +00:00
|
|
|
let liTag = document.createElement("LI");
|
|
|
|
let name = favesList[i].innerHTML;
|
|
|
|
let parts = (name.includes("/")) ? name.split("/") : name.split("\\");
|
|
|
|
let txtNode = document.createTextNode(parts[parts.length - 2]);
|
2018-08-25 21:10:09 +00:00
|
|
|
|
2018-12-09 21:40:23 +00:00
|
|
|
liTag.setAttribute("name", name);
|
|
|
|
liTag.setAttribute("title", name);
|
2018-08-25 21:10:09 +00:00
|
|
|
liTag.setAttribute("onclick", "loadFave(this)");
|
|
|
|
liTag.appendChild(txtNode);
|
|
|
|
listView.appendChild(liTag);
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 18:51:20 +00:00
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const updateHTMLDirList = async (data) => {
|
|
|
|
let isInFaves = data.getElementsByTagName('IN_FAVE')[0].innerHTML;
|
|
|
|
let dirPath = data.getElementsByTagName('PATH_HEAD')[0].innerHTML;
|
2018-12-10 00:06:51 +00:00
|
|
|
let dirs = Array.prototype.slice.call(data.getElementsByTagName('DIR'), 0);
|
|
|
|
let videos = Array.prototype.slice.call(data.getElementsByTagName('VID_FILE'), 0);
|
|
|
|
let images = Array.prototype.slice.call(data.getElementsByTagName('IMG_FILE'), 0);
|
|
|
|
let files = Array.prototype.slice.call(data.getElementsByTagName('FILE'), 0);
|
2018-11-23 23:46:40 +00:00
|
|
|
let dirImg = "resources/images/icons/folder.png";
|
|
|
|
let i = 0;
|
|
|
|
let size = 0;
|
2018-04-22 06:03:43 +00:00
|
|
|
|
2018-12-10 00:06:51 +00:00
|
|
|
|
2018-04-22 08:56:25 +00:00
|
|
|
document.getElementById("path").innerHTML = dirPath;
|
2018-04-22 06:03:43 +00:00
|
|
|
insertArea.innerHTML = "";
|
|
|
|
|
2018-12-10 00:06:51 +00:00
|
|
|
// Setup background if there is a 000.* in selection
|
2018-12-10 00:11:28 +00:00
|
|
|
let bgImgPth = images[0] ? images[0].innerHTML : "";
|
2018-12-10 00:06:51 +00:00
|
|
|
if (bgImgPth.match(/000\.(jpg|png|gif)\b/) != null) {
|
|
|
|
updateBG(dirPath + bgImgPth);
|
|
|
|
} else {
|
|
|
|
updateBG("resources/images/backgrounds/000.jpg");
|
|
|
|
}
|
|
|
|
|
|
|
|
// determin whether to style faves or not
|
|
|
|
let elm = document.getElementById("faves");
|
2018-08-25 05:53:44 +00:00
|
|
|
if (isInFaves == "true") {
|
|
|
|
elm.style.backgroundColor = "rgb(255, 255, 255)";
|
|
|
|
elm.style.color = "rgb(0, 0, 0)";
|
|
|
|
} else {
|
|
|
|
elm.style.backgroundColor = "";
|
|
|
|
elm.style.color = "";
|
|
|
|
}
|
|
|
|
|
2018-12-10 00:06:51 +00:00
|
|
|
// Insert dirs
|
2018-04-22 08:14:40 +00:00
|
|
|
size = dirs.length;
|
2018-12-10 00:06:51 +00:00
|
|
|
|
|
|
|
sortElms(dirs);
|
2018-04-22 06:03:43 +00:00
|
|
|
for (; i < size; i++) {
|
2018-11-23 23:46:40 +00:00
|
|
|
let dir = dirs[i].innerHTML;
|
2018-04-22 06:03:43 +00:00
|
|
|
|
|
|
|
if (dir != "resources/") {
|
2018-05-03 08:14:28 +00:00
|
|
|
createElmBlock("DIV", "dirStyle", "dirID", "systemIcon", dirImg ,
|
|
|
|
"dirTitle", dir);
|
2018-04-22 06:03:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert videos
|
2018-12-10 00:06:51 +00:00
|
|
|
let thumbnail = "";
|
|
|
|
let vidNme = "";
|
|
|
|
size = videos.length;
|
2018-04-22 08:14:40 +00:00
|
|
|
|
2018-12-10 00:06:51 +00:00
|
|
|
sortVidElms(videos);
|
2018-04-22 06:03:43 +00:00
|
|
|
for (i = 0; i < size; i++) {
|
2018-12-10 00:06:51 +00:00
|
|
|
vidNme = videos[i].children[0].innerHTML;
|
|
|
|
thumbnail = videos[i].children[1].innerHTML;
|
|
|
|
|
2018-05-03 08:14:28 +00:00
|
|
|
createElmBlock("SPAN", "movieStyle", "movieID", "thumbnail", thumbnail,
|
|
|
|
"movieTitle", vidNme);
|
2018-04-22 06:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Insert images
|
2018-12-10 00:06:51 +00:00
|
|
|
thumbnail = "";
|
|
|
|
size = images.length;
|
2018-04-22 06:03:43 +00:00
|
|
|
|
2018-12-10 00:06:51 +00:00
|
|
|
// sortElms(images);
|
2018-04-22 06:03:43 +00:00
|
|
|
for (i = 0; i < size; i++) {
|
2018-12-10 00:06:51 +00:00
|
|
|
thumbnail = images[i].innerHTML;
|
2018-04-22 06:03:43 +00:00
|
|
|
|
2018-04-22 08:14:40 +00:00
|
|
|
if (thumbnail.match(/000\.(jpg|png|gif)\b/) == null &&
|
2018-05-03 08:14:28 +00:00
|
|
|
!thumbnail.includes("favicon.png")) {
|
2018-11-23 23:46:40 +00:00
|
|
|
let imgTag = document.createElement("IMG");
|
2018-05-03 08:14:28 +00:00
|
|
|
imgTag.id = "imageID";
|
|
|
|
imgTag.className = "iconImg";
|
2018-12-10 00:06:51 +00:00
|
|
|
imgTag.src = dirPath + thumbnail;
|
2018-05-03 08:14:28 +00:00
|
|
|
imgTag.alt = thumbnail;
|
|
|
|
insertArea.appendChild(imgTag);
|
2018-04-22 06:03:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert files
|
|
|
|
size = files.length;
|
2018-12-10 00:06:51 +00:00
|
|
|
|
|
|
|
sortElms(files);
|
2018-04-22 06:03:43 +00:00
|
|
|
for (i = 0; i < size; i++) {
|
2018-12-10 00:06:51 +00:00
|
|
|
let fileName = files[i].innerHTML;
|
2018-05-03 08:14:28 +00:00
|
|
|
createElmBlock("DIV", "fileStyle", "fileID", "systemIcon", setFileIconType(fileName),
|
|
|
|
"fileTitle", fileName);
|
2018-04-22 08:14:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-10 00:06:51 +00:00
|
|
|
const sortVidElms = (obj) => {
|
|
|
|
obj.sort(function(a,b) {
|
|
|
|
var n1 = a.children[0].innerHTML;
|
|
|
|
var n2 = b.children[0].innerHTML;
|
|
|
|
if (n1 > n2) return 1;
|
|
|
|
if (n1 < n2) return -1;
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const sortElms = (obj) => {
|
|
|
|
obj.sort(function(a,b) {
|
|
|
|
var n1 = a.innerHTML;
|
|
|
|
var n2 = b.innerHTML;
|
|
|
|
if (n1 > n2) return 1;
|
|
|
|
if (n1 < n2) return -1;
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const createElmBlock = (contnrType, contnrClass, imgID, imgClass,
|
|
|
|
imgSrc, inputClass, fileName) => {
|
|
|
|
let contnrTag = document.createElement(contnrType);
|
|
|
|
let imgTag = document.createElement("IMG");
|
|
|
|
let inputTag = document.createElement("INPUT");
|
2018-05-03 08:14:28 +00:00
|
|
|
|
|
|
|
contnrTag.className = contnrClass;
|
|
|
|
contnrTag.title = fileName;
|
2018-05-10 07:42:39 +00:00
|
|
|
contnrTag.tabIndex = "1";
|
2018-05-03 08:14:28 +00:00
|
|
|
imgTag.id = imgID;
|
|
|
|
imgTag.className = imgClass ;
|
|
|
|
imgTag.src = imgSrc;
|
|
|
|
imgTag.alt = fileName;
|
|
|
|
inputTag.type = "text";
|
|
|
|
inputTag.id = "titleID";
|
|
|
|
inputTag.className = inputClass;
|
|
|
|
inputTag.readOnly = "true";
|
|
|
|
inputTag.value = fileName;
|
|
|
|
inputTag.addEventListener("focusout", disableEdits);
|
|
|
|
|
|
|
|
contnrTag.appendChild(imgTag);
|
|
|
|
contnrTag.appendChild(inputTag);
|
|
|
|
insertArea.appendChild(contnrTag);
|
|
|
|
}
|
|
|
|
|
2018-11-23 23:46:40 +00:00
|
|
|
const setFileIconType = (fileName) => {
|
2018-04-22 08:14:40 +00:00
|
|
|
if (fileName.match(/\.(doc|docx|xls|xlsx|rtf)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/doc.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else if (fileName.match(/\.(7z|7zip|zip|tar.gz|tar.xz|gz|rar|jar)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/arc.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else if (fileName.match(/\.(pdf)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/pdf.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else if (fileName.match(/\.(html)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/html.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else if (fileName.match(/\.(txt|conf)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/text.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else if (fileName.match(/\.(iso|img)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/img.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else if (fileName.match(/\.(sh|batch|exe)\b/) != null) {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/scrip.png";
|
2018-04-22 08:14:40 +00:00
|
|
|
} else {
|
2018-05-03 08:14:28 +00:00
|
|
|
return "resources/images/icons/bin.png";
|
2018-04-22 06:03:43 +00:00
|
|
|
}
|
|
|
|
}
|