| | |
| | |
| | |
| | |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_children_config_class(elBase, idSelected, classSelected, classUnSelected="") { |
| | for(let child of elBase.children) { |
| | if (child.id == idSelected) { |
| | child.className = classSelected; |
| | } else { |
| | child.className = classUnSelected; |
| | } |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_create_button(id, callback, name=undefined, innerText=undefined) { |
| | if (!name) { |
| | name = id; |
| | } |
| | if (!innerText) { |
| | innerText = id; |
| | } |
| | let btn = document.createElement("button"); |
| | btn.id = id; |
| | btn.name = name; |
| | btn.innerText = innerText; |
| | btn.addEventListener("click", callback); |
| | return btn; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_create_append_p(text, elParent=undefined, id=undefined) { |
| | let para = document.createElement("p"); |
| | para.innerText = text; |
| | if (id) { |
| | para.id = id; |
| | } |
| | if (elParent) { |
| | elParent.appendChild(para); |
| | } |
| | return para; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_create_boolbutton(id, texts, defaultValue, cb) { |
| | let el = document.createElement("button"); |
| | el["xbool"] = defaultValue; |
| | el["xtexts"] = structuredClone(texts); |
| | el.innerText = el["xtexts"][String(defaultValue)]; |
| | if (id) { |
| | el.id = id; |
| | } |
| | el.addEventListener('click', (ev)=>{ |
| | el["xbool"] = !el["xbool"]; |
| | el.innerText = el["xtexts"][String(el["xbool"])]; |
| | cb(el["xbool"]); |
| | }) |
| | return el; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_creatediv_boolbutton(id, label, texts, defaultValue, cb, className="gridx2") { |
| | let div = document.createElement("div"); |
| | div.className = className; |
| | let lbl = document.createElement("label"); |
| | lbl.setAttribute("for", id); |
| | lbl.innerText = label; |
| | div.appendChild(lbl); |
| | let btn = el_create_boolbutton(id, texts, defaultValue, cb); |
| | div.appendChild(btn); |
| | return { div: div, el: btn }; |
| | } |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_create_select(id, options, defaultOption, cb) { |
| | let el = document.createElement("select"); |
| | el["xselected"] = defaultOption; |
| | el["xoptions"] = structuredClone(options); |
| | for(let cur of Object.keys(options)) { |
| | let op = document.createElement("option"); |
| | op.value = cur; |
| | op.innerText = cur; |
| | if (options[cur] == defaultOption) { |
| | op.selected = true; |
| | } |
| | el.appendChild(op); |
| | } |
| | if (id) { |
| | el.id = id; |
| | el.name = id; |
| | } |
| | el.addEventListener('change', (ev)=>{ |
| | let target = (ev.target); |
| | console.log("DBUG:UI:Select:", id, ":", target.value); |
| | cb(target.value); |
| | }) |
| | return el; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_creatediv_select(id, label, options, defaultOption, cb, className="gridx2") { |
| | let div = document.createElement("div"); |
| | div.className = className; |
| | let lbl = document.createElement("label"); |
| | lbl.setAttribute("for", id); |
| | lbl.innerText = label; |
| | div.appendChild(lbl); |
| | let sel = el_create_select(id, options,defaultOption, cb); |
| | div.appendChild(sel); |
| | return { div: div, el: sel }; |
| | } |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_create_input(id, type, defaultValue, cb) { |
| | let el = document.createElement("input"); |
| | el.type = type; |
| | el.value = defaultValue; |
| | if (id) { |
| | el.id = id; |
| | } |
| | el.addEventListener('change', (ev)=>{ |
| | cb(el.value); |
| | }) |
| | return el; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function el_creatediv_input(id, label, type, defaultValue, cb, className="gridx2") { |
| | let div = document.createElement("div"); |
| | div.className = className; |
| | let lbl = document.createElement("label"); |
| | lbl.setAttribute("for", id); |
| | lbl.innerText = label; |
| | div.appendChild(lbl); |
| | let el = el_create_input(id, type, defaultValue, cb); |
| | div.appendChild(el); |
| | return { div: div, el: el }; |
| | } |
| |
|