X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2Fmaterial%2Findex.js;fp=app%2FResources%2Fstatic%2Fthemes%2Fmaterial%2Findex.js;h=185ac1e068c09abf0979f4c53e77a20356523002;hb=e101052afc69efb18c413776e39a0281576c4ca4;hp=d8f5628cd5cf866f2ebdb7c848ec7d91ee1d7764;hpb=0914a6f2fd33aeda6100e4d94c3ea3cec942f5f0;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index d8f5628c..185ac1e0 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js @@ -120,4 +120,30 @@ $(document).ready(() => { }); }); } + + $('.markasread').on('click', () => { + const article = document.getElementById('article'); + const link = document.getElementById('link-archive'); + const articleId = article.dataset.id; + const xhr = new XMLHttpRequest(); + + xhr.onload = function toggleArchive() { + if (xhr.status === 200) { + const previousStatus = document.getElementById('archive-icon').innerHTML; + let status = link.dataset.iconUnread; + let label = link.dataset.labelUnread; + if (previousStatus === 'unarchive') { + status = link.dataset.iconRead; + label = link.dataset.labelRead; + } + document.getElementById('archive-icon').innerHTML = status; + document.getElementById('archive-label').innerHTML = label; + window.Materialize.toast(xhr.responseText, 4000); + } + }; + + const url = `${Routing.generate('archive_entry', { id: articleId })}?some_var_name=true`; + xhr.open('GET', url, false); + xhr.send(null); + }); });