File size: 1,256 Bytes
8a5e8bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

var academic_chat = null;

var sliders = null;
var rangeInputs = null;
var numberInputs = null;

function set_elements() {
    academic_chat = document.querySelector('gradio-app');
    async function get_sliders() {
        sliders = document.querySelectorAll('input[type="range"]');
        while (sliders.length == 0) {
            await new Promise(r => setTimeout(r, 100));
            sliders = document.querySelectorAll('input[type="range"]');
        }
        setSlider();
    }
    get_sliders();
}

function setSlider() {
    rangeInputs = document.querySelectorAll('input[type="range"]');
    numberInputs = document.querySelectorAll('input[type="number"]')
    function setSliderRange() {
        var range = document.querySelectorAll('input[type="range"]');
        range.forEach(range => {
            range.style.backgroundSize = (range.value - range.min) / (range.max - range.min) * 100 + '% 100%';
        });
    }
    setSliderRange();
    rangeInputs.forEach(rangeInput => {
        rangeInput.addEventListener('input', setSliderRange);
    });
    numberInputs.forEach(numberInput => {
        numberInput.addEventListener('input', setSliderRange);
    })
}

window.addEventListener("DOMContentLoaded", () => {
    set_elements();
});