2024-07-29 04:24:28 +08:00
|
|
|
{# templates/form.html #}
|
|
|
|
|
|
|
|
{% set key = item.key %}
|
|
|
|
|
|
|
|
{% macro input(item, type='text', class='api', name='name') %}
|
2024-08-18 00:47:36 +08:00
|
|
|
<input class="{{ class }}" type="{{ type }}" name="{{ name }}{{ key }}" data-type="{{ item.type }}" data-key="{{ key }}"
|
2024-07-29 04:24:28 +08:00
|
|
|
onchange="valueChangedHandler(this)"
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro label(item, class='label-inline', add='') %}
|
|
|
|
<label class="{{class}}"> {{ item.name }}{{ add }}</label>
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% block form_render %}
|
|
|
|
{% if item.get("elem") == "hex_info" %}
|
|
|
|
{{ label(item, add=':') }}
|
|
|
|
{{ input(item, class='content api') }} data-hex readonly />
|
|
|
|
|
|
|
|
{% elif item.get("elem") == "label" %}
|
|
|
|
{{ label(item, class='') }}
|
|
|
|
|
|
|
|
{% elif item.get("elem") == "range" %}
|
|
|
|
<div class="clearfix">
|
|
|
|
<form>
|
|
|
|
{{ label(item, add='=') }}
|
|
|
|
|
|
|
|
{{ input(item, class='input-inline', type='number', name='aInput') }}
|
|
|
|
readonly oninput="this.form.aRange{{ key }}.value=this.value" />
|
2024-08-18 00:47:36 +08:00
|
|
|
|
2024-07-29 04:24:28 +08:00
|
|
|
{{ input(item, class='range api', type='range', name='aRange') }}
|
2024-08-18 00:47:36 +08:00
|
|
|
min="{{ item.values.min }}" max="{{ item.values.max }}" oninput="this.form.aInput{{key}}.value=this.value" />
|
2024-07-29 04:24:28 +08:00
|
|
|
</form>
|
2024-08-18 00:47:36 +08:00
|
|
|
|
2024-07-29 04:24:28 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{% elif item.get("elem") == "checkbox" %}
|
|
|
|
<div class="clearfix">
|
2024-08-18 00:47:36 +08:00
|
|
|
{{ label(item) }}
|
2024-07-29 04:24:28 +08:00
|
|
|
{{ input(item, type="checkbox") }} />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% elif item["values"] %}
|
|
|
|
{{ label(item, class='') }}
|
2024-08-18 00:47:36 +08:00
|
|
|
<select class="api" data-type="{{ item.type }}" data-key="{{ key }}" required>
|
2024-07-29 04:24:28 +08:00
|
|
|
<option disabled selected value></option>
|
|
|
|
|
2024-08-18 00:47:36 +08:00
|
|
|
{% for k, v in item["values"].items() %}
|
2024-07-29 04:24:28 +08:00
|
|
|
<option value="{{ k }}">{{ v }}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select><br />
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
{{ label(item, class='') }}
|
|
|
|
{{ input(item) }} />
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
{% endblock %}
|