summaryrefslogtreecommitdiff
path: root/example/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'example/static/js')
-rw-r--r--example/static/js/media.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/example/static/js/media.js b/example/static/js/media.js
index e7ae59d..adcfab1 100644
--- a/example/static/js/media.js
+++ b/example/static/js/media.js
@@ -98,15 +98,19 @@ window.onpopstate = function(event) {
}
};
+function close_viewer() {
+ let slash = window.location.pathname.lastIndexOf('/')
+ let new_path = window.location.pathname.substring(0, slash + 1);
+ window.location.assign(window.location.protocol + "//" +
+ window.location.host + new_path);
+}
+
document.addEventListener('DOMContentLoaded', (event) => {
show_from_query_string();
document.getElementById('close').onclick =
function(event) {
- let slash = window.location.pathname.lastIndexOf('/')
- let new_path = window.location.pathname.substring(0, slash);
- window.location.assign(window.location.protocol + "//" +
- window.location.host + new_path);
+ close_viewer();
return false;
};
});
@@ -121,7 +125,7 @@ document.addEventListener('keydown', (event) => {
} else if (event.key == 'ArrowRight') {
document.getElementById('next').onclick();
} else if (event.key == 'Escape') {
- document.getElementById('close').onclick();
+ close_viewer();
} else if (event.key == 'D') {
document.getElementById('download').onclick();
}