File size: 2,257 Bytes
f555b43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
var settingsHintsSetup = false;

onOptionsChanged(function() {
    if (settingsHintsSetup) return;
    settingsHintsSetup = true;

    gradioApp().querySelectorAll('#settings [id^=setting_]').forEach(function(div) {
        var name = div.id.substr(8);
        var commentBefore = opts._comments_before[name];
        var commentAfter = opts._comments_after[name];

        if (!commentBefore && !commentAfter) return;

        var span = null;
        if (div.classList.contains('gradio-checkbox')) span = div.querySelector('label span');
        else if (div.classList.contains('gradio-checkboxgroup')) span = div.querySelector('span').firstChild;
        else if (div.classList.contains('gradio-radio')) span = div.querySelector('span').firstChild;
        else span = div.querySelector('label span').firstChild;

        if (!span) return;

        if (commentBefore) {
            var comment = document.createElement('DIV');
            comment.className = 'settings-comment';
            comment.innerHTML = commentBefore;
            span.parentElement.insertBefore(document.createTextNode('\xa0'), span);
            span.parentElement.insertBefore(comment, span);
            span.parentElement.insertBefore(document.createTextNode('\xa0'), span);
        }
        if (commentAfter) {
            comment = document.createElement('DIV');
            comment.className = 'settings-comment';
            comment.innerHTML = commentAfter;
            span.parentElement.insertBefore(comment, span.nextSibling);
            span.parentElement.insertBefore(document.createTextNode('\xa0'), span.nextSibling);
        }
    });
});

function settingsHintsShowQuicksettings() {
    requestGet("./internal/quicksettings-hint", {}, function(data) {
        var table = document.createElement('table');
        table.className = 'popup-table';

        data.forEach(function(obj) {
            var tr = document.createElement('tr');
            var td = document.createElement('td');
            td.textContent = obj.name;
            tr.appendChild(td);

            td = document.createElement('td');
            td.textContent = obj.label;
            tr.appendChild(td);

            table.appendChild(tr);
        });

        popup(table);
    });
}