OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function initialize() { | 5 function initialize() { |
6 navigator.serviceWorker.register('service_worker.js'); | 6 navigator.serviceWorker.register('service_worker.js'); |
| 7 |
| 8 window.addEventListener('appinstalled', () => { |
| 9 window.document.title = 'Got appinstalled'; |
| 10 }); |
7 } | 11 } |
8 | 12 |
9 function addManifestLinkTag() { | 13 function addManifestLinkTag() { |
10 var url = window.location.href; | 14 var url = window.location.href; |
11 var manifestIndex = url.indexOf("?manifest="); | 15 var manifestIndex = url.indexOf("?manifest="); |
12 var manifestUrl = | 16 var manifestUrl = |
13 (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json'; | 17 (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json'; |
14 var linkTag = document.createElement("link"); | 18 var linkTag = document.createElement("link"); |
15 linkTag.rel = "manifest"; | 19 linkTag.rel = "manifest"; |
16 linkTag.href = manifestUrl; | 20 linkTag.href = manifestUrl; |
17 document.head.append(linkTag); | 21 document.head.append(linkTag); |
18 } | 22 } |
OLD | NEW |