aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2023-10-23 21:58:06 +0200
committerpacien2023-10-23 21:58:06 +0200
commit3af33091d66197d2b14ab0ed7962d79b3a17d6e1 (patch)
treec3f12d599c72f05415db9522c6126ec7bf81292d
parent7249325100ce5d373d7da8b3e14ea8283a56eef9 (diff)
downloadbeamer-viewer-3af33091d66197d2b14ab0ed7962d79b3a17d6e1.tar.gz
presentation,stage: split object init and start
-rw-r--r--beamer/viewer/presentation.js4
-rw-r--r--beamer/viewer/stage/stage.js17
-rw-r--r--beamer/viewer/viewer.js1
3 files changed, 15 insertions, 7 deletions
diff --git a/beamer/viewer/presentation.js b/beamer/viewer/presentation.js
index 222a6d4..8934dda 100644
--- a/beamer/viewer/presentation.js
+++ b/beamer/viewer/presentation.js
@@ -25,6 +25,10 @@ class Presentation {
25 this.stage = this._setupStage(); 25 this.stage = this._setupStage();
26 } 26 }
27 27
28 start() {
29 this.stage.start();
30 }
31
28 _setupStage() { 32 _setupStage() {
29 const self = this; 33 const self = this;
30 const onStageReadyCallback = function() { self._onStageReady(); }; 34 const onStageReadyCallback = function() { self._onStageReady(); };
diff --git a/beamer/viewer/stage/stage.js b/beamer/viewer/stage/stage.js
index 201f7b4..cb94231 100644
--- a/beamer/viewer/stage/stage.js
+++ b/beamer/viewer/stage/stage.js
@@ -23,6 +23,15 @@ class Stage {
23 this.audienceScreen = null; 23 this.audienceScreen = null;
24 this.presenterScreen = null; 24 this.presenterScreen = null;
25 25
26 this.onReady = onReady;
27 this.eventHandlers = [
28 new KeyboardEventHandler(onNext, onPrevious),
29 new MouseClickEventHandler(onNext, onPrevious),
30 new TouchSwipeEventHandler(onNext, onPrevious)
31 ];
32 }
33
34 start() {
26 this.projector = window.open(window.location.href, "_blank", "toolbar=0,location=0,menubar=0"); 35 this.projector = window.open(window.location.href, "_blank", "toolbar=0,location=0,menubar=0");
27 if (this.projector == null) 36 if (this.projector == null)
28 alert("Please allow pop-ups, then refresh this page."); 37 alert("Please allow pop-ups, then refresh this page.");
@@ -32,15 +41,9 @@ class Stage {
32 self.audienceScreen = new Screen(self.projector, false, false); 41 self.audienceScreen = new Screen(self.projector, false, false);
33 self.presenterScreen = new Screen(window, true, true); 42 self.presenterScreen = new Screen(window, true, true);
34 self._watchDetach(); 43 self._watchDetach();
35 onReady(); 44 self.onReady();
36 }); 45 });
37 46
38 this.eventHandlers = [
39 new KeyboardEventHandler(onNext, onPrevious),
40 new MouseClickEventHandler(onNext, onPrevious),
41 new TouchSwipeEventHandler(onNext, onPrevious)
42 ];
43
44 this._registerEventHandler(window); 47 this._registerEventHandler(window);
45 this._registerEventHandler(this.projector); 48 this._registerEventHandler(this.projector);
46 } 49 }
diff --git a/beamer/viewer/viewer.js b/beamer/viewer/viewer.js
index 065298a..ee79d47 100644
--- a/beamer/viewer/viewer.js
+++ b/beamer/viewer/viewer.js
@@ -29,6 +29,7 @@ class Viewer {
29 load(source) { 29 load(source) {
30 pdfjsLib.getDocument(source).then(function(pdf) { 30 pdfjsLib.getDocument(source).then(function(pdf) {
31 const presentation = new Presentation(pdf); 31 const presentation = new Presentation(pdf);
32 presentation.start();
32 }).catch(function(error) { 33 }).catch(function(error) {
33 console.error(error); 34 console.error(error);
34 window.alert("Error while loading presentation:\n\n" + error.message); 35 window.alert("Error while loading presentation:\n\n" + error.message);