Codacy JS style fixes
This commit is contained in:
parent
02068f1f4f
commit
aa0b45e563
|
@ -1,6 +1,7 @@
|
||||||
var GAME_LOADING_ERROR_MSG = 'Game loading failed, please retry later.';
|
var GAME_LOADING_ERROR_MSG = 'Game loading failed, please retry later.';
|
||||||
|
|
||||||
async function play(game){
|
async function play(game){
|
||||||
|
console.log("Opening game "+game+"...");
|
||||||
try {
|
try {
|
||||||
await import(`./games/${game}/game.js`)
|
await import(`./games/${game}/game.js`)
|
||||||
.then(({default: Game}) => {
|
.then(({default: Game}) => {
|
||||||
|
|
|
@ -34,10 +34,10 @@ toastr.options = {
|
||||||
$.fn.loading = function(action="start", options) {
|
$.fn.loading = function(action="start", options) {
|
||||||
var opts = $.extend( {}, $.fn.loading.defaults, options );
|
var opts = $.extend( {}, $.fn.loading.defaults, options );
|
||||||
|
|
||||||
if(action == "show") {
|
if(action === "show") {
|
||||||
this.addClass("loading_blur");
|
this.addClass("loading_blur");
|
||||||
$( "body" ).append( "<div id='loading_div' class='loading_overlay'><p class=''><b>"+opts.message+"</b></p></div>" );
|
$( "body" ).append( "<div id='loading_div' class='loading_overlay'><p class=''><b>"+opts.message+"</b></p></div>" );
|
||||||
} else if(action == "hide") {
|
} else if(action === "hide") {
|
||||||
this.removeClass("loading_blur");
|
this.removeClass("loading_blur");
|
||||||
this.addClass("loading_no_blur");
|
this.addClass("loading_no_blur");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -115,7 +115,7 @@ if (getCookie("authenticated")) {
|
||||||
installServiceWorker = false;
|
installServiceWorker = false;
|
||||||
}
|
}
|
||||||
if ('storage' in navigator && 'estimate' in navigator.storage && !getCookie("forceServiceWorkerInstallation")){
|
if ('storage' in navigator && 'estimate' in navigator.storage && !getCookie("forceServiceWorkerInstallation")){
|
||||||
navigator.storage.estimate().then(quota => {
|
navigator.storage.estimate().then((quota) => {
|
||||||
const requiredMemory = 3 * 1e+6;
|
const requiredMemory = 3 * 1e+6;
|
||||||
if (quota < requiredMemory) {
|
if (quota < requiredMemory) {
|
||||||
console.log("Skipping ServiceWorker installation because memory is low. memory="+quota);
|
console.log("Skipping ServiceWorker installation because memory is low. memory="+quota);
|
||||||
|
@ -129,9 +129,9 @@ if (getCookie("authenticated")) {
|
||||||
}
|
}
|
||||||
if(installServiceWorker){
|
if(installServiceWorker){
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
navigator.serviceWorker.register('sw.js').then(registration => {
|
navigator.serviceWorker.register('sw.js').then((registration) => {
|
||||||
console.log('SW registered: ', registration);
|
console.log('SW registered: ', registration);
|
||||||
}).catch(registrationError => {
|
}).catch((registrationError) => {
|
||||||
console.log('SW registration failed: ', registrationError);
|
console.log('SW registration failed: ', registrationError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -194,7 +194,7 @@ async function loadTable({table_page, set_interval=true, interval=10000, onlineR
|
||||||
}
|
}
|
||||||
}}).fail(function(data, status) {
|
}}).fail(function(data, status) {
|
||||||
if(status == "parsererror"){
|
if(status == "parsererror"){
|
||||||
if($("#table_body").children().length == 0) { //this is a server-side authentication error on some cheap hosting providers
|
if($("#table_body").children().length === 0) { //this is a server-side authentication error on some cheap hosting providers
|
||||||
loadTable(table_page, set_interval, interval); //retry
|
loadTable(table_page, set_interval, interval); //retry
|
||||||
} // else nothing
|
} // else nothing
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -70,16 +70,16 @@ self.addEventListener('fetch', function (event) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('install', event => {
|
self.addEventListener('install', (event) => {
|
||||||
self.skipWaiting();
|
self.skipWaiting();
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.open(cacheName).then(cache => {
|
caches.open(cacheName).then((cache) => {
|
||||||
cache.addAll(urls);
|
cache.addAll(urls);
|
||||||
fetch('resources/dist/manifest.json')
|
fetch('resources/dist/manifest.json')
|
||||||
.then(response => response.json())
|
.then((response) => response.json())
|
||||||
.then(manifest => {
|
.then((manifest) => {
|
||||||
let scripts_required = ["main.js", "maps.js"];
|
let scripts_required = ["main.js", "maps.js"];
|
||||||
scripts_required.map(script_name => {
|
scripts_required.map((script_name) => {
|
||||||
console.log(manifest);
|
console.log(manifest);
|
||||||
console.log(script_name);
|
console.log(script_name);
|
||||||
cache.add("resources/dist/"+manifest[script_name]);
|
cache.add("resources/dist/"+manifest[script_name]);
|
||||||
|
@ -89,10 +89,10 @@ self.addEventListener('install', event => {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
self.addEventListener('activate', event => {
|
self.addEventListener('activate', (event) => {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.keys().then(keys => Promise.all(
|
caches.keys().then((keys) => Promise.all(
|
||||||
keys.map(key => {
|
keys.map((key) => {
|
||||||
if (!expectedCaches.includes(key)) {
|
if (!expectedCaches.includes(key)) {
|
||||||
console.log("Deleting cache "+key);
|
console.log("Deleting cache "+key);
|
||||||
return caches.delete(key);
|
return caches.delete(key);
|
||||||
|
|
Loading…
Reference in New Issue