blob: ba887878f6857c8bbf0daeb78ebf9ea7407fc657 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
* Copyright (C) 2024 dwlr <dweller@cabin.digital>
*
* BSD 3-Clause License (BSD-3-Clause)
* See LICENSE for details
*/
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]);
}
|