mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-08 23:29:21 +02:00
67 lines
1.5 KiB
Twig
67 lines
1.5 KiB
Twig
<div class="card card-primary card-outline card-outline-tabs">
|
|
<div class="card-header">
|
|
<h5 class="m-0">Settings</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="box">
|
|
<div class="box-body">
|
|
<button name="save" type="submit" class="btn btn-primary">Save</button>
|
|
</div>
|
|
<br/>
|
|
{{ settingsParsed|raw }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
function doShowHide(el, show)
|
|
{
|
|
if (show) {
|
|
$(el).show()
|
|
}
|
|
else {
|
|
$(el).hide()
|
|
}
|
|
}
|
|
|
|
{% for key, value in settings %}
|
|
{% if value.show_if is defined %}
|
|
$(function () {
|
|
$('input[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
|
performChecks_{{ key }}(this);
|
|
});
|
|
|
|
{% if settings[value.show_if[0]]['type'] == 'boolean' %}
|
|
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]:checked');
|
|
{% else %}
|
|
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]');
|
|
{% endif %}
|
|
});
|
|
|
|
function performChecks_{{ key }}(el)
|
|
{
|
|
let success = false;
|
|
let thisVal = $(el).val();
|
|
|
|
let operator = '{{ value.show_if[1]|raw }}';
|
|
if (operator === '>') {
|
|
success = thisVal > Number('{{ value.show_if[2] }}');
|
|
}
|
|
else if (operator === '<') {
|
|
success = thisVal < Number('{{ value.show_if[2] }}');
|
|
}
|
|
else if (operator === '==' || operator === '=') {
|
|
success = thisVal == '{{ value.show_if[2] }}';
|
|
}
|
|
|
|
doShowHide('#row_{{ key }}', success);
|
|
}
|
|
{% endif %}
|
|
{% endfor %}
|
|
</script>
|