aboutsummaryrefslogtreecommitdiff
path: root/pointless/viewer/stage.js
diff options
context:
space:
mode:
authorpacien2018-08-24 01:39:40 +0200
committerpacien2018-08-24 01:39:40 +0200
commit4ac79e422129e654e48909017a50b066b2f587d1 (patch)
tree0c42e814da49d82456505b3e1c49f82359d98016 /pointless/viewer/stage.js
parent3a53e581c4888ce0d8e7f62c6766eeafe1c0610f (diff)
downloadbeamer-viewer-4ac79e422129e654e48909017a50b066b2f587d1.tar.gz
Handle click and touch events
Diffstat (limited to 'pointless/viewer/stage.js')
-rw-r--r--pointless/viewer/stage.js85
1 files changed, 0 insertions, 85 deletions
diff --git a/pointless/viewer/stage.js b/pointless/viewer/stage.js
deleted file mode 100644
index 1772480..0000000
--- a/pointless/viewer/stage.js
+++ /dev/null
@@ -1,85 +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 Stage {
22 constructor(onReady, onNext, onPrevious) {
23 this.onNext = onNext;
24 this.onPrevious = onPrevious;
25 this.audienceScreen = null;
26 this.presenterScreen = null;
27
28 this.projector = window.open(window.location.href, "_blank", "toolbar=0,location=0,menubar=0");
29 if (this.projector == null)
30 alert("Please allow pop-ups, then refresh this page.");
31
32 const self = this;
33 this.projector.addEventListener("load", function() {
34 self.audienceScreen = new Screen(self.projector, false, false);
35 self.presenterScreen = new Screen(window, true, true);
36 self._watchDetach();
37 onReady();
38 });
39
40 this._registerEventHandler(window);
41 this._registerEventHandler(this.projector);
42 }
43
44 setPage(page) {
45 this.audienceScreen.setPage(page);
46 this.presenterScreen.setPage(page);
47 }
48
49 _registerEventHandler(window) {
50 const self = this;
51 window.addEventListener("keydown", function(event) {
52 self._onCommand(event);
53 })
54 }
55
56 _onCommand(keyboardEvent) {
57 switch (keyboardEvent.key) {
58 case "Enter":
59 case " ":
60 case "ArrowRight":
61 case "n":
62 return this.onNext();
63
64 case "ArrowLeft":
65 case "p":
66 return this.onPrevious();
67 }
68 }
69
70 _watchDetach() {
71 const self = this;
72 window.addEventListener("beforeunload", function() {
73 self._setMessage(self.projector, "Controller detached");
74 });
75
76 this.projector.addEventListener("beforeunload", function() {
77 self._setMessage(window, "Viewer detached");
78 });
79 }
80
81 _setMessage(window, message) {
82 const messageBar = window.document.getElementById("message");
83 messageBar.textContent = message;
84 }
85}