summaryrefslogtreecommitdiff
path: root/js/lmmtfy.js
blob: 0f9951d5532cb50884e3fd14ab2064cdbae68541 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright (C) 2024 dwlr <dweller@cabin.digital>
 *
 * BSD 3-Clause License (BSD-3-Clause)
 * See LICENSE for details
 */


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 dom_opts  = document.getElementById("query_opts_toggle");

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;
let actions =
[
    [250, () => { dom_query.focus(); }, 1],
    [150, () => { dom_query.value += query[j++]; }, query.length],

    [100, () => { dom_opts.focus(); }, 1],
    [100, () => { dom_opts.click(); }, 1],

    [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],
];

function do_stuff()
{
    elapsed += 50;

    if((elapsed % actions[i][0]) == 0)
    {
        actions[i][1]();
        actions[i][2]--;
        if(actions[i][2] <= 0) i++;
    }

    setTimeout(do_stuff, 50);
}

do_stuff();