Basic localStorage usage
From SmartBots Developers Docs
Bot PlaygroundExamples
Revision as of 15:21, 6 October 2016 by Gg (Talk | contribs) (Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} This script displays the basic usage of localStorage.set() and localStorage.get() functions. <syntaxhighlight lang="javascript"> var CONFIG...")
Jump to: navigation, search
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));
}
- Basic localStorage usage