mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 12:33:09 +02:00
Salt
This commit is contained in:
parent
decb257136
commit
86e1b792c2
1 changed files with 9 additions and 1 deletions
|
@ -78,11 +78,16 @@
|
||||||
const raw = (localStorage.getItem('useRawScript') == 'true' && isDebug)
|
const raw = (localStorage.getItem('useRawScript') == 'true' && isDebug)
|
||||||
|| ENV != 'production';
|
|| ENV != 'production';
|
||||||
|
|
||||||
|
// Get salt query
|
||||||
|
const salt = localStorage.getItem('salt')
|
||||||
|
? '?salt=' + localStorage.getItem('salt')
|
||||||
|
: '';
|
||||||
|
|
||||||
// Load an app script
|
// Load an app script
|
||||||
// Note: 'async' make it possible to load the script asyncly.
|
// Note: 'async' make it possible to load the script asyncly.
|
||||||
// 'defer' make it possible to run the script when the dom loaded.
|
// 'defer' make it possible to run the script when the dom loaded.
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.setAttribute('src', `/assets/${app}.${ver}.${lang}.${raw ? 'raw' : 'min'}.js`);
|
script.setAttribute('src', `/assets/${app}.${ver}.${lang}.${raw ? 'raw' : 'min'}.js${salt}`);
|
||||||
script.setAttribute('async', 'true');
|
script.setAttribute('async', 'true');
|
||||||
script.setAttribute('defer', 'true');
|
script.setAttribute('defer', 'true');
|
||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
|
@ -118,6 +123,9 @@
|
||||||
function refresh() {
|
function refresh() {
|
||||||
localStorage.setItem('shouldFlush', 'false');
|
localStorage.setItem('shouldFlush', 'false');
|
||||||
|
|
||||||
|
// Random
|
||||||
|
localStorage.setItem('salt', Math.random().toString());
|
||||||
|
|
||||||
// Clear cache (serive worker)
|
// Clear cache (serive worker)
|
||||||
try {
|
try {
|
||||||
navigator.serviceWorker.controller.postMessage('clear');
|
navigator.serviceWorker.controller.postMessage('clear');
|
||||||
|
|
Loading…
Reference in a new issue