Difference between revisions of "Bot Playground/Examples/Basic localStorage usage"
From SmartBots Developers Docs
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} This script displays the basic usage of localStorage.set() and localStorage.get() functions. <syntaxhighlight lang="javascript"> var CONFIG...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
− | This script displays the basic usage of localStorage.set() and localStorage.get() functions. | + | This script displays the basic usage of [[Bot_Playground/Built-in_Functions/localStorage.set|localStorage.set()]] and [[Bot_Playground/Built-in_Functions/localStorage.get|localStorage.get()]] functions. |
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> |
Latest revision as of 15:23, 6 October 2016
This script displays the basic usage of localStorage.set() and localStorage.get() functions.
var CONFIG = {};
restoreConfig();
CONFIG.runs++;
console.log("This script is starting for " + CONFIG.runs + " time");
saveConfig();
function restoreConfig() {
var cnf = localStorage.get("my_config");
CONFIG = { runs: 0 };
if(typeof(cnf) != "undefined" && cnf != "") {
CONFIG = JSON.parse(cnf);
}
}
function saveConfig() {
localStorage.set("my_config", JSON.stringify(CONFIG));
}