summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngrid Budau <twigle_ingrid@yahoo.com>2021-11-09 08:49:46 +0100
committerIngrid Budau <twigle_ingrid@yahoo.com>2021-11-09 08:49:46 +0100
commitd379bebafd31b08326df62102dec295b1eb66474 (patch)
tree9f40868ce2f4201ba73c3407ef6e1cfdd164d9ce
parent2767bc1a54410ab6f9437ec037dd3602c4483fe6 (diff)
downloadqutebrowser-d379bebafd31b08326df62102dec295b1eb66474.tar.gz
qutebrowser-d379bebafd31b08326df62102dec295b1eb66474.zip
Refactore JS function which checks the input with the configured value
-rw-r--r--qutebrowser/html/settings.html29
1 files changed, 13 insertions, 16 deletions
diff --git a/qutebrowser/html/settings.html b/qutebrowser/html/settings.html
index 4c42336c2..9fc478565 100644
--- a/qutebrowser/html/settings.html
+++ b/qutebrowser/html/settings.html
@@ -11,10 +11,14 @@ var cset = function(option, value) {
xhr.send();
}
-let configVal;
-let inputId;
-let input;
-let currentVal;
+function checkInput(optionName, loopIndex) {
+ // Checks the input which has the configured value
+
+ let inputId = `input-${optionName}-${loopIndex}`
+ let input = document.getElementById(inputId)
+
+ input.checked = true
+}
{% endblock %}
{% block style %}
@@ -68,18 +72,11 @@ input[type="radio"]:checked + label { background-color: #a6dfff; color: #084c88;
<label for="input-{{ option.name }}-{{ loop.index0 }}">
{{ value }}
</label>
- <script type="text/javascript">
- function checkInput() {
- configVal = '{{ confget(option.name) }}'
- currentVal = '{{ value }}'
- inputId = "input-{{ option.name }}-{{ loop.index0 }}"
- input = document.getElementById(inputId)
-
- if (configVal === currentVal) { input.checked = true }
- }
-
- checkInput()
- </script>
+ {% if confget(option.name) == value %}
+ <script type="text/javascript">
+ checkInput('{{ option.name}}', {{ loop.index0 }})
+ </script>
+ {% endif %}
{% endfor %}
</td>
{% else %}