add cross channel reply setting

This commit is contained in:
Mystikfluu 2022-07-26 00:53:11 +02:00
parent b942dd73cd
commit e788d84194
4 changed files with 30 additions and 1 deletions

View File

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

View File

@ -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
}
}

View File

@ -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
}

View File

@ -59,6 +59,9 @@
<br>
<span id="response_pw"></span>
</div>
<div>
<input type="checkbox" id="ACCR_checkbox" onchange="setAllowCCR()"> Cross-Channel Reply <br>
</div>
</div>
</main>
<footer>