diff --git a/public/style.css b/public/style.css
index b8c8820..95c3d13 100644
--- a/public/style.css
+++ b/public/style.css
@@ -253,9 +253,12 @@ summary {
border-top: 1px dotted gray;
font-size: 12px;
}
-.comment form.savecomment {
+form.savecomment {
margin: 0px 0px 10px 10px;
}
+.comment > .children > form.savecomment {
+ margin: 0px 0px 10px 20px;
+}
.savecomment textarea {
width: 500px;
height: 100px;
@@ -370,7 +373,6 @@ form.nsfw div {
}
.pager {
margin: 10px;
- display: none;
}
.pager a {
padding: 1px 4px;
@@ -381,10 +383,18 @@ form.nsfw div {
text-decoration: none;
color: #369;
}
+.pager.hidden {
+ display: none;
+}
+#loadmore {
+ display: none;
+}
#loadmore, #end {
- visibility: hidden;
margin: 10px 0px;
}
+#loadmore.show {
+ display: block;
+}
#loadmore[disabled] {
visibility: visible;
}
@@ -475,6 +485,23 @@ form.nsfw div {
position: relative;
color: #000;
}
+#settings {
+ background-color: white;
+ border: 1px solid #888;
+ display: none;
+ position: absolute;
+ right: 10px;
+ top: 45px;
+}
+#settings form {
+ margin: 0px;
+}
+.dark #settings {
+ background-color: #262626;
+}
+#settings.open {
+ display: inline-block;
+}
.expando.open{
display: block;
}
@@ -980,7 +1007,7 @@ form.create input[type=file], form.create select {
}
.preferences label{
display: inline-block;
- width: 120px;
+ width: 100px;
text-align: right;
}
diff --git a/public/utils.js b/public/utils.js
index 458610a..5af1ba4 100644
--- a/public/utils.js
+++ b/public/utils.js
@@ -1,8 +1,10 @@
-function request(url, params, callback, errorcallback) {
+function request(url, params, callback, errorcallback = function(){}) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
+ if (xmlHttp.readyState != 4 ) { return }
+ if (xmlHttp.status == 200) {
return callback(xmlHttp.responseText);
+ }
errorcallback(xmlHttp.responseText);
}
var method = "GET"
@@ -41,7 +43,11 @@ function commentClick(e) {
var form = e.target.parentNode
if (form) {
data = new FormData(form)
- if (("c"+data.get("commentid")) != targ.id) { return }
+ if (("c"+data.get("commentid")) == targ.id) {
+
+ } else if (("c"+data.get("parentid")) == targ.id) {
+ targ = form
+ } else { return }
params = new URLSearchParams(data).toString()
params += "&" + e.target.name + "=" + e.target.value
params += "&xhr=1"
@@ -114,6 +120,8 @@ function loadMore(e) {
toggle_images(true)
}
}
+ var loadmore = document.getElementById("loadmore")
+ if (loadmore) loadmore.className = "show"
}
else {
e.target.outerHTML = ''
@@ -167,6 +175,47 @@ function formSubmit(e) {
return false
}
+function open_settings(e) {
+ e.preventDefault()
+ var settings = document.getElementById("settings")
+ settings.className = "open"
+ request(e.target.href + "?xhr=1", "", function(res) {
+ settings.innerHTML = res
+ var options = document.getElementsByClassName("scripting")
+ for (var i = 0; i < options.length; i++) {
+ var input = options[i].getElementsByTagName('input')
+ if (!input.length) { continue }
+ if (localStorage.getItem(input[0].name) == "true") {
+ input[0].checked = "checked"
+ }
+ }
+ })
+ return false
+}
+
+function close_settings(e) {
+ e.preventDefault()
+ var settings = document.getElementById("settings")
+ settings.className = ""
+ return false
+}
+
+function save_settings(e) {
+ e = e || window.event;
+ var targ = e.currentTarget || e.srcElement || e;
+ var data = new FormData(targ)
+ console.log(data)
+ e.preventDefault()
+ var params = new URLSearchParams(data).toString()
+ request(targ.target, params, function(res) {
+ ["endlessScrolling", "autoLoad"].map(function(x) {
+ localStorage.setItem(x, data.get(x)=="on")
+ })
+ window.location.reload()
+ })
+ return false;
+}
+
function parse_youtube(url){
if (url.indexOf("youtu") == -1) return false
var regExp = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/;
@@ -227,12 +276,22 @@ for (var i = 0; i < posts.length; i++) {
}
}
-window.onscroll = function(ev) {
- if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
- var loadmore = document.getElementById("loadmore")
- if (loadmore) {
- loadmore.click()
- }
- }
-};
+if (localStorage.getItem("endlessScrolling") == "true") {
+ var pager = document.getElementsByClassName("pager")
+ if (pager.length) pager[0].className = "pager hidden"
+ var loadmore = document.getElementById("loadmore")
+ if (loadmore) loadmore.className = "show"
+
+ if (localStorage.getItem("autoLoad") == "true") {
+ window.onscroll = function(e) {
+ if ((window.innerHeight + Math.round(window.scrollY)) >= document.body.offsetHeight) {
+ var loadmore = document.getElementById("loadmore")
+ if (loadmore) {
+ loadmore.click()
+ }
+ }
+ };
+ }
+}
+
diff --git a/routes.go b/routes.go
index 71c388e..c32c9a4 100644
--- a/routes.go
+++ b/routes.go
@@ -147,7 +147,7 @@ var funcMap = template.FuncMap{
converted = re.ReplaceAllString(converted, `href="/`+host+`/$1`)
re = regexp.MustCompile(` !([a-zA-Z0-9]+)@([a-zA-Z0-9\.\-]+) `)
converted = re.ReplaceAllString(converted, ` !$1@$2 `)
- re = regexp.MustCompile(`::: spoiler (.*?)\n(.*?)\s:::`)
+ re = regexp.MustCompile(`::: spoiler (.*?)\n([\S\s]*?):::`)
converted = re.ReplaceAllString(converted, "$1
$2