Created
May 15, 2014 23:58
-
-
Save ethertank/3cc6cb395359850318f9 to your computer and use it in GitHub Desktop.
あとで
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//初期値 | |
var defaultSetting = { | |
width: 400, | |
height: 300, | |
color: "black" | |
}; | |
//前回実行時に localStorage に setting が追加されていたらそれを読む。 | |
//無ければ defaultSetting オブジェクトを。 | |
var setting = JSON.parse(localStorage.getItem("setting")) || defaultSetting; | |
//この辺でアプリ実行毎に書き換える必要がある値があるなら変えとく | |
//保存。 | |
//その他、任意のタイミングで保存。 | |
localStorage.setItem( | |
"setting", | |
JSON.stringify(setting) | |
); | |
//確認。いけてるっぽい? | |
console.dir( | |
JSON.parse(localStorage.getItem("setting")) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment