aboutsummaryrefslogtreecommitdiff
path: root/beamer/viewer
diff options
context:
space:
mode:
Diffstat (limited to 'beamer/viewer')
-rw-r--r--beamer/viewer/init.js18
-rw-r--r--beamer/viewer/viewer.js20
2 files changed, 19 insertions, 19 deletions
diff --git a/beamer/viewer/init.js b/beamer/viewer/init.js
index d634c94..a6ea7be 100644
--- a/beamer/viewer/init.js
+++ b/beamer/viewer/init.js
@@ -18,15 +18,6 @@
18 18
19"use strict"; 19"use strict";
20 20
21const params = function() {
22 const queryDict = {};
23 location.hash.substr(1).split("&").forEach(item => {
24 const pair = item.split("=");
25 queryDict[pair[0]] = pair[1];
26 });
27 return queryDict;
28}();
29
30function isController() { 21function isController() {
31 return window.opener == null || window.opener.location.href != window.location.href; 22 return window.opener == null || window.opener.location.href != window.location.href;
32} 23}
@@ -41,16 +32,7 @@ function initCache() {
41 32
42function init() { 33function init() {
43 initCache(); 34 initCache();
44
45 const viewer = new Viewer(); 35 const viewer = new Viewer();
46
47 if ("file" in params)
48 viewer.loadFromUrl(params["file"]);
49}
50
51function load(file) {
52 location.hash = "file=" + file;
53 location.reload();
54} 36}
55 37
56if (isController()) 38if (isController())
diff --git a/beamer/viewer/viewer.js b/beamer/viewer/viewer.js
index 21b369a..28c0187 100644
--- a/beamer/viewer/viewer.js
+++ b/beamer/viewer/viewer.js
@@ -66,7 +66,7 @@ class Viewer {
66 this.fileInput.files = dummy.files; 66 this.fileInput.files = dummy.files;
67 } 67 }
68 68
69 loadFromUrl(url) { 69 _loadFromUrl(url) {
70 this._setFileName(url); 70 this._setFileName(url);
71 this._setPresentation(url); 71 this._setPresentation(url);
72 } 72 }
@@ -94,5 +94,23 @@ class Viewer {
94 event.preventDefault(); 94 event.preventDefault();
95 event.stopPropagation(); 95 event.stopPropagation();
96 }); 96 });
97
98 window.addEventListener('load', () => this._on_hash_change());
99 window.addEventListener('hashchange', () => this._on_hash_change());
100 }
101
102 _on_hash_change() {
103 const params = this._hash_params();
104 if ("file" in params)
105 this._loadFromUrl(params["file"]);
106 }
107
108 _hash_params() {
109 const queryDict = {};
110 location.hash.substr(1).split("&").forEach(item => {
111 const pair = item.split("=");
112 queryDict[pair[0]] = pair[1];
113 });
114 return queryDict;
97 } 115 }
98} 116}