From aaf9688d1ad81255e5e5479d1108dcf369950fd1 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 27 Oct 2024 00:36:08 +0200 Subject: [PATCH] playing around with html css js --- playground/html/root/cangrow.js | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 playground/html/root/cangrow.js diff --git a/playground/html/root/cangrow.js b/playground/html/root/cangrow.js new file mode 100644 index 0000000..becf034 --- /dev/null +++ b/playground/html/root/cangrow.js @@ -0,0 +1,35 @@ +function toggleDisplay(id) { + let el = document.getElementById(id); + let el_cs = getComputedStyle(el); + + if (el_cs.getPropertyValue('display') === 'none') { + el.style.display = 'inline'; + } else { + el.style.display = 'none'; + } +} + +function hideAllClass(classname) { + + const el = document.getElementsByClassName(classname); + + for(let i = 0; i < el.length ; i++) { + el[i].style.display = ''; + } +} + +function showSelect(selectId, prefix, hideClass = '') { + if(hideClass != '') { + hideAllClass(hideClass); + } + + let selVal = document.getElementById(selectId).value; + toggleId = prefix + selVal; + if(document.getElementById(toggleId) !== null ) { + toggleDisplay(toggleId); + } +} + +function confirmDelete(name) { + return confirm('Delete ' + name + '?'); +}