From 3cb8b19a4eb0410e6ea86b975369af869df8a8b9 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Sun, 28 Apr 2024 11:43:26 -0400 Subject: [PATCH] expand marks read option. #103 --- public/utils.js | 10 +++++++--- templates/settings.html | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/utils.js b/public/utils.js index 320a070..530922a 100644 --- a/public/utils.js +++ b/public/utils.js @@ -1,11 +1,11 @@ function request(url, params, callback, errorcallback = function(){}) { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function() { - if (xmlHttp.readyState != 4 ) { return } + if (xmlHttp.readyState != 4 || !callback ) { return } if (xmlHttp.status == 200) { return callback(xmlHttp.responseText); } - errorcallback(xmlHttp.responseText); + if (errorcallback) errorcallback(xmlHttp.responseText); } var method = "GET" if (params) method = "POST" @@ -31,6 +31,10 @@ function postClick(e) { bdy.className = 'expando open'; btn.className = "expando-button open" var url = targ.getElementsByClassName("url")[0].href + if (bdy.querySelector("img.image") && localStorage.getItem("markRead") == "true") { + bdy.parentNode.querySelector(".title").className = "title visited" + request(bdy.parentNode.querySelector('.buttons a').href, { op: "read_post", submit: "mark read"}) + } if (id = parseYoutube(url)) { targ.getElementsByClassName("embed")[0].innerHTML = youtubeIframe(id) } @@ -378,7 +382,7 @@ function saveSettings(e) { var data = new FormData(targ) e.preventDefault() request(targ.target, data, function(res) { - ["endlessScrolling", "autoLoad"].map(function(x) { + ["endlessScrolling", "autoLoad", "markRead"].map(function(x) { localStorage.setItem(x, data.get(x)=="on") }) window.location.reload() diff --git a/templates/settings.html b/templates/settings.html index ad94120..f4de045 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -148,6 +148,14 @@ + {{ if .Session }} +
+ + +
+ {{ end }}