Added download functionality

This commit is contained in:
Maxim Stewart 2018-10-19 13:28:30 -05:00
parent fc03202bf3
commit d101b97dd3
4 changed files with 44 additions and 20 deletions

View File

@ -15,6 +15,7 @@
<menu type="context" id="menu">
<menuitem label="Home Directory" onclick="clearDirCookie()"></menuitem>
<menuitem label="Show Server Messages" onclick="tgglElmView('serverMsgView')"></menuitem>
<menuitem label="Download" onclick="downloadItem()"></menuitem>
<menuitem label="Clear Upload List" onclick="clearDlList()"></menuitem>
<menuitem label="Delete File/Directory" onclick="deleteItem()"></menuitem>
</menu>

View File

@ -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

View File

@ -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; }

View File

@ -1,4 +1,25 @@
// 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 callingID = obj.id;
@ -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;