From 2f766bbfa6321de5eb9a0a4ce0e7f5df23962348 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 20 Jul 2018 22:22:30 +0200 Subject: Enforce constancy --- appcache.js | 6 +++--- pointless/viewer/init.js | 10 +++++----- pointless/viewer/presentation.js | 10 +++++----- pointless/viewer/stage.js | 8 ++++---- pointless/viewer/timer.js | 6 +++--- pointless/viewer/viewer.js | 10 +++++----- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/appcache.js b/appcache.js index ba356c2..09b588f 100644 --- a/appcache.js +++ b/appcache.js @@ -27,7 +27,7 @@ class AppCache { "pointless/viewer/timer.js" ]; - var appCache = this; + const appCache = this; self.addEventListener("install", function(event) { event.waitUntil(appCache._onInstall()); }); @@ -38,7 +38,7 @@ class AppCache { } _onInstall() { - var self = this; + const self = this; return caches.open(this.cacheName).then(function(cache) { return cache.addAll(self.filesToCache); }); @@ -58,4 +58,4 @@ class AppCache { } } -var appCache = new AppCache(); +const appCache = new AppCache(); diff --git a/pointless/viewer/init.js b/pointless/viewer/init.js index dddbf17..a9294ea 100644 --- a/pointless/viewer/init.js +++ b/pointless/viewer/init.js @@ -7,10 +7,10 @@ "use strict"; -var params = function() { - var queryDict = {}; +const params = function() { + const queryDict = {}; location.search.substr(1).split("&").forEach(function(item) { - var pair = item.split("="); + const pair = item.split("="); queryDict[pair[0]] = pair[1]; }); return queryDict; @@ -24,14 +24,14 @@ function initCache() { if (!navigator.serviceWorker) return; navigator.serviceWorker.register("appcache.js"); - var offlineCapableIndicator = document.getElementById("offlineCapable"); + const offlineCapableIndicator = document.getElementById("offlineCapable"); offlineCapableIndicator.style.visibility = "visible"; } function init() { initCache(); - var viewer = new Viewer(); + const viewer = new Viewer(); if ("file" in params) viewer.load(params["file"]); diff --git a/pointless/viewer/presentation.js b/pointless/viewer/presentation.js index 853d764..97a9244 100644 --- a/pointless/viewer/presentation.js +++ b/pointless/viewer/presentation.js @@ -15,10 +15,10 @@ class Presentation { } _setupStage() { - var self = this; - var onStageReadyCallback = function() { self._onStageReady(); }; - var onNextCallback = function() { self._onNext(); }; - var onPreviousCallback = function() { self._onPrevious(); }; + const self = this; + const onStageReadyCallback = function() { self._onStageReady(); }; + const onNextCallback = function() { self._onNext(); }; + const onPreviousCallback = function() { self._onPrevious(); }; return new Stage(onStageReadyCallback, onNextCallback, onPreviousCallback); } @@ -37,7 +37,7 @@ class Presentation { } _setPage(pageIndex) { - var self = this; + const self = this; this.currentPageIndex = pageIndex; this.pdf.getPage(this.currentPageIndex).then(function(page) { self.stage.setPage(page); diff --git a/pointless/viewer/stage.js b/pointless/viewer/stage.js index 117b0af..b641a9e 100644 --- a/pointless/viewer/stage.js +++ b/pointless/viewer/stage.js @@ -18,7 +18,7 @@ class Stage { if (this.projector == null) alert("Please allow pop-ups, then refresh this page."); - var self = this; + const self = this; this.projector.addEventListener("load", function() { self.audienceScreen = new Screen(self.projector, false, false); self.presenterScreen = new Screen(window, true, true); @@ -36,7 +36,7 @@ class Stage { } _registerEventHandler(window) { - var self = this; + const self = this; window.addEventListener("keydown", function(event) { self._onCommand(event); }) @@ -57,7 +57,7 @@ class Stage { } _watchDetach() { - var self = this; + const self = this; window.addEventListener("beforeunload", function() { self._setMessage(self.projector, "Controller detached"); }); @@ -68,7 +68,7 @@ class Stage { } _setMessage(window, message) { - var messageBar = window.document.getElementById("message"); + const messageBar = window.document.getElementById("message"); messageBar.textContent = message; } } diff --git a/pointless/viewer/timer.js b/pointless/viewer/timer.js index 4f19986..28c3f97 100644 --- a/pointless/viewer/timer.js +++ b/pointless/viewer/timer.js @@ -18,19 +18,19 @@ class Timer { if (this.startTime != null) return; this.startTime = Date.now(); - var self = this; + const self = this; setInterval(function() { self._runTimer(); }, 1000); } _runTimer() { - var timeDelta = Math.floor((Date.now() - this.startTime) / 1000); + const timeDelta = Math.floor((Date.now() - this.startTime) / 1000); this._setDisplay(timeDelta); } _setDisplay(seconds) { - var dateObj = new Date(null); + const dateObj = new Date(null); dateObj.setSeconds(seconds); this.display.textContent = dateObj.toISOString().substr(11, 8); } diff --git a/pointless/viewer/viewer.js b/pointless/viewer/viewer.js index 9e92c2c..75486a4 100644 --- a/pointless/viewer/viewer.js +++ b/pointless/viewer/viewer.js @@ -19,15 +19,15 @@ class Viewer { load(source) { this.welcomeScreen.style.display = "none"; pdfjsLib.getDocument(source).then(function(pdf) { - var presentation = new Presentation(pdf); + const presentation = new Presentation(pdf); }); } _readFile(file) { - var fileReader = new FileReader(); - var self = this; + const fileReader = new FileReader(); + const self = this; fileReader.onload = function() { - var byteArray = new Uint8Array(this.result); + const byteArray = new Uint8Array(this.result); self.load(byteArray); } @@ -35,7 +35,7 @@ class Viewer { } _listenForInput() { - var self = this; + const self = this; fileInput.addEventListener("change", function(event) { self._readFile(event.target.files[0]); }); -- cgit v1.2.3