Skip to content

Commit

Permalink
Task #27 Bookmarking system. Adding constants for key names.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesgs committed Sep 21, 2015
1 parent f922726 commit c872d1c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions assets/js/bookmark.js
Expand Up @@ -22,24 +22,33 @@

var Bookmark = {
storage : null,

BOOKMARK_HISTORY : 'mangapress-bookmark-history',
BOOKMARK : 'mangapress-bookmark',
init: function() {
this.storage = localStorage;
},

bookmark : function() {
var href = window.location.href,
pageTitle = window.document.title,
data = {};
console.log(this);
data = {},
d = new Date();

var existingBookmarkData = this.storage.getItem(this.BOOKMARK);

if (existingBookmarkData) {
var bookmarkHistory = JSON.parse(this.storage.getItem(this.BOOKMARK_HISTORY));
bookmarkHistory.push(existingBookmarkData);
this.storage.setItem(this.BOOKMARK_HISTORY, JSON.stringify(bookmarkHistory));
}

data = {
url : href,
title : pageTitle,
date : Date.now()
};

this.storage.setItem('bookmark', JSON.stringify(data));
console.log(JSON.parse(this.storage.getItem('bookmark')));
this.storage.setItem(this.BOOKMARK, JSON.stringify(data));
},

history : function() {
Expand Down

0 comments on commit c872d1c

Please sign in to comment.