From 15b2be158ac0147982dd30382251b3ce83e219c7 Mon Sep 17 00:00:00 2001
From: Roland Reichwein <mail@reichwein.it>
Date: Mon, 11 May 2020 19:46:30 +0200
Subject: Generate download link for files

---
 plugins/webbox/TODO            |  2 +-
 plugins/webbox/html/webbox.css |  2 ++
 plugins/webbox/html/webbox.js  | 26 +++++++++++++++++++++-----
 3 files changed, 24 insertions(+), 6 deletions(-)

(limited to 'plugins/webbox')

diff --git a/plugins/webbox/TODO b/plugins/webbox/TODO
index ffa32db..108b645 100644
--- a/plugins/webbox/TODO
+++ b/plugins/webbox/TODO
@@ -1,7 +1,7 @@
 Prio 1 (for next version)
 ======
 
-generate download link for selected file
+provide index for nested directories, also if requested via url
 gallery
 Info if not selected: all
 Copy function
diff --git a/plugins/webbox/html/webbox.css b/plugins/webbox/html/webbox.css
index 71e3673..6ea5147 100644
--- a/plugins/webbox/html/webbox.css
+++ b/plugins/webbox/html/webbox.css
@@ -248,10 +248,12 @@ table.list td.name {
 }
 
 /* Tooltip container */
+/*
 .tooltip {
 	position: relative;
 	display: inline-block;
 }
+*/
 
 /* Tooltip text */
 /*
diff --git a/plugins/webbox/html/webbox.js b/plugins/webbox/html/webbox.js
index c25b039..e056c16 100644
--- a/plugins/webbox/html/webbox.js
+++ b/plugins/webbox/html/webbox.js
@@ -41,25 +41,41 @@ function loadContents(dir) {
 		} else {
 			for (var i = 0; i < listElements.length; i++) {
 				var type = listElements[i].getAttribute("type");
+				var filename = listElements[i].textContent;
+				var mouse_click =
+					"onclick=\"entryMouse('" + filename + "')\"";
+				
+				var full_path = currentDir + "/" + filename;
+				if (full_path.substr(0, 2) == "//") {
+					full_path = full_path.substr(1);
+				}
+
+				// make relative path
+				while (full_path.substr(0, 1) == "/") {
+					full_path = full_path.substr(1);
+				}
+
+				var name_td;
 				if (type == "file") {
 					type = "<img src=\"webbox-html/file.png\"/>";
+					name_td = "<td><a href=\"" + full_path + "\"><div class=\"name\" style=\"height:100%;width:100%\">" + filename + "</div></a></td>";
 				} else if (type == "dir") {
 					type = "<img src=\"webbox-html/directory.png\"/>";
+					name_td = "<td class=\"name\" " + mouse_click + ">" + filename + "</td>";
 				} else {
 					type = "";
 				}
 
                                 var selector = "<td class=\"selector\"></td>";
-				if (listElements[i].textContent != "..") {
-					selector = "<td class=\"selector\" onclick=\"toggleSelection('" + listElements[i].textContent + "')\">&#9744;</td>";
+				if (filename != "..") {
+					selector = "<td class=\"selector\" onclick=\"toggleSelection('" + filename + "')\">&#9744;</td>";
 				}
 
-				var mouse_click =
-					"onclick=\"entryMouse('" + listElements[i].textContent + "')\"";
 				result += "<tr>" +
 					selector +
 					"<td class=\"type\" " + mouse_click + ">" + type + "</td>" +
-					"<td class=\"name\" " + mouse_click + ">" + listElements[i].textContent + "</td></tr>";
+					name_td +
+					"</tr>";
 			}
 		}
 
-- 
cgit v1.2.3