aboutsummaryrefslogtreecommitdiff
path: root/pointless/viewer/viewer.js
diff options
context:
space:
mode:
Diffstat (limited to 'pointless/viewer/viewer.js')
-rw-r--r--pointless/viewer/viewer.js65
1 files changed, 0 insertions, 65 deletions
diff --git a/pointless/viewer/viewer.js b/pointless/viewer/viewer.js
deleted file mode 100644
index a38e9d3..0000000
--- a/pointless/viewer/viewer.js
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * Pointless Viewer, a web-based Beamer presentation viewer
3 * Copyright (C) 2018 Pacien TRAN-GIRARD
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19"use strict";
20
21class Viewer {
22 constructor() {
23 this.fileInput = document.getElementById("fileInput");
24 this._listenForInput();
25 }
26
27 load(source) {
28 pdfjsLib.getDocument(source).then(function(pdf) {
29 const presentation = new Presentation(pdf);
30 }).catch(function(error) {
31 console.error(error);
32 window.alert("Error while loading presentation:\n\n" + error.message);
33 window.location.href = window.location.pathname; // reload without "?file=..."
34 });
35 }
36
37 _readFile(file) {
38 const fileReader = new FileReader();
39 const self = this;
40 fileReader.onload = function() {
41 const byteArray = new Uint8Array(this.result);
42 self.load(byteArray);
43 }
44
45 fileReader.readAsArrayBuffer(file);
46 }
47
48 _listenForInput() {
49 const self = this;
50 fileInput.addEventListener("change", function(event) {
51 self._readFile(event.target.files[0]);
52 });
53
54 document.body.addEventListener("drop", function(event) {
55 event.preventDefault();
56 event.stopPropagation();
57 self._readFile(event.dataTransfer.files[0]);
58 });
59
60 document.body.addEventListener("dragover", function(event) {
61 event.preventDefault();
62 event.stopPropagation();
63 });
64 }
65}