expand marks read option. #103

This commit is contained in:
Ryan Stafford 2024-04-28 11:43:26 -04:00
parent 77abd06a2c
commit 3cb8b19a4e
2 changed files with 15 additions and 3 deletions

View file

@ -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()

View file

@ -148,6 +148,14 @@
</label>
<input type="checkbox" name="linksInNewWindow" {{ if .LinksInNewWindow }}checked{{end}}>
</div>
{{ if .Session }}
<div class="scripting">
<label>
expand marks read
</label>
<input type="checkbox" name="markRead">
</div>
{{ end }}
<div>
<label>lemmy: {{ .Site.Version }}<br><a href="https://github.com/rystaf/mlmym">mlmym</a>: {{ .Version }}</label>
<input type="submit" value="save">