parent
7ca18bbe67
commit
dd3e29fcb9
10 changed files with 139 additions and 51 deletions
@ -0,0 +1,6 @@ |
||||
RewriteEngine On |
||||
RewriteBase / |
||||
RewriteRule ^index\.html$ - [L] |
||||
RewriteCond %{REQUEST_FILENAME} !-f |
||||
RewriteCond %{REQUEST_FILENAME} !-d |
||||
RewriteRule . /index.html [L] |
@ -0,0 +1,45 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
<title>دعوت</title> |
||||
<style type="text/css"> |
||||
body { |
||||
height: 100%; |
||||
margin: 0px; |
||||
background-color: aquamarine; |
||||
display: flex; |
||||
align-items: center; |
||||
text-align: center; |
||||
justify-content: center; |
||||
} |
||||
|
||||
.city { |
||||
align-items: center; |
||||
width: 80%; |
||||
display: flex; |
||||
justify-content: center; |
||||
flex-direction: column; |
||||
padding: 40px 8%; |
||||
border-radius: 20px; |
||||
background-color: #fff; |
||||
} |
||||
|
||||
.city-name { |
||||
font-size: 2em; |
||||
} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<div class="city"> |
||||
<h2 class="city-name"> |
||||
<span>لطفا اتصال به شبکه را چک کنید.</span> |
||||
</h2> |
||||
</div> |
||||
</body> |
||||
|
||||
</html> |
@ -0,0 +1,42 @@ |
||||
const CACHE_NAME = "version-1"; |
||||
const urlsToCache = ['index.html', 'offline.html']; |
||||
|
||||
const self = this; |
||||
|
||||
//Install SW
|
||||
self.addEventListener('install', (event) => { |
||||
event.waitUntil( |
||||
caches.open(CACHE_NAME) |
||||
.then((cache) => { |
||||
console.log('Opened cache'); |
||||
|
||||
return cache.addAll(urlsToCache); |
||||
}) |
||||
) |
||||
}); |
||||
|
||||
//Listen for requests
|
||||
self.addEventListener('fetch', (event) => { |
||||
event.respondWith( |
||||
caches.match(event.request) |
||||
.then(() => { |
||||
return fetch(event.request) |
||||
.catch(() => caches.match('offline.html')); |
||||
}) |
||||
); |
||||
}); |
||||
//Activate the SW
|
||||
self.addEventListener('activate', (event) => { |
||||
const cacheWhiteList = []; |
||||
cacheWhiteList.push(CACHE_NAME); |
||||
|
||||
event.waitUntil( |
||||
caches.keys().then((cacheNames) => Promise.all( |
||||
cacheNames.map((cacheName) => { |
||||
if (!cacheWhiteList.includes(cacheName)) { |
||||
return caches.delete(cacheName); |
||||
} |
||||
}) |
||||
)) |
||||
) |
||||
}); |
Loading…
Reference in new issue