summaryrefslogtreecommitdiff
path: root/js/query_opts.js
diff options
context:
space:
mode:
authordweller <dweller@cabin.digital>2024-02-27 20:48:15 +0200
committerdweller <dweller@cabin.digital>2024-02-27 20:48:15 +0200
commit2a66021e508fe2ff6912e6e6578eaf035e1ffdd8 (patch)
tree6a2066ac5a617ef3b02798e1e27d89d5368889fb /js/query_opts.js
parentcd0894ddefbc9c0be2d59b9160fc911e16b67bd2 (diff)
add section and arch dropdowns, wow that was a pain
Diffstat (limited to 'js/query_opts.js')
-rw-r--r--js/query_opts.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/query_opts.js b/js/query_opts.js
new file mode 100644
index 0000000..f81ee0c
--- /dev/null
+++ b/js/query_opts.js
@@ -0,0 +1,27 @@
+const min_width = 20;
+const rpad = 15;
+
+const tmp = document.getElementById('js_tmp');
+const opts = new Array(document.getElementById('sect'),
+ document.getElementById('arch'));
+
+function fix_width(e)
+{
+ let style = window.getComputedStyle(e, null);
+ let font_sz = parseFloat(style.getPropertyValue('font-size'));
+
+ tmp.style.fontSize = font_sz + "px";
+ tmp.innerHTML = e.options[e.selectedIndex].text;
+
+ let tmp_width = parseFloat(window.getComputedStyle(tmp, null).width);
+ let width = (min_width + tmp_width + (tmp_width > 0 ? rpad : 0)) + "px";
+
+ e.style.width = width;
+}
+
+for(let i=0; i < opts.length; i++)
+{
+ opts[i].addEventListener("change", (ev) => { fix_width(opts[i]); });
+ fix_width(opts[i]);
+}
+