diff --git a/assets/public/css/styles.css b/assets/public/css/styles.css
index 2509f863..752ea608 100644
--- a/assets/public/css/styles.css
+++ b/assets/public/css/styles.css
@@ -578,6 +578,10 @@ header h1 {
margin: 0;
font-size: 2em;
}
+header a,
+header a:hover {
+ color: inherit;
+}
header p {
font-size: 1.5em;
}
diff --git a/assets/public/js/application.js b/assets/public/js/application.js
index 91c84449..b1d613cb 100644
--- a/assets/public/js/application.js
+++ b/assets/public/js/application.js
@@ -2,6 +2,13 @@
var selectedItems = [];
+Array.prototype.removeElement = function(element) {
+ var i = this.indexOf(element);
+ if (i != -1) {
+ this.splice(i, 1);
+ }
+}
+
document.addEventListener("DOMContentLoaded", function(event) {
var items = document.getElementsByClassName('item');
Array.from(items).forEach(link => {
@@ -12,10 +19,7 @@ document.addEventListener("DOMContentLoaded", function(event) {
selectedItems.push(url);
} else {
link.classList.remove('selected');
- var i = selectedItems.indexOf(url);
- if (i != -1) {
- selectedItems.splice(i, 1);
- }
+ selectedItems.removeElement(url);
}
var event = new CustomEvent('changed-selected');
@@ -24,49 +28,69 @@ document.addEventListener("DOMContentLoaded", function(event) {
});
});
- document.getElementById("back").addEventListener("click", backEvent);
+ document.getElementById("open").addEventListener("click", openEvent);
+ if (document.getElementById("back")) {
+ document.getElementById("back").addEventListener("click", backEvent)
+ };
document.getElementById("delete").addEventListener("click", deleteEvent);
document.getElementById("download").addEventListener("click", downloadEvent);
return false;
});
-var backEvent = function(event) {
- var items = document.getElementsByClassName('item');
- Array.from(items).forEach(link => {
- link.classList.remove('selected');
- });
- selectedItems = [];
+var openEvent = function(event) {
+ if (selectedItems.length) {
- var event = new CustomEvent('changed-selected');
- document.dispatchEvent(event);
- return false;
+
+ return false;
+ }
+
+ window.open(window.location + "?raw=true");
+ return false;
+}
+
+var backEvent = function(event) {
+ var items = document.getElementsByClassName('item');
+ Array.from(items).forEach(link => {
+ link.classList.remove('selected');
+ });
+ selectedItems = [];
+
+ var event = new CustomEvent('changed-selected');
+ document.dispatchEvent(event);
+ return false;
}
var deleteEvent = function(event) {
- Array.from(selectedItems).forEach(item => {
- var request = new XMLHttpRequest();
- request.open("DELETE", item);
- request.send();
- request.onreadystatechange = function() {
- if (request.readyState == 4) {
- if (request.status != 200) {
- alert("something wrong happened!");
- return false;
- }
+ Array.from(selectedItems).forEach(item => {
+ var request = new XMLHttpRequest();
+ request.open("DELETE", item);
+ request.send();
+ request.onreadystatechange = function() {
+ if (request.readyState == 4) {
+ if (request.status != 200) {
+ alert("something wrong happened!");
+ return false;
+ }
- alert(item + " deleted");
- // Add removing animation
- }
- }
- });
- return false;
+ selectedItems.removeElement(item);
+ alert(item + " deleted");
+ // Add removing animation
+ }
+ }
+ });
+ return false;
}
var downloadEvent = function(event) {
- Array.from(selectedItems).forEach(item => {
- window.open(item + "?download=true");
- });
- return false;
+ if (selectedItems.length) {
+ Array.from(selectedItems).forEach(item => {
+ window.open(item + "?download=true");
+ });
+ return false;
+ }
+
+ window.open(window.location + "?download=true");
+ return false;
}
document.addEventListener("changed-selected", function(event) {
diff --git a/assets/templates/actions.tmpl b/assets/templates/actions.tmpl
new file mode 100644
index 00000000..d675b047
--- /dev/null
+++ b/assets/templates/actions.tmpl
@@ -0,0 +1,8 @@
+{{ define "actions" }}
+
+
open_in_new
+
mode_edit
+
file_download
+
delete
+
+{{ end }}
diff --git a/assets/templates/base.tmpl b/assets/templates/base.tmpl
index 696ac5c8..2dba9bf6 100644
--- a/assets/templates/base.tmpl
+++ b/assets/templates/base.tmpl
@@ -13,31 +13,32 @@
+
+ {{ if .IsDir }}
+ {{ end }}
{{ template "content" .Data }}
diff --git a/assets/templates/listing.tmpl b/assets/templates/listing.tmpl
index 01b5a36a..fed14c65 100644
--- a/assets/templates/listing.tmpl
+++ b/assets/templates/listing.tmpl
@@ -24,64 +24,5 @@
{{- end}}
-
-
-
{{ end }}
diff --git a/assets/templates/single.tmpl b/assets/templates/single.tmpl
index 29493cb5..eb8bfe6b 100644
--- a/assets/templates/single.tmpl
+++ b/assets/templates/single.tmpl
@@ -3,9 +3,9 @@
{{ if eq .Type "image" }}
-
+
{{ else if eq .Type "audio" }}
-