New editor written in Python dialect
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.9 KiB

from browser import document
def generic_list_getter():
result = []
for input_el in document.getElementsByClassName("list-adder-input"):
result_candidate = input_el.value
if result_candidate != "":
return result
# Formats data from inputs to name-value objects
def double_list_getter(firstParameter, secondParameter, allowEmptyField = False):
result = []
for row in document.getElementsByClassName("double-list-row"):
firstValue = row.querySelector("." + firstParameter + "-input").value
secondValue = row.querySelector("." + secondParameter + "-input").value
if (allowEmptyField is False and '' in [firstValue, secondValue]):
if (allowEmptyField is True and all('' == value or value.isspace() for value in [firstValue, secondValue])):
result.append({firstParameter: firstValue, secondParameter: secondValue})
return result
def definitions_getter():
result = {}
result["indicator"] = document.getElementById("indicator-input").value
result["explanation"] = document.getElementById("explanation-input").value
return result
def label_list_getter():
result = []
for row in document.getElementsByClassName("label-list-row"):
ltype = row.querySelector(".label-type")
lvalue = row.querySelector(".label-value")
lother = row.querySelector(".label-value-other")
if lother is None:
value = lother.value
if not value:
value = lvalue.options[lvalue.selectedIndex].text
if not value:
result.append((ltype.textContent, value))
kontrastivno = document.getElementById("kontrastivno-input").checked;
if kontrastivno:
result.append(("razmerje", "kontrastivno"))
return result