-
-
Save ngstwr/31a75e542fba432a2f1c to your computer and use it in GitHub Desktop.
Revisions
-
anhang created this gist
Jul 20, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ AZHU.storage = { save : function(key, jsonData, expirationMin){ if (!Modernizr.localstorage){return false;} var expirationMS = expirationMin * 60 * 1000; var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS} localStorage.setItem(key, JSON.stringify(record)); return jsonData; }, load : function(key){ if (!Modernizr.localstorage){return false;} var record = JSON.parse(localStorage.getItem(key)); if (!record){return false;} return (new Date().getTime() < record.timestamp && JSON.parse(record.value)); } }