Skip to content

Instantly share code, notes, and snippets.

@sooop
Created February 13, 2013 13:58
Show Gist options
  • Save sooop/4944789 to your computer and use it in GitHub Desktop.
Save sooop/4944789 to your computer and use it in GitHub Desktop.
memoUtils.js
/* 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