diff --git a/ServiceWorker.js b/ServiceWorker.js index 2861966..31d7e79 100644 --- a/ServiceWorker.js +++ b/ServiceWorker.js @@ -1,42 +1,42 @@ var cacheName = 'tempConverterShell'; + var filesToCache = [ - '/', - '/index.html', - '/scripts/app.js', - '/styles/app.css' + './', + './index.html', + './sample.js', + './sample.css' ]; -//install イベントの時 作動 ↓ + self.addEventListener('install', function(event) { - console.log('ServiceWorker installing'); - event.waitUntil( + console.log('ServiceWorker installing'); + event.waitUntil( caches.open(cacheName).then(function(cache) { - console.log('Service Worker caching app shell'); - return cache.addAll(filesToCache); + console.log('Service Worker caching app shell'); + return cache.addAll(filesToCache); }) - ); + ); }); -//activate イベントの時 作動 ↓ + self.addEventListener('activate', function(event) { - console.log('Service Worker activating'); - event.waitUntil( + console.log('Service Worker activating'); + event.waitUntil( caches.keys().then(function(keyList) { - return Promise.all(keyList.map(function(key) { - if (key !== cacheName) { - console.log('Service Worker removing oldcache', key); - return caches.delete(key); - } - })); + return Promise.all(keyList.map(function(key) { + if (key !== cacheName) { + console.log('Service Worker removing old cache', key); + return caches.delete(key); + } + })); }) - ); - return self.clients.claim(); + ); + return self.clients.claim(); }); -//fetch イベントの時 作動 ↓ + self.addEventListener('fetch', function(event) { - console.log('Service Worker fetching ', - event.request.url); - event.respondWith( + console.log('Service Worker fetching ', event.request.url); + event.respondWith( caches.match(event.request).then(function(response) { - return response || fetch(event.request); + return response || fetch(event.request); }) - ); + ); }); \ No newline at end of file diff --git a/icon180x180.png b/icon180x180.png new file mode 100644 index 0000000..66b4eec --- /dev/null +++ b/icon180x180.png Binary files differ diff --git a/icon192x192.png b/icon192x192.png new file mode 100644 index 0000000..a483f0b --- /dev/null +++ b/icon192x192.png Binary files differ diff --git a/icon512x512.png b/icon512x512.png new file mode 100644 index 0000000..1b524ab --- /dev/null +++ b/icon512x512.png Binary files differ diff --git a/icon81x81.png b/icon81x81.png new file mode 100644 index 0000000..32b7770 --- /dev/null +++ b/icon81x81.png Binary files differ diff --git a/index.html b/index.html index 2c8fe15..17f287e 100644 --- a/index.html +++ b/index.html @@ -1,15 +1,29 @@ - - - - PWAテスト - - - - - - -

名前を書き込んでください

- - + + + + + PWAテスト + + + + + + + + +

名前を入力してください。

+ + + + + \ No newline at end of file diff --git a/manifset.json b/manifset.json new file mode 100644 index 0000000..aecd5c2 --- /dev/null +++ b/manifset.json @@ -0,0 +1,30 @@ +{ + "name": "PWA sample", + "short_name": "PWA", + "icons": [{ + "src": "./icon81x81.png", + "sizes": "81x81", + "type": "image/png" + }, + { + "src": "./icon180x180.png", + "sizes": "180x180", + "type": "image/png" + }, + { + "src": "./icon192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "./icon512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + + "theme_color": "#c0c0c0", + "background_color": "#dcdcdc", + "display": "standalone", + "start_url": "./index.html" + } \ No newline at end of file diff --git a/sample.css b/sample.css new file mode 100644 index 0000000..764c032 --- /dev/null +++ b/sample.css @@ -0,0 +1,3 @@ +body { + background-color: white; + } \ No newline at end of file diff --git a/sample.js b/sample.js index 0491b8d..ea5455e 100644 --- a/sample.js +++ b/sample.js @@ -1,5 +1,5 @@ function gettext() { var text = document.getElementById("name").value; var elem = document.getElementById("test"); - elem.innerHTML = text + "さん、こんにちわ"; -} + elem.innerHTML = text+"さん、こんにちは"; +} \ No newline at end of file