/* Feature Detectors */ /* Valid values for ${type}: localstorage, sessionstorage */ async function storageAvailable(type) { try { var storage = window[type], x = '__storage_test__'; storage.setItem(x, x); storage.getItem(x); return true; } catch (err) { return false; } } /* Delays */ /* Usage: '' */ const delay = ms => new Promise(res => setTimeout(res, ms)); /* Log Helper */ /* Values for level: 1, 2, 3 */ /* Maintains backwards compatibility for previous implementation of log helper */ async function log(msg, type) { var time = new Date().toISOString(); switch (type) { case "ERR": console.error(`${time} - ${msg}`); break; case "WARN": console.warn(`${time} - ${msg}`); break; case "INFO": console.info(`${time} - ${msg}`); break; default: console.log(`${time} - ${msg}`); break; }; }; /* Loading Box Control */ async function hideLoading() { document.getElementById("loading").style = "display: none;"; } /* DEPRECIATED: Alias for hideLoading() - Marked for removal*/ async function clearLoading() { log("Depreciated function called - clearLoading()", "WARN") await hideLoading(); } async function showLoading() { document.getElementById("loading").style = "display: block;"; } async function setLoadingDesc(desc) { document.getElementById("loading_desc").textContent = `${desc}`; }