Codacy JS style fixes

This commit is contained in:
Matteo Gheza 2021-04-05 14:52:03 +02:00
parent 02068f1f4f
commit aa0b45e563
3 changed files with 15 additions and 14 deletions

View File

@ -1,6 +1,7 @@
var GAME_LOADING_ERROR_MSG = 'Game loading failed, please retry later.';
async function play(game){
console.log("Opening game "+game+"...");
try {
await import(`./games/${game}/game.js`)
.then(({default: Game}) => {

View File

@ -34,10 +34,10 @@ toastr.options = {
$.fn.loading = function(action="start", options) {
var opts = $.extend( {}, $.fn.loading.defaults, options );
if(action == "show") {
if(action === "show") {
this.addClass("loading_blur");
$( "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.addClass("loading_no_blur");
setTimeout(() => {
@ -115,7 +115,7 @@ if (getCookie("authenticated")) {
installServiceWorker = false;
}
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;
if (quota < requiredMemory) {
console.log("Skipping ServiceWorker installation because memory is low. memory="+quota);
@ -129,9 +129,9 @@ if (getCookie("authenticated")) {
}
if(installServiceWorker){
window.addEventListener('load', () => {
navigator.serviceWorker.register('sw.js').then(registration => {
navigator.serviceWorker.register('sw.js').then((registration) => {
console.log('SW registered: ', registration);
}).catch(registrationError => {
}).catch((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) {
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
} // else nothing
} else {

View File

@ -70,16 +70,16 @@ self.addEventListener('fetch', function (event) {
}
});
self.addEventListener('install', event => {
self.addEventListener('install', (event) => {
self.skipWaiting();
event.waitUntil(
caches.open(cacheName).then(cache => {
caches.open(cacheName).then((cache) => {
cache.addAll(urls);
fetch('resources/dist/manifest.json')
.then(response => response.json())
.then(manifest => {
.then((response) => response.json())
.then((manifest) => {
let scripts_required = ["main.js", "maps.js"];
scripts_required.map(script_name => {
scripts_required.map((script_name) => {
console.log(manifest);
console.log(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(
caches.keys().then(keys => Promise.all(
keys.map(key => {
caches.keys().then((keys) => Promise.all(
keys.map((key) => {
if (!expectedCaches.includes(key)) {
console.log("Deleting cache "+key);
return caches.delete(key);