aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pointless/viewer/viewer.css10
-rw-r--r--pointless/viewer/viewer.js41
-rw-r--r--viewer.html3
3 files changed, 46 insertions, 8 deletions
diff --git a/pointless/viewer/viewer.css b/pointless/viewer/viewer.css
index 14db376..bea73e6 100644
--- a/pointless/viewer/viewer.css
+++ b/pointless/viewer/viewer.css
@@ -8,10 +8,15 @@
8body { 8body {
9 background-color: black; 9 background-color: black;
10 color: white; 10 color: white;
11 font-family: sans-serif;
11 overflow: hidden; 12 overflow: hidden;
12} 13}
13 14
14#screen { 15#fileInput {
16 display: none;
17}
18
19.centered {
15 position: absolute; 20 position: absolute;
16 top: 50%; 21 top: 50%;
17 left: 50%; 22 left: 50%;
@@ -19,14 +24,13 @@ body {
19} 24}
20 25
21.notification { 26.notification {
22 position: absolute; 27 position: absolute;
23 bottom: 0; 28 bottom: 0;
24 left: 50%; 29 left: 50%;
25 transform: translateX(-50%); 30 transform: translateX(-50%);
26 padding: 0.5rem 1rem; 31 padding: 0.5rem 1rem;
27 border-radius: 1rem 1rem 0 0; 32 border-radius: 1rem 1rem 0 0;
28 background-color: black; 33 background-color: black;
29 font-family: sans-serif;
30 font-size: 1.6rem; 34 font-size: 1.6rem;
31} 35}
32 36
diff --git a/pointless/viewer/viewer.js b/pointless/viewer/viewer.js
index 00c6f76..1c651fc 100644
--- a/pointless/viewer/viewer.js
+++ b/pointless/viewer/viewer.js
@@ -16,8 +16,41 @@ var params = function() {
16 return queryDict; 16 return queryDict;
17}(); 17}();
18 18
19if (window.opener == null) { 19function isController() {
20 pdfjsLib.getDocument(params["file"]).then(function(pdf) { 20 return window.opener == null || window.opener.location.href != window.location.href;
21 var presentation = new Presentation(pdf); 21}
22 }); 22
23class Viewer {
24 constructor() {
25 this.fileInput = document.getElementById("fileInput");
26 this.fileInput.style.display = "block";
27
28 var self = this;
29 fileInput.addEventListener("change", function(event) {
30 var callback = function(file) { self._load(file) };
31 self._readFile(event.target.files[0], callback);
32 });
33
34 if ("file" in params)
35 this._load(params["file"]);
36 }
37
38 _load(source) {
39 this.fileInput.style.display = "none";
40 pdfjsLib.getDocument(source).then(function(pdf) {
41 var presentation = new Presentation(pdf);
42 });
43 }
44
45 _readFile(file, callback) {
46 var fileReader = new FileReader();
47 fileReader.onload = function() {
48 var byteArray = new Uint8Array(this.result);
49 callback(byteArray);
50 }
51
52 fileReader.readAsArrayBuffer(file);
53 }
23} 54}
55
56if (isController()) new Viewer();
diff --git a/viewer.html b/viewer.html
index f4c6dde..943bbce 100644
--- a/viewer.html
+++ b/viewer.html
@@ -15,7 +15,8 @@
15 </head> 15 </head>
16 16
17 <body> 17 <body>
18 <canvas id="screen"></canvas> 18 <canvas id="screen" class="centered"></canvas>
19 <input id="fileInput" class="centered" type="file" multiple="false"/>
19 <div id="timer" class="notification"></div> 20 <div id="timer" class="notification"></div>
20 <div id="message" class="notification"></div> 21 <div id="message" class="notification"></div>
21 22