Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
P
PWATraining
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
training
PWATraining
Commits
c6515491
Commit
c6515491
authored
Jul 27, 2020
by
mohdrafhanmohdamin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "not ok"
This reverts commit
57a16f9b
.
parent
cbe8b09c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
1 deletion
+152
-1
sw.js
src/js/sw.js
+76
-1
sw.js
src/sw.js
+76
-0
No files found.
src/js/sw.js
View file @
c6515491
\ No newline at end of file
importScripts
(
'https://storage.googleapis.com/workbox-cdn/releases/5.1.3/workbox-sw.js'
);
if
(
workbox
)
{
console
.
log
(
`Yay! Workbox is loaded 🎉`
);
workbox
.
precaching
.
precacheAndRoute
(
self
.
__WB_MANIFEST
);
workbox
.
googleAnalytics
.
initialize
();
}
else
{
console
.
log
(
`Boo! Workbox didn't load 😬`
);
}
self
.
addEventListener
(
'install'
,
function
(
e
)
{
self
.
skipWaiting
();
});
self
.
addEventListener
(
'activate'
,
function
(
e
)
{
return
self
.
clients
.
claim
();
});
self
.
addEventListener
(
'push'
,
function
(
e
)
{
const
data
=
e
.
data
.
json
();
var
options
;
if
(
data
.
url
)
{
options
=
{
body
:
data
.
body
,
badge
:
"./images/badges/notification_192.png"
,
icon
:
"./images/icons/icon-192x192.png"
,
vibrate
:
[
100
,
50
,
100
],
data
:
{
url
:
data
.
url
},
actions
:
[
{
action
:
'web-action'
,
title
:
'Open web'
}
]
}
}
else
{
options
=
{
body
:
data
.
body
,
badge
:
"./images/badges/notification_192.png"
,
icon
:
"./images/icons/icon-192x192.png"
,
vibrate
:
[
100
,
50
,
100
]
}
}
self
.
registration
.
showNotification
(
data
.
title
,
options
);
});
self
.
addEventListener
(
'pushsubscriptionchange'
,
function
(
e
)
{
console
.
info
(
'Subscription expired'
);
});
self
.
addEventListener
(
'notificationclick'
,
function
(
e
)
{
if
(
!
e
.
action
)
{
// Was a normal notification click
console
.
info
(
'Notification Click.'
);
return
;
}
switch
(
e
.
action
)
{
case
'web-action'
:
e
.
notification
.
close
();
e
.
waitUntil
(
clients
.
openWindow
(
e
.
notification
.
data
.
url
)
);
break
;
}
});
src/sw.js
0 → 100644
View file @
c6515491
importScripts
(
'https://storage.googleapis.com/workbox-cdn/releases/5.1.3/workbox-sw.js'
);
if
(
workbox
)
{
console
.
log
(
`Yay! Workbox is loaded 🎉`
);
workbox
.
precaching
.
precacheAndRoute
([{
"revision"
:
"b1c77f9c5225951a9c6bd70d4188fa6a"
,
"url"
:
"index.html"
},{
"revision"
:
"6f38b559ee2733468231d0e3589a46f2"
,
"url"
:
"favicon.ico"
},{
"revision"
:
"fa694d319ff249bbafc9b0ebeb5bdd8a"
,
"url"
:
"css/app.css"
},{
"revision"
:
"0d606a447f16af75e775b64b27f3c442"
,
"url"
:
"js/app.js"
},{
"revision"
:
"ae75e72cfa193100f2baba436c50616b"
,
"url"
:
"js/menu.js"
},{
"revision"
:
"07eab90e6269c3f19ddc34ddfb890adf"
,
"url"
:
"js/share.js"
},{
"revision"
:
"fc8aef5e3399c8fb6efea89b54459f11"
,
"url"
:
"js/swipe.js"
},{
"revision"
:
"609e8f6ce7aa15cd2e5effde31057a80"
,
"url"
:
"js/toast.js"
},{
"revision"
:
"9cff0b914c679f32a3c1e4162f80522a"
,
"url"
:
"images/badges/notification_192.png"
},{
"revision"
:
"784b1c63c7be412d166db4a3d49f2501"
,
"url"
:
"images/icons/icon-128x128.png"
},{
"revision"
:
"adb787791bb14d1a5a076321c886b171"
,
"url"
:
"images/icons/icon-144x144.png"
},{
"revision"
:
"e25a0afa07977ad1039a46b9ab82daee"
,
"url"
:
"images/icons/icon-152x152.png"
},{
"revision"
:
"86e1f0fae80ecb97faad31f57d88aaec"
,
"url"
:
"images/icons/icon-192x192.png"
},{
"revision"
:
"72c220ac025d55ff95abe164ffb31db4"
,
"url"
:
"images/icons/icon-384x384.png"
},{
"revision"
:
"720fb062cb6d0f37070a9d877967a894"
,
"url"
:
"images/icons/icon-512x512.png"
},{
"revision"
:
"c03ad90690383f8dc249bb6c7a407aab"
,
"url"
:
"images/icons/icon-72x72.png"
},{
"revision"
:
"2ee2cc270deb2d95e2c8773398eff1fe"
,
"url"
:
"images/icons/icon-96x96.png"
},{
"revision"
:
"1b9053762212073bbade3145680cbf41"
,
"url"
:
"images/logoUiTM.svg"
}]);
workbox
.
googleAnalytics
.
initialize
();
}
else
{
console
.
log
(
`Boo! Workbox didn't load 😬`
);
}
self
.
addEventListener
(
'install'
,
function
(
e
)
{
self
.
skipWaiting
();
});
self
.
addEventListener
(
'activate'
,
function
(
e
)
{
return
self
.
clients
.
claim
();
});
self
.
addEventListener
(
'push'
,
function
(
e
)
{
const
data
=
e
.
data
.
json
();
var
options
;
if
(
data
.
url
)
{
options
=
{
body
:
data
.
body
,
badge
:
"./images/badges/notification_192.png"
,
icon
:
"./images/icons/icon-192x192.png"
,
vibrate
:
[
100
,
50
,
100
],
data
:
{
url
:
data
.
url
},
actions
:
[
{
action
:
'web-action'
,
title
:
'Open web'
}
]
}
}
else
{
options
=
{
body
:
data
.
body
,
badge
:
"./images/badges/notification_192.png"
,
icon
:
"./images/icons/icon-192x192.png"
,
vibrate
:
[
100
,
50
,
100
]
}
}
self
.
registration
.
showNotification
(
data
.
title
,
options
);
});
self
.
addEventListener
(
'pushsubscriptionchange'
,
function
(
e
)
{
console
.
info
(
'Subscription expired'
);
});
self
.
addEventListener
(
'notificationclick'
,
function
(
e
)
{
if
(
!
e
.
action
)
{
// Was a normal notification click
console
.
info
(
'Notification Click.'
);
return
;
}
switch
(
e
.
action
)
{
case
'web-action'
:
e
.
notification
.
close
();
e
.
waitUntil
(
clients
.
openWindow
(
e
.
notification
.
data
.
url
)
);
break
;
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment