Created
February 13, 2013 13:58
-
-
Save sooop/4944789 to your computer and use it in GitHub Desktop.
memoUtils.js
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
/* memoUtils.js */ | |
var ls = null; | |
var docs = new Array(); | |
var keys = new Array(); | |
var currentDoc = null; | |
var getStorage = function() | |
{ | |
if(window.Storage) | |
{ | |
if(!ls) ls = window.localStorage; | |
return true; | |
} | |
console.log("No Storage Supported"); | |
return false; | |
}; | |
function doc(key){ | |
this.key = key; | |
this.title = "untitled"; | |
this.body = "Start Here..."; | |
this.save = function(){ | |
if(getStorage()) | |
{ | |
ls.setItem('title-'+this.key, this.title); | |
ls.setItem('body-'+this.key, this.body); | |
} | |
}; | |
this.load = function(){ | |
if(getStorage()) | |
{ | |
this.title = ls.getItem('title-'+this.key); | |
this.body = ls.getItem('body-'+this.key); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment