Skip to content

Commit

Permalink
sw 3
Browse files Browse the repository at this point in the history
  • Loading branch information
vvsviridov committed Apr 18, 2021
1 parent cd65847 commit e28986f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
30 changes: 14 additions & 16 deletions assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ function ID() {
}


async function pageInit() {
await initServiceWorker()

function pageInit() {
if (document.location.search !== '') {
container.classList.add('active')
back.className = 'fas fa-cloud-download-alt'
Expand All @@ -47,18 +45,6 @@ async function pageInit() {
}


async function initServiceWorker() {
if ('serviceWorker' in navigator) {
try {
const reg = await navigator.serviceWorker.register('/serviceworker.js')
console.log('Service worker register success')
} catch (e) {
console.error('Service worker register fail')
}
}
}


function uploadFile(file) {
const ref = storageRef.child(fileId)
const uploadTask = ref.put(file)
Expand Down Expand Up @@ -188,4 +174,16 @@ upload.addEventListener('dragover', (e) => {
})


pageInit()
window.addEventListener('load', async () => {
if ('serviceWorker' in navigator) {
try {
const reg = await navigator.serviceWorker.register('/serviceworker.js')
console.log('Service worker register success')
} catch (e) {
console.error('Service worker register fail')
}
}
pageInit()
})


4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./assets/style.css" />
<link rel="manifest" href="manifest.json">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="manifest" href="/manifest.json">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"display": "standalone",
"orientation": "portrait",
"scope": "/",
"start_url": ".",
"start_url": "/",
"icons": [
{
"src": "/assets/icon-192x192.png",
Expand Down
2 changes: 1 addition & 1 deletion serviceworker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const staticCacheName = 's-streamio-v1'
const staticCacheName = 's-streamio-v2'

const assetUrls = [
'index.html',
Expand Down

0 comments on commit e28986f

Please sign in to comment.