Created
August 8, 2011 13:20
-
-
Save pinscript/1131725 to your computer and use it in GitHub Desktop.
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
function Storage() { | |
this.isSupported = function () { | |
try { | |
return !!localStorage.getItem; | |
} catch (e) { | |
return false; | |
} | |
}; | |
this.get = function (name) { | |
return JSON.parse(window.localStorage.getItem(name)); | |
}; | |
this.set = function (name, value) { | |
window.localStorage.setItem(name, JSON.stringify(value)); | |
}; | |
this.clear = function () { | |
window.localStorage.clear(); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment