mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
Add base for handling and storing progress
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
define(function(){
|
||||
/*
|
||||
* Simple module for storing data in the browser's local storage
|
||||
*/
|
||||
return {
|
||||
set: function(key, value) {
|
||||
localStorage[key] = JSON.stringify(value);
|
||||
},
|
||||
get: function(key, def) {
|
||||
try {
|
||||
return JSON.parse(localStorage[key]) || def;
|
||||
} catch(err) {
|
||||
return localStorage[key] || def;
|
||||
}
|
||||
},
|
||||
remove: function(key) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user