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