aboutsummaryrefslogtreecommitdiff
path: root/pointless/viewer/init.js
blob: a9294ea1ae6da71f90aac0f6b9c90c2a41030b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * init.js
 * Part of Pointless Viewer, a Beamer presentation viewer
 * Copyright 2018 Pacien TRAN-GIRARD
 * License: GNU GPL v3
 */

"use strict";

const params = function() {
  const queryDict = {};
  location.search.substr(1).split("&").forEach(function(item) {
    const pair = item.split("=");
    queryDict[pair[0]] = pair[1];
  });
  return queryDict;
}();

function isController() {
  return window.opener == null || window.opener.location.href != window.location.href;
}

function initCache() {
  if (!navigator.serviceWorker) return;
  navigator.serviceWorker.register("appcache.js");
  
  const offlineCapableIndicator = document.getElementById("offlineCapable");
  offlineCapableIndicator.style.visibility = "visible";
}

function init() {
  initCache();

  const viewer = new Viewer();

  if ("file" in params)
    viewer.load(params["file"]);
}

if (isController())
  init();