-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
111 lines (85 loc) · 4.16 KB
/
index.html
1
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="description" content="smartMailOne offline analytics with service workers - test 1."> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Service Worker Test1: Read-through Caching (w/Offline Analytics)</title> <!-- Add to homescreen for Chrome on Android --> <meta name="mobile-web-app-capable" content="yes"> <!-- Add to homescreen for Safari on iOS --> <meta name="apple-mobile-web-app-title" content="Service Worker Sample: Read-through Caching (w/Offline Analytics)"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <script> // Service workers require HTTPS (http://goo.gl/lq4gCo). If we're running on a real web server // (as opposed to localhost on a custom port, which is whitelisted), then change the protocol to HTTPS. if ((!location.port || location.port == "80") && location.protocol != 'https:') { location.protocol = 'https:'; } </script> </head> <body> <h1>Service Worker Test1: Read-through Caching (w/Offline Analytics)</h1> <div class="output"> <div id="status"></div> </div> <script> function showImages() { document.querySelector('#images').style.display = 'block'; } if ('serviceWorker' in navigator) { navigator.serviceWorker.register('./sw.js', {scope: './'}).then(function() { // Registration was successful. Now, check to see whether the service worker is controlling the page. if (navigator.serviceWorker.controller) { // If .controller is set, then this page is being actively controlled by the service worker. document.querySelector('#status').textContent = 'The service worker is currently handling network operations. ' + 'If you reload the page, the images (and everything else) will be served from the service worker\'s cache.'; showImages(); } else { // If .controller isn't set, then prompt the user to reload the page so that the service worker can take // control. Until that happens, the service worker's fetch handler won't be used. document.querySelector('#status').textContent = 'Please reload this page to allow the service worker to handle network operations.'; } }).catch(function(error) { // Something went wrong during registration. The service-worker.js file // might be unavailable or contain a syntax error. document.querySelector('#status').textContent = error; }); } else { // The current browser doesn't support service workers. var aElement = document.createElement('a'); aElement.href = 'http://www.chromium.org/blink/serviceworker/service-worker-faq'; aElement.textContent = 'Service workers are not supported in the current browser.'; document.querySelector('#status').appendChild(aElement); } </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-70931661-1', 'auto'); ga('send', 'pageview', {'sessionControl': 'start'});</script><script> !function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push( arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0]; d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode. insertBefore(d,q)}(window,document,'script','_gs'); _gs('GSN-909817-Q'); _gs('identify', { // TODO User ID id: 123, // TODO User's full name name: 'Sergio Renzo', // TODO User's email address email: 'sergio.renzo@gmail.com', // TODO User's # date created_at: '2015-12-02 18:30:00' }); </script> <!-- Built with love using Web Starter Kit --> </body></html>