From d101b97dd3c895e02f2a287e7b14aaa3997a353b Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Fri, 19 Oct 2018 13:28:30 -0500 Subject: [PATCH] Added download functionality --- index.html | 1 + resources/js/filesystemActions.js | 6 ----- resources/js/uiActions.js | 15 +++++++++++ resources/js/uiEvents.js | 42 ++++++++++++++++++++----------- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index fe18942..96c10b4 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,7 @@ + diff --git a/resources/js/filesystemActions.js b/resources/js/filesystemActions.js index 738ef03..935e73f 100644 --- a/resources/js/filesystemActions.js +++ b/resources/js/filesystemActions.js @@ -1,4 +1,3 @@ -var itemObj = undefined; var binary = null; var pathNodes = []; @@ -87,11 +86,6 @@ function createItem(type) { "createItem=true&item=" + fullPth + "&type=" + type); } -function startDeleteItem(item) { - // Get the item name - itemObj = item; -} - function deleteItem() { var path = document.getElementById("path").innerHTML; // Clicked yes to delete and there is an item diff --git a/resources/js/uiActions.js b/resources/js/uiActions.js index c39e8fb..d1361aa 100644 --- a/resources/js/uiActions.js +++ b/resources/js/uiActions.js @@ -79,6 +79,21 @@ function clearDirCookie() { getDir("/"); } +function downloadItem() { + var partialPath = document.getElementById("path").innerHTML; + var aTag = document.createElement("A"); + var text = document.createTextNode(itemObj); + var fullPath = partialPath + itemObj; + aTag.setAttribute("href", fullPath); + aTag.setAttribute("target", "_blank"); + aTag.setAttribute("id", itemObj); + aTag.append(text); + + console.log(aTag); + document.getElementById("serverMsgView").append(aTag); + document.getElementById(itemObj).click(); +} + function clearDlList() { document.getElementById("CLEARBTTN").click(); } function onloadSetBG() { updateBG("resources/images/backgrounds/000.jpg"); } function updateBG(bgImg) { document.getElementById("bg").src = bgImg; } diff --git a/resources/js/uiEvents.js b/resources/js/uiEvents.js index 3e6dbcb..3cae3bc 100644 --- a/resources/js/uiEvents.js +++ b/resources/js/uiEvents.js @@ -1,6 +1,27 @@ -// ondblclick +var itemObj = undefined; + +document.onclick = function (event) { + var obj = event.target; + var callingID = obj.id; + var classNM = obj.className; + + // right-click detect + if (event.which == 3) { + if (callingID == "imageID") { + setSelectedItem(obj.alt); + } else if (callingID == "dirID" || callingID == "fileID" || + callingID == "movieID") { + var node = obj.parentNode; + setSelectedItem(node.children[1].value); + } else if (classNM == "fileStyle" || classNM == "dirStyle" || + classNM == "movieStyle") { + setSelectedItem(obj.children[1].value); + } + } +} + document.ondblclick = function (event) { - var obj = event.target; + var obj = event.target; var callingID = obj.id; var classNM = obj.className; @@ -33,18 +54,6 @@ document.ondblclick = function (event) { } else if (callingID == "titleID") { enableEdit(obj); } - // Right click detect - } else if (event.which == 3) { - if (callingID == "imageID") { - startDeleteItem(obj.alt); - } else if (callingID == "dirID" || callingID == "fileID" || - callingID == "movieID") { - var node = obj.parentNode; - startDeleteItem(node.children[1].value); - } else if (classNM == "fileStyle" || classNM == "dirStyle" || - classNM == "movieStyle") { - startDeleteItem(obj.children[1].value); - } } } @@ -62,6 +71,11 @@ document.onkeydown = function (event) { } } +function setSelectedItem(item) { + // Get the item name + itemObj = item; +} + // Drage event for the poped out image and media container function dragContainer(elmnt) { var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;