Skip to content

Instantly share code, notes, and snippets.

@rtekie
Created August 26, 2012 19:47
Show Gist options
  • Save rtekie/3483057 to your computer and use it in GitHub Desktop.
Save rtekie/3483057 to your computer and use it in GitHub Desktop.
// Retrieve a list of URLs from the local storage.
// Use defaults if storage has not been initialized yet.
// URLs are serialized using JSON for storage.
function getMyUrls() {
var myUrls;
var storedUrls = localStorage.getItem("myUrls");
if (storedUrls) {
// Deserialize URLs
myUrls = JSON.parse(storedUrls);
}
else {
// Initialize defaults
myUrls = [encodeURIComponent("http://ctoinsights.wordpress.com"), encodeURIComponent("http://www.book-current.com")];
localStorage.setItem("myUrls", JSON.stringify(myUrls));
}
return myUrls;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment