KankenOnline/kanken_online/static/translations.js

27 lines
1.0 KiB
JavaScript
Raw Normal View History

const addStringButton = document.getElementById("add-string-button");
addStringButton.addEventListener("click", (e) => {
const stringName = prompt("Enter a string name: ");
if (stringName == "") {
return;
}
for (let section of document.getElementsByClassName("translation-section")) {
// <label for="{{ string }}">{{ string }}</label>
// <input type="text" id="{{ string }}" name="{{ string }}" value="{{ translation }}">
// <br>
const label = document.createElement("label");
label.setAttribute("for", stringName);
label.innerText = stringName;
const input = document.createElement("input");
input.setAttribute("type", "text");
input.setAttribute("id", stringName);
input.setAttribute("name", stringName);
input.setAttribute("value", "");
const br = document.createElement("br");
section.appendChild(label);
section.appendChild(input);
section.appendChild(br);
}
});