diff options
Diffstat (limited to 'app/Resources/static/themes/material/index.js')
-rwxr-xr-x | app/Resources/static/themes/material/index.js | 26 |
1 files changed, 26 insertions, 0 deletions
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(() => { | |||
120 | }); | 120 | }); |
121 | }); | 121 | }); |
122 | } | 122 | } |
123 | |||
124 | $('.markasread').on('click', () => { | ||
125 | const article = document.getElementById('article'); | ||
126 | const link = document.getElementById('link-archive'); | ||
127 | const articleId = article.dataset.id; | ||
128 | const xhr = new XMLHttpRequest(); | ||
129 | |||
130 | xhr.onload = function toggleArchive() { | ||
131 | if (xhr.status === 200) { | ||
132 | const previousStatus = document.getElementById('archive-icon').innerHTML; | ||
133 | let status = link.dataset.iconUnread; | ||
134 | let label = link.dataset.labelUnread; | ||
135 | if (previousStatus === 'unarchive') { | ||
136 | status = link.dataset.iconRead; | ||
137 | label = link.dataset.labelRead; | ||
138 | } | ||
139 | document.getElementById('archive-icon').innerHTML = status; | ||
140 | document.getElementById('archive-label').innerHTML = label; | ||
141 | window.Materialize.toast(xhr.responseText, 4000); | ||
142 | } | ||
143 | }; | ||
144 | |||
145 | const url = `${Routing.generate('archive_entry', { id: articleId })}?some_var_name=true`; | ||
146 | xhr.open('GET', url, false); | ||
147 | xhr.send(null); | ||
148 | }); | ||
123 | }); | 149 | }); |