forked from zealotrunner/fancy-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added extension icon and improved style
- Loading branch information
Frank Kohlhepp
committed
Mar 27, 2011
1 parent
db4289f
commit 8a0f10b
Showing
6 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
// Copyright (c) 2011 Frank Kohlhepp | ||
// https://github.com/frankkohlhepp/store-js | ||
// License: MIT-license | ||
*/ | ||
(function () { | ||
this.Store = function (name) { | ||
var storePrototype = { | ||
"save": function () { | ||
var stringifiedObj = JSON.stringify(this); | ||
localStorage.setItem(name, stringifiedObj); | ||
|
||
if (localStorage.getItem(name) !== stringifiedObj) { | ||
throw "savingFailed"; | ||
} | ||
|
||
return this; | ||
}, | ||
|
||
"remove": function () { | ||
localStorage.removeItem(name); | ||
for (var key in this) { | ||
if (this.hasOwnProperty(key)) { | ||
delete this[key]; | ||
} | ||
} | ||
|
||
return this; | ||
} | ||
}; | ||
|
||
var store = JSON.parse(localStorage.getItem(name) || "{}"); | ||
store.__proto__ = storePrototype; | ||
return store; | ||
}; | ||
})(); |