Spaces:
PAIR
/
Running on A10G

File size: 1,390 Bytes
bfd34e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
function demo_load(x) {
    document.body.scrollTop = document.documentElement.scrollTop = 0;

    function gradioApp() {
        const elems = document.getElementsByTagName('gradio-app');
        const elem = elems.length == 0 ? document : elems[0];
    
        if (elem !== document) {
            elem.getElementById = function(id) {
                return document.getElementById(id);
            };
        }
        return elem.shadowRoot ? elem.shadowRoot : elem;
    }

    function all_gallery_buttons() {
        var allGalleryButtons = gradioApp().querySelectorAll('#outputgallery .thumbnail-item.thumbnail-small');
        var visibleGalleryButtons = [];
        allGalleryButtons.forEach(function(elem) {
            if (elem.parentElement.offsetParent) {
                visibleGalleryButtons.push(elem);
            }
        });
        return visibleGalleryButtons;
    }
    
    function selected_gallery_button() {
        return all_gallery_buttons().find(elem => elem.classList.contains('selected')) ?? null;
    }
    
    function selected_gallery_index() {
        return all_gallery_buttons().findIndex(elem => elem.classList.contains('selected'));
    }

    window.gradioApp = gradioApp
    window.all_gallery_buttons = all_gallery_buttons
    window.selected_gallery_button = selected_gallery_button
    window.selected_gallery_index = selected_gallery_index
}