Browse Source

Show hearted nodes

pm2
Luke Childs 8 years ago
parent
commit
cccb84f077
  1. 14
      public/assets/enhancements.js

14
public/assets/enhancements.js

@ -57,14 +57,20 @@
}
});
// Show heart as active if we've already hearted this node
var storageKey = 'heartedNodes';
var heartedNodes = JSON.parse(localStorage.getItem(storageKey)) || [];
var node = /^\/node\/([a-zA-Z0-9]+)/.exec(window.location.pathname);
node = node ? node[1] : node;
if(heartedNodes.indexOf(node) > -1) {
heartEl.classList.add('hearted');
}
// Add click handler
heartEl.addEventListener('click', function(e) {
// Setup vars
var storageKey = 'heartedNodes';
// Recheck localStorage
var heartedNodes = JSON.parse(localStorage.getItem(storageKey)) || [];
var node = /^\/node\/([a-zA-Z0-9]+)/.exec(window.location.pathname);
node = node ? node[1] : node;
var nodeIndex = heartedNodes.indexOf(node);
// Heart/unheart node

Loading…
Cancel
Save