diff options
Diffstat (limited to 'pointless/viewer/stage/stage.js')
-rw-r--r-- | pointless/viewer/stage/stage.js | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/pointless/viewer/stage/stage.js b/pointless/viewer/stage/stage.js deleted file mode 100644 index e9a2d38..0000000 --- a/pointless/viewer/stage/stage.js +++ /dev/null | |||
@@ -1,76 +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 | |||
21 | class Stage { | ||
22 | constructor(onReady, onNext, onPrevious) { | ||
23 | this.audienceScreen = null; | ||
24 | this.presenterScreen = null; | ||
25 | |||
26 | this.projector = window.open(window.location.href, "_blank", "toolbar=0,location=0,menubar=0"); | ||
27 | if (this.projector == null) | ||
28 | alert("Please allow pop-ups, then refresh this page."); | ||
29 | |||
30 | const self = this; | ||
31 | this.projector.addEventListener("load", function() { | ||
32 | self.audienceScreen = new Screen(self.projector, false, false); | ||
33 | self.presenterScreen = new Screen(window, true, true); | ||
34 | self._watchDetach(); | ||
35 | onReady(); | ||
36 | }); | ||
37 | |||
38 | this.eventHandlers = [ | ||
39 | new KeyboardEventHandler(onNext, onPrevious), | ||
40 | new MouseClickEventHandler(onNext, onPrevious), | ||
41 | new TouchSwipeEventHandler(onNext, onPrevious) | ||
42 | ]; | ||
43 | |||
44 | this._registerEventHandler(window); | ||
45 | this._registerEventHandler(this.projector); | ||
46 | } | ||
47 | |||
48 | setPage(page) { | ||
49 | this.audienceScreen.setPage(page); | ||
50 | this.presenterScreen.setPage(page); | ||
51 | } | ||
52 | |||
53 | _registerEventHandler(window) { | ||
54 | if (window == null) return; | ||
55 | |||
56 | this.eventHandlers.forEach(function(eventHandler) { | ||
57 | eventHandler.register(window); | ||
58 | }); | ||
59 | } | ||
60 | |||
61 | _watchDetach() { | ||
62 | const self = this; | ||
63 | window.addEventListener("beforeunload", function() { | ||
64 | self._setMessage(self.projector, "Controller detached"); | ||
65 | }); | ||
66 | |||
67 | this.projector.addEventListener("beforeunload", function() { | ||
68 | self._setMessage(window, "Viewer detached"); | ||
69 | }); | ||
70 | } | ||
71 | |||
72 | _setMessage(window, message) { | ||
73 | const messageBar = window.document.getElementById("message"); | ||
74 | messageBar.textContent = message; | ||
75 | } | ||
76 | } | ||