fix a bunch of settings

master
Aevann 2023-01-01 16:19:25 +02:00
parent d831e7ed2c
commit 2e6d7e61dd
3 changed files with 13 additions and 10 deletions

View File

@ -92,14 +92,17 @@ for (const element of setting_switchs) {
};
}
const setting_reloads = document.getElementsByClassName('setting_reload');
for (const element of setting_reloads) {
const setting_selects = document.getElementsByClassName('setting_select');
for (const element of setting_selects) {
if (element.dataset.nonce != nonce) {
console.log("Nonce check failed!")
continue
}
element.onchange = () => {
postToastReload(element,`/settings/personal?${element.name}=${element.value}`);
if (element.dataset.reload)
postToastReload(element,`/settings/personal?${element.name}=${element.value}`);
else
postToast(element,`/settings/personal?${element.name}=${element.value}`);
};
}

View File

@ -41,7 +41,7 @@
<div class="body w-lg-100">
<p>Change how many posts appear on every page.</p>
<div class="input-group mb2">
<select autocomplete="off" id='frontsize' class="form-control setting_switch" data-nonce="{{g.nonce}}" form="profile-settings" name="frontsize">
<select autocomplete="off" id='frontsize' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="frontsize">
{% for entry in PAGE_SIZES %}
<option value="{{entry}}"{{' selected' if v.frontsize==entry}}>{{entry}}</option>
{% endfor %}
@ -56,7 +56,7 @@
<div class="body w-lg-100">
<p>Change the default sorting for comments.</p>
<div class="input-group mb2">
<select autocomplete="off" id='defaultsortingcomments' class="form-control setting_switch" data-nonce="{{g.nonce}}" form="profile-settings" name="defaultsortingcomments">
<select autocomplete="off" id='defaultsortingcomments' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="defaultsortingcomments">
{% for entry in COMMENT_SORTS %}
<option value="{{entry}}"{{' selected' if v.defaultsortingcomments==entry}}>{{entry}}</option>
{% endfor %}
@ -71,7 +71,7 @@
<div class="body w-lg-100">
<p>Change the default sorting for posts.</p>
<div class="input-group mb2">
<select autocomplete="off" id='defaultsorting' class="form-control setting_switch" data-nonce="{{g.nonce}}" form="profile-settings" name="defaultsorting">
<select autocomplete="off" id='defaultsorting' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="defaultsorting">
{% for entry in SORTS %}
<option value="{{entry}}"{{' selected' if v.defaultsorting==entry}}>{{entry}}</option>
{% endfor %}
@ -86,7 +86,7 @@
<div class="body w-lg-100">
<p>Change the default time filter for posts.</p>
<div class="input-group mb2">
<select autocomplete="off" id='defaulttime' class="form-control setting_switch" data-nonce="{{g.nonce}}" form="profile-settings" name="defaulttime">
<select autocomplete="off" id='defaulttime' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="defaulttime">
{% for entry in TIME_FILTERS %}
<option value="{{entry}}"{{' selected' if v.defaulttime==entry}}>{{entry}}</option>
{% endfor %}
@ -115,7 +115,7 @@
<div class="body w-lg-100">
<p>Change the domain you would like to view reddit posts in.</p>
<div class="input-group mb2">
<select autocomplete="off" id='reddit' class="form-control setting_switch" data-nonce="{{g.nonce}}" form="profile-settings" name="reddit">
<select autocomplete="off" id='reddit' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="reddit">
{% for entry in ['old.reddit.com', 'reddit.com', 'i.reddit.com', 'unddit.com', 'teddit.net', 'libredd.it'] %}
<option value="{{entry}}"{{' selected' if v.reddit==entry}}>{{entry}}</option>
{% endfor %}

View File

@ -29,7 +29,7 @@
</div>
<div class="body w-lg-100">
<div class="input-group mb2">
<select autocomplete="off" id='theme' class="form-control setting_reload" form="profile-settings" name="theme" data-nonce="{{g.nonce}}">
<select autocomplete="off" id='theme' class="form-control setting_select" form="profile-settings" name="theme" data-nonce="{{g.nonce}}" data-reload="1">
{% for entry in THEMES %}
<option value="{{entry}}" {% if v.theme==entry %} selected {% endif %}>
{{entry}}
@ -100,7 +100,7 @@
<p>Join a house (cost: {{cost}} coins or marseybux).</p>
{% endif %}
<div class="input-group mb2">
<select {% if v.coins < cost and v.marseybux < cost or v.bite %}disabled{% endif %} autocomplete="off" id='house' class="form-control setting_reload" form="profile-settings" name="house" data-nonce="{{g.nonce}}">
<select {% if v.coins < cost and v.marseybux < cost or v.bite %}disabled{% endif %} autocomplete="off" id='house' class="form-control setting_select" form="profile-settings" name="house" data-nonce="{{g.nonce}}" data-reload="1">
{% for entry in HOUSES %}
<option value="{{entry}}" {% if v.house.startswith(entry) %} selected {% endif %}>
{{entry}}