From 2eb5f103ab1b41477440cc391165ea7ef5f7f959 Mon Sep 17 00:00:00 2001 From: apolinario Date: Mon, 5 Dec 2022 16:30:15 +0100 Subject: Fix WebUI not working inside of iframes --- script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'script.js') diff --git a/script.js b/script.js index 8b3b67e3..d9424de9 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,5 @@ function gradioApp(){ - return document.getElementsByTagName('gradio-app')[0].shadowRoot; + return document } function get_uiCurrentTab() { @@ -82,4 +82,4 @@ function uiElementIsVisible(el) { } } return isVisible; -} \ No newline at end of file +} -- cgit v1.2.3 From 1075819b16ef328805dd946acaffd43efa2eb444 Mon Sep 17 00:00:00 2001 From: apolinario Date: Tue, 6 Dec 2022 15:13:41 +0100 Subject: Use shadowRoot if inside of an iframe and don't use it if outside This makes sure it will work everywhere --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'script.js') diff --git a/script.js b/script.js index d9424de9..49b6c557 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,5 @@ function gradioApp(){ - return document + return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document } function get_uiCurrentTab() { -- cgit v1.2.3 From 8eb638cdd3d08ad6e9373569fd81d0a6e8a63f16 Mon Sep 17 00:00:00 2001 From: apolinario Date: Tue, 6 Dec 2022 15:14:22 +0100 Subject: style change --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'script.js') diff --git a/script.js b/script.js index 49b6c557..1c8fcbf1 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,5 @@ function gradioApp(){ - return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document + return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document; } function get_uiCurrentTab() { -- cgit v1.2.3 From 37139d8aac10bd13758f52e3d361f3d017c4ad46 Mon Sep 17 00:00:00 2001 From: apolinario Date: Sat, 10 Dec 2022 12:51:40 +0100 Subject: No code repeat --- script.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'script.js') diff --git a/script.js b/script.js index 1c8fcbf1..9748ec90 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,6 @@ -function gradioApp(){ - return !!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document; +function gradioApp() { + const gradioShadowRoot = document.getElementsByTagName('gradio-app')[0].shadowRoot + return !!gradioShadowRoot ? gradioShadowRoot : document; } function get_uiCurrentTab() { -- cgit v1.2.3 From 4fc81542077af73610279ad7b6b26e38718a0f81 Mon Sep 17 00:00:00 2001 From: Gerschel Date: Tue, 3 Jan 2023 23:25:34 -0800 Subject: better targetting, class tabs was autoassigned I moved a preset manager into quicksettings, this function was targeting my component instead of the tabs. This is because class tabs is autoassigned, while element id #tabs is not, this allows a tabbed component to live in the quicksettings. --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'script.js') diff --git a/script.js b/script.js index 9748ec90..0e117d06 100644 --- a/script.js +++ b/script.js @@ -4,7 +4,7 @@ function gradioApp() { } function get_uiCurrentTab() { - return gradioApp().querySelector('.tabs button:not(.border-transparent)') + return gradioApp().querySelector('#tabs button:not(.border-transparent)') } function get_uiCurrentTabContent() { -- cgit v1.2.3 From 6ffefdcc9f47b66cbc543690d97cbf8327f4ba58 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 12 Jan 2023 19:47:44 +0300 Subject: fix js errors when restarting UI --- script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'script.js') diff --git a/script.js b/script.js index 0e117d06..21960d91 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,6 @@ function gradioApp() { - const gradioShadowRoot = document.getElementsByTagName('gradio-app')[0].shadowRoot + const elems = document.getElementsByTagName('gradio-app') + const gradioShadowRoot = elems.length == 0 ? null : elems[0].shadowRoot return !!gradioShadowRoot ? gradioShadowRoot : document; } -- cgit v1.2.3