From ed0d81dc63f6856dfe402614760197010ee6be0f Mon Sep 17 00:00:00 2001 From: Renard Date: Wed, 3 Apr 2019 16:00:39 -0300 Subject: Shobon: MarkAsRead re-do --- static/js/shobon.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/static/js/shobon.js b/static/js/shobon.js index 534821e..86faa53 100644 --- a/static/js/shobon.js +++ b/static/js/shobon.js @@ -88,7 +88,16 @@ function shobon() { } if (newRepliesInThread > 0 && !inThread) { - thread.getElementsByClassName("threadlinks")[0].innerHTML += "Marcar como leido"; + var btnNew = document.createElement("span"); + btnNew.dataset.id = boardName + "_" + threadId; + btnNew.dataset.last = lastReplyN; + btnNew.textContent = "Marcar como leĆ­do"; + btnNew.setAttribute("style", "font-weight: bold; background: #81a2be; padding: 5px; border-radius: 5px; float: right; margin-bottom: 10px;"); + btnNew.onclick = function(){ + localStorage.setItem(this.dataset.id, this.dataset.last); + this.hidden = true; + }; + thread.getElementsByClassName("threadlinks")[0].appendChild(btnNew); } } @@ -103,16 +112,6 @@ function shobon() { if(localStorage.getItem("shobon_newposts") == "true" && inThread) { localStorage.setItem(boardName + "_" + threadId, lastReplyN); } - - var btns = document.getElementsByClassName("btnMarkAsRead"); - for (var i = 0; i < btns.length; i++){ - btns[i].addEventListener("click", markAsRead, false); - } -} - -function markAsRead(){ - this.style.display = none; - localStorage.setItem(this.dataset.id, this.dataset.last); } function on_checked(e) { -- cgit v1.2.1-18-gbd029