diff --git a/web/cw.js b/web/cw.js index c780b85..6c9f98e 100644 --- a/web/cw.js +++ b/web/cw.js @@ -226,6 +226,7 @@ audioGlobal.autoplay = false; audioGlobal.loop = false; + // Creates and plays a short notification sound at the requested volume. function playAudio(src, vlm) { let audio = audioGlobal; audio.src = src; @@ -233,6 +234,7 @@ audio.play(); } + // Reads one user preference, falling back to defaults when unset. function getSettings(key) { //Получение настроек let setting = 'cws_sett_' + key; let val = window.localStorage.getItem(setting); @@ -249,6 +251,7 @@ } var error_tm; + // Displays a transient in-game error message in the shared notification area. function error(t) { $("#error").text(t).show(); clearTimeout(error_tm); @@ -257,25 +260,30 @@ }, 10000); } + // Hides the currently displayed error without changing stored settings. function hideError() { clearTimeout(error_tm); $("#error").fadeOut(500); } + // Persists one preference and updates the in-memory settings cache. function setSettings(key, val) { let setting = 'cws_sett_' + key; window.localStorage.setItem(setting, val); } + // Removes a preference so subsequent reads use its default value. function removeSettings(key) { let setting = 'cws_sett_' + key; window.localStorage.removeItem(setting); } + // Injects a style block into the page and returns the created element. function addCSS(css) { $('head').append(``); } + // Formats a numeric component with a leading zero for clock-like displays. function leadZero(num) { return (num < 10) ? '0' + num : num; } @@ -357,6 +365,7 @@ } } } + // Initializes helpers that only apply to the main game page. function cw3() { //Игровая if (globals.on_settLink) { $('.small').first().append(` | Настройки модов`); //Настройки мода @@ -1954,6 +1963,7 @@ ${globals.on_treeTechies?`