diff options
author | pacien | 2018-08-24 01:39:40 +0200 |
---|---|---|
committer | pacien | 2018-08-24 01:39:40 +0200 |
commit | 4ac79e422129e654e48909017a50b066b2f587d1 (patch) | |
tree | 0c42e814da49d82456505b3e1c49f82359d98016 /pointless/viewer/timer.js | |
parent | 3a53e581c4888ce0d8e7f62c6766eeafe1c0610f (diff) | |
download | beamer-viewer-4ac79e422129e654e48909017a50b066b2f587d1.tar.gz |
Handle click and touch events
Diffstat (limited to 'pointless/viewer/timer.js')
-rw-r--r-- | pointless/viewer/timer.js | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/pointless/viewer/timer.js b/pointless/viewer/timer.js deleted file mode 100644 index 21cd8b8..0000000 --- a/pointless/viewer/timer.js +++ /dev/null | |||
@@ -1,48 +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 Timer { | ||
22 | constructor(window) { | ||
23 | this.display = window.document.getElementById("timer"); | ||
24 | this.startTime = null; | ||
25 | this._setDisplay(0); | ||
26 | } | ||
27 | |||
28 | start() { | ||
29 | if (this.startTime != null) return; | ||
30 | this.startTime = Date.now(); | ||
31 | |||
32 | const self = this; | ||
33 | setInterval(function() { | ||
34 | self._runTimer(); | ||
35 | }, 1000); | ||
36 | } | ||
37 | |||
38 | _runTimer() { | ||
39 | const timeDelta = Math.floor((Date.now() - this.startTime) / 1000); | ||
40 | this._setDisplay(timeDelta); | ||
41 | } | ||
42 | |||
43 | _setDisplay(seconds) { | ||
44 | const dateObj = new Date(null); | ||
45 | dateObj.setSeconds(seconds); | ||
46 | this.display.textContent = dateObj.toISOString().substr(11, 8); | ||
47 | } | ||
48 | } | ||