bookwyrm/bookwyrm/static/js/localstorage.js
Fabien Basmaison 53f03457cc Add linter for JS files with basic recommended rules:
- Add Github Action.
- Fix JS files to match rules; mostly `globals` and `exported`.
2021-03-31 17:07:28 +02:00

21 lines
589 B
JavaScript

/* exported updateDisplay */
/* globals addRemoveClass */
// set javascript listeners
function updateDisplay(e) {
// used in set reading goal
var key = e.target.getAttribute('data-id');
var value = e.target.getAttribute('data-value');
window.localStorage.setItem(key, value);
document.querySelectorAll('[data-hide="' + key + '"]')
.forEach(t => setDisplay(t));
}
function setDisplay(el) {
// used in set reading goal
var key = el.getAttribute('data-hide');
var value = window.localStorage.getItem(key);
addRemoveClass(el, 'hidden', value);
}