diff --git a/js/posts.js b/js/posts.js
index 41a6279..3ac9ec4 100644
--- a/js/posts.js
+++ b/js/posts.js
@@ -312,6 +312,13 @@ async function loadChannels() {
currentChannel = channelname
socket.send(JSON.stringify({"id":"switchChannel","data":channelname}))
main()
+
+ let settings = await(await fetch("/api/settings")).json()
+ if(settings != "null") {
+ if(settings.ACCR == false) {
+ unreply()
+ }
+ }
})
tab.appendChild(channelp)
}
diff --git a/js/settings.js b/js/settings.js
index 7db4554..1df790b 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -139,3 +139,18 @@ async function changeUsername() {
setuser()
}
}
+
+
+async function setAllowCCR() {
+ const ACCR = document.getElementById("ACCR_checkbox").checked
+ const settingname = "ACCR" //Allow Cross-Channel reply (see #22 )
+
+ let r = await(await post("/api/settings",{setting: settingname, value: ACCR})).json()
+
+ if(r.status == "error") {
+ alert("Couldn't change setting")
+ console.log(r.code)
+ } else if(r.status == "success") {
+ //changed setting
+ }
+}
\ No newline at end of file
diff --git a/routes/api/settingshandler.js b/routes/api/settingshandler.js
index bdf07d1..b8e0c62 100644
--- a/routes/api/settingshandler.js
+++ b/routes/api/settingshandler.js
@@ -1,3 +1,7 @@
+const allowed_settings = { //"settingname":["validtypes"]
+ "ACCR": ["boolean"]
+}
+
module.exports = {
"setup": function(router,con,server) {
router.get("/api/settings",function(req,res) {
@@ -14,7 +18,7 @@ module.exports = {
res.json({"error":"no setting to change"})
return
}
- if((typeof req.body.value) != "string") {
+ if(!((typeof req.body.value) in allowed_settings[req.body.setting])) {
res.json({"error":"no new setting value given"})
return
}
diff --git a/views/settings.html b/views/settings.html
index 790c9f9..2ad29a8 100644
--- a/views/settings.html
+++ b/views/settings.html
@@ -59,6 +59,9 @@
+