2019-11-16 13:59:23 +00:00
|
|
|
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 != "":
|
|
|
|
result.append(result_candidate)
|
|
|
|
return result
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2020-07-16 10:46:48 +00:00
|
|
|
# Formats data from inputs to name-value objects
|
2020-08-07 08:34:47 +00:00
|
|
|
def double_list_getter(firstParameter, secondParameter, allowEmptyField = False):
|
2020-07-16 10:22:54 +00:00
|
|
|
result = []
|
2020-08-06 10:47:52 +00:00
|
|
|
for row in document.getElementsByClassName("double-list-row"):
|
|
|
|
firstValue = row.querySelector("." + firstParameter + "-input").value
|
|
|
|
secondValue = row.querySelector("." + secondParameter + "-input").value
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2020-08-07 08:34:47 +00:00
|
|
|
if (allowEmptyField is False and '' in [firstValue, secondValue]):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if (allowEmptyField is True and all('' == value or value.isspace() for value in [firstValue, secondValue])):
|
2020-07-16 10:22:54 +00:00
|
|
|
continue
|
|
|
|
|
2020-08-06 10:47:52 +00:00
|
|
|
result.append({firstParameter: firstValue, secondParameter: secondValue})
|
2020-07-16 10:22:54 +00:00
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2019-11-17 20:33:58 +00:00
|
|
|
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")
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2020-03-19 20:02:53 +00:00
|
|
|
if lother is None:
|
|
|
|
continue
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2019-11-17 20:33:58 +00:00
|
|
|
value = lother.value
|
|
|
|
if not value:
|
2020-07-16 10:22:54 +00:00
|
|
|
value = lvalue.options[lvalue.selectedIndex].text
|
|
|
|
|
2019-11-17 20:33:58 +00:00
|
|
|
if not value:
|
|
|
|
continue
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2019-11-17 20:33:58 +00:00
|
|
|
result.append((ltype.textContent, value))
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2020-03-19 20:02:53 +00:00
|
|
|
kontrastivno = document.getElementById("kontrastivno-input").checked;
|
|
|
|
if kontrastivno:
|
2020-03-20 17:34:19 +00:00
|
|
|
result.append(("razmerje", "kontrastivno"))
|
2020-07-16 10:22:54 +00:00
|
|
|
|
2019-11-17 20:33:58 +00:00
|
|
|
return result
|