aboutsummaryrefslogtreecommitdiff
path: root/pointless/viewer/init.js
blob: dddbf17b5c8714d4a3320675ab8091c804c5ba35 (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";

var params = function() {
  var queryDict = {};
  location.search.substr(1).split("&").forEach(function(item) {
    var 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");
  
  var offlineCapableIndicator = document.getElementById("offlineCapable");
  offlineCapableIndicator.style.visibility = "visible";
}

function init() {
  initCache();

  var viewer = new Viewer();

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

if (isController())
  init();