/* * Copyright (C) 2024 dwlr * * BSD 3-Clause License (BSD-3-Clause) * See LICENSE for details */ let min_width = 20; 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')); let txt = e.options[e.selectedIndex].text; tmp.style.fontSize = font_sz + "px"; tmp.innerHTML = txt + '#'; let tmp_width = parseFloat(window.getComputedStyle(tmp, null).width); let width = (min_width + tmp_width) + "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]); }