summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/lmmtfy.js18
-rw-r--r--js/query_opts.js27
2 files changed, 45 insertions, 0 deletions
diff --git a/js/lmmtfy.js b/js/lmmtfy.js
index a029c8f..2c5a642 100644
--- a/js/lmmtfy.js
+++ b/js/lmmtfy.js
@@ -8,10 +8,19 @@
const dom_query = document.getElementById("query");
const dom_sect = document.getElementById("sect");
+const dom_arch = document.getElementById("arch");
const dom_man = document.getElementById("man");
const query = dom_query.value;
+const sect = dom_sect.value;
+const arch = dom_arch.value;
+
dom_query.value = "";
+dom_sect.value = "";
+dom_arch.value = "";
+
+fix_width(dom_sect);
+fix_width(dom_arch);
let i = 0, j = 0;
let elapsed = 0;
@@ -19,6 +28,15 @@ let actions =
[
[250, () => { dom_query.focus(); }, 1],
[150, () => { dom_query.value += query[j++]; }, query.length],
+
+ [100, () => { dom_sect.focus(); }, 1],
+ [100, () => { dom_sect.value = sect; }, 1],
+ [100, () => { fix_width(dom_sect); }, 1],
+
+ [100, () => { dom_arch.focus(); }, 1],
+ [100, () => { dom_arch.value = arch; }, 1],
+ [100, () => { fix_width(dom_arch); }, 1],
+
[250, () => { dom_man.focus(); }, 1],
[250, () => { dom_man.click(); }, 1],
];
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]);
+}
+