add import-export for more stickiness
parent
4b7fd2acf8
commit
ac376d88b2
|
|
@ -25,6 +25,13 @@
|
||||||
<script>
|
<script>
|
||||||
function init() {
|
function init() {
|
||||||
load()
|
load()
|
||||||
|
save()
|
||||||
|
}
|
||||||
|
|
||||||
|
function doimport() {
|
||||||
|
var marshalled = document.getElementById("import").value
|
||||||
|
load_json(marshalled)
|
||||||
|
save()
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
|
@ -47,6 +54,10 @@
|
||||||
var marshalled = localStorage.getItem("data")
|
var marshalled = localStorage.getItem("data")
|
||||||
if (!marshalled)
|
if (!marshalled)
|
||||||
return
|
return
|
||||||
|
load_json(marshalled)
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_json(marshalled) {
|
||||||
var data = JSON.parse(marshalled)
|
var data = JSON.parse(marshalled)
|
||||||
var inputs = document.getElementById("form").getElementsByTagName("input")
|
var inputs = document.getElementById("form").getElementsByTagName("input")
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
@ -68,9 +79,14 @@
|
||||||
data.push({name: input.name, value: input.value, checked: input.checked})
|
data.push({name: input.name, value: input.value, checked: input.checked})
|
||||||
}
|
}
|
||||||
var marshalled = JSON.stringify(data)
|
var marshalled = JSON.stringify(data)
|
||||||
localStorage.setItem("data", marshalled)
|
save_json(marshalled)
|
||||||
console.log(new Date(), "saved", data)
|
console.log(new Date(), "saved", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function save_json(marshalled) {
|
||||||
|
localStorage.setItem("data", marshalled)
|
||||||
|
document.getElementById("export").value = marshalled
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</header>
|
</header>
|
||||||
<body onload="init();">
|
<body onload="init();">
|
||||||
|
|
@ -272,6 +288,17 @@
|
||||||
</notes>
|
</notes>
|
||||||
</free_company>
|
</free_company>
|
||||||
</form>
|
</form>
|
||||||
|
<io>
|
||||||
|
<details>
|
||||||
|
<summary>EXPORT</summary>
|
||||||
|
<textarea id="export" style="width: 100%"></textarea><br>
|
||||||
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary>IMPORT</summary>
|
||||||
|
<textarea id="import" style="width: 100%"></textarea><br>
|
||||||
|
<button onclick="doimport(); return false;">IMPORT</button>
|
||||||
|
</details>
|
||||||
<button onclick="reset(); return false;">RESET</button>
|
<button onclick="reset(); return false;">RESET</button>
|
||||||
|
</io>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue