(function() {
class AnotElement extends HTMLElement {
constructor() {
super();
this.attachShadow({'mode': 'open'});
}
listItem() {
const arr = JSON.parse(window.localStorage.getItem('annotations'));
return arr?arr:[];
}
hasItem(text) {
return text == '' || this.listItem().filter(stext => text === stext).length > 0;
}
saveItem(text) {
if (!this.hasItem(text)) {
const arr = this.listItem();
arr.push(text);
window.localStorage.setItem('annotations', JSON.stringify(arr));
}
}
delItem(text) {
const arr = this.listItem().filter(stext => text !== stext);
localStorage.setItem('annotations', JSON.stringify(arr.length>0?arr:[]));
}
}