{% macro taint_js() %}
function taint() {
- let els = document.getElementsByClassName("enable_on_change");
- for (let i = 0; i < els.length; i++) {
- els[i].disabled = false;
- }
- let links_text = '';
- els = document.getElementsByClassName("disable_on_change");
- for (let i = 0; i < els.length; i++) {
- links_text += els[i].textContent + ' ';
- }
+ // activate buttons "apply", "revert"
+ Array.from(document.getElementsByClassName("enable_on_change")).forEach((el) => {
+ el.disabled = false;
+ });
+ // deactivate Booking links
+ Array.from(document.getElementsByClassName("disable_on_change")).forEach((el) => {
+ links_text += el.textContent + ' ';
+ });
const span = document.getElementById('booking_links');
+ let links_text = '';
span.innerHTML = '';
const del = document.createElement("del");
span.appendChild(del);
del.textContent = links_text;
+ // remove oninput handlers no longer needed (since we only ever go one way)
+ ['input', 'textarea'].forEach((tag_name) => {
+ Array.from(document.getElementsByTagName(tag_name)).forEach((el) => {
+ el.oninput = null;
+ });
+ });
}
{% endmacro %}
{% block content %}
<form action="/edit_raw/{{id}}" method="POST">
{{ macros.edit_bar("structured", id) }}
-<textarea name="booking" cols=100 rows=100 onchange="taint()">
+<textarea name="booking" cols=100 rows=100 oninput="taint()">
{% for dat_line in dat_lines %}{{ dat_line.raw }}
{% endfor %}</textarea>
</form>
input.name = `line_${i}_${name}`
input.value = value.trim();
input.placeholder = placeholder;
- input.onchange = taint;
+ input.oninput = taint;
if (dat_line.error) {
td.classList.add("invalid");
}