1jQuery(function (){
2    if(!JSINFO['plugins']) return;
3    if(!JSINFO.plugins['lms']) return;
4
5    if (JSINFO.ACT !== 'admin') {
6        jQuery('a.wikilink1, a.wikilink2').each(function (idx, elem){
7
8            if(elem['title'] && JSINFO.plugins.lms.seen.includes(elem.title)) {
9                jQuery(elem).addClass('lms-seen');
10            }
11
12        });
13    }
14
15    // mark whole sections seen
16    const navheaders = jQuery('nav div.content h1, nav div.content h2, nav div.content h3, nav div.content h4, nav div.content h5');
17    navheaders.each(function (idx, header) {
18        const $list = jQuery(jQuery(header).next()[0]).find('ul');
19        if ($list.length) {
20            if ($list.find('a').length === $list.find('a.lms-seen').length) {
21                jQuery(header).addClass('lms-seen');
22            }
23        }
24    });
25
26    /**
27     * admin interface: autocomplete users
28     */
29    const $form = jQuery('.dokuwiki.mode_admin form#lms__admin-autocomplete');
30    if (!$form.length) return;
31
32    $form.find('input')
33        .autocomplete({
34            source: function (request, response) {
35                jQuery.getJSON(DOKU_BASE + 'lib/exe/ajax.php?call=plugin_lms_autocomplete', {
36                    user: request.term,
37                    sectok: $form.find('input[name="sectok"]').val()
38                }, response);
39            },
40            minLength: 0
41        });
42});
43