workaround because chrome doesn't support onclick in select options

This commit is contained in:
lenovo
2022-11-14 13:42:18 +01:00
parent 49daf21ae6
commit 48e1572957
8 changed files with 46 additions and 37 deletions

View File

@@ -77,12 +77,9 @@ function filter_selection_indexes(menu, indexes, reverse, add) {
function is_element_unchecked(element) {
if (typeof(element) === "undefined")
return false;
if (typeof(element.attributes) === "undefined")
if (typeof(element.type) === "undefined")
return false;
if (typeof(element.attributes.type) === "undefined")
return false;
value = element.attributes.type.value;
if (value === "checkbox") {
if (element.type === "checkbox") {
return ! element.checked;
}
return false;
@@ -96,6 +93,17 @@ function is_element_unchecked(element) {
function filter_show_only_selection(element, indexes, menu, add = false, zoom_in = true) {
// temp solution because we can't actually put onclick event inside select options
// on chrome, so I have to recover the indexes another way
if (element.type == "select-one") {
if (element.value == menu)
indexes = [];
else {
indexes = element.children[element.selectedIndex].title;
indexes = JSON.parse(indexes);
}
}
let reverse = is_element_unchecked(element);
let index_array = filter_selection_indexes(menu, indexes, reverse, add);