docs: explain shared cwshed utility functions
This commit is contained in:
1 parent
67eed5d6ac
commit
7df69196c5
1 file changed
+7
@@ -212,6 +212,7 @@
|
|||||||
audioGlobal.autoplay = false;
|
audioGlobal.autoplay = false;
|
||||||
audioGlobal.loop = false;
|
audioGlobal.loop = false;
|
||||||
|
|
||||||
|
// Creates and plays a notification sound at the requested volume.
|
||||||
function playAudio(src, vlm) {
|
function playAudio(src, vlm) {
|
||||||
let audio = audioGlobal;
|
let audio = audioGlobal;
|
||||||
audio.src = src;
|
audio.src = src;
|
||||||
@@ -219,6 +220,7 @@
|
|||||||
audio.play();
|
audio.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reads one persisted userscript preference or its default value.
|
||||||
function getSettings(key) { //Получение настроек
|
function getSettings(key) { //Получение настроек
|
||||||
let setting = 'cws_sett_' + key;
|
let setting = 'cws_sett_' + key;
|
||||||
let val = window.localStorage.getItem(setting);
|
let val = window.localStorage.getItem(setting);
|
||||||
@@ -235,6 +237,7 @@
|
|||||||
}
|
}
|
||||||
var error_tm;
|
var error_tm;
|
||||||
|
|
||||||
|
// Displays a transient error message in the shared game notification area.
|
||||||
function error(t) {
|
function error(t) {
|
||||||
$("#error").text(t).show();
|
$("#error").text(t).show();
|
||||||
clearTimeout(error_tm);
|
clearTimeout(error_tm);
|
||||||
@@ -243,21 +246,25 @@
|
|||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hides the current error without changing any stored preference.
|
||||||
function hideError() {
|
function hideError() {
|
||||||
clearTimeout(error_tm);
|
clearTimeout(error_tm);
|
||||||
$("#error").fadeOut(500);
|
$("#error").fadeOut(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Persists one userscript preference for future page loads.
|
||||||
function setSettings(key, val) {
|
function setSettings(key, val) {
|
||||||
let setting = 'cws_sett_' + key;
|
let setting = 'cws_sett_' + key;
|
||||||
window.localStorage.setItem(setting, val);
|
window.localStorage.setItem(setting, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Removes one preference so subsequent reads fall back to its default.
|
||||||
function removeSettings(key) {
|
function removeSettings(key) {
|
||||||
let setting = 'cws_sett_' + key;
|
let setting = 'cws_sett_' + key;
|
||||||
window.localStorage.removeItem(setting);
|
window.localStorage.removeItem(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Injects a style block into the current page and returns its node.
|
||||||
function addCSS(css) {
|
function addCSS(css) {
|
||||||
$('head').append(`<style>${css}</style>`);
|
$('head').append(`<style>${css}</style>`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user