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 }