Spaces:
Runtime error
Runtime error
updated code UI ✅✅
Browse files726 unmodified lines727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791726 unmodified linesoutputs=[end_consultation_status])# JavaScript for appointment ID auto-population (as in working_hugging_face_code.py)gr.HTML("""<script>function getUrlParameter(name) {name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');var results = regex.exec(window.location.search);return results === null ? '' : decodeURIComponent(results[1].replace(/\\+/g, ' '));}function setAppointmentIdValue(val) {// Try by ID (Gradio 3.x and some 4.x)var input = document.getElementById('appointment_id_input');if (input) {input.value = val;input.dispatchEvent(new Event('input', { bubbles: true }));return true;}// Try Gradio 4.x shadow DOMvar gradioApp = document.querySelector('gradio-app') || document.querySelector('body');if (gradioApp) {// Find textbox by labelvar labels = gradioApp.querySelectorAll('label');for (var i = 0; i < labels.length; i++) {if (labels[i].textContent.trim().toLowerCase().includes('appointment id')) {// Find the input in the same parentvar parent = labels[i].parentElement;var textbox = parent.querySelector('input[type="text"], textarea');if (textbox) {textbox.value = val;textbox.dispatchEvent(new Event('input', { bubbles: true }));return true;}}}}// Try all textboxes for fallbackvar allInputs = document.querySelectorAll('input[type="text"], textarea');for (var i = 0; i < allInputs.length; i++) {if (allInputs[i].placeholder && allInputs[i].placeholder.toLowerCase().includes('appointment id')) {allInputs[i].value = val;allInputs[i].dispatchEvent(new Event('input', { bubbles: true }));return true;}}return false;}function tryPopulateAppointmentId() {var appointmentId = getUrlParameter('appointment_id');if (appointmentId) {setAppointmentIdValue(appointmentId);}}document.addEventListener('DOMContentLoaded', function() {setTimeout(tryPopulateAppointmentId, 400);});window.addEventListener('load', function() {setTimeout(tryPopulateAppointmentId, 1000);});setTimeout(tryPopulateAppointmentId, 2000);</script>""")726 unmodified lines727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815726 unmodified linesoutputs=[end_consultation_status])# --- FIXED: Improved JavaScript for appointment ID auto-population ---# This script will robustly set the value of the Gradio textbox, even in Gradio 4.x shadow DOM.gr.HTML("""<script>(function() {function getUrlParameter(name) {name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');var results = regex.exec(window.location.search);return results === null ? '' : decodeURIComponent(results[1].replace(/\\+/g, ' '));}function setAppointmentIdValue(val) {// Try by element id (Gradio 3.x and some 4.x)var input = document.getElementById('appointment_id_input');if (input) {input.value = val;input.dispatchEvent(new Event('input', { bubbles: true }));input.dispatchEvent(new Event('change', { bubbles: true }));return true;}// Try Gradio 4.x shadow DOMvar gradioApp = document.querySelector('gradio-app');if (gradioApp && gradioApp.shadowRoot) {// Try to find textbox by label textvar labels = gradioApp.shadowRoot.querySelectorAll('label');for (var i = 0; i < labels.length; i++) {if (labels[i].textContent.trim().toLowerCase().includes('appointment id')) {// Find the input in the same parentvar parent = labels[i].parentElement;var textbox = parent.querySelector('input[type="text"], textarea');if (textbox) {textbox.value = val;textbox.dispatchEvent(new Event('input', { bubbles: true }));textbox.dispatchEvent(new Event('change', { bubbles: true }));return true;}}}// Fallback: try all textboxes in shadowRootvar allInputs = gradioApp.shadowRoot.querySelectorAll('input[type="text"], textarea');for (var i = 0; i < allInputs.length; i++) {if (allInputs[i].placeholder && allInputs[i].placeholder.toLowerCase().includes('appointment id')) {allInputs[i].value = val;allInputs[i].dispatchEvent(new Event('input', { bubbles: true }));allInputs[i].dispatchEvent(new Event('change', { bubbles: true }));return true;}}}// Try all textboxes for fallback (outside shadow DOM)var allInputs = document.querySelectorAll('input[type="text"], textarea');for (var i = 0; i < allInputs.length; i++) {if (allInputs[i].placeholder && allInputs[i].placeholder.toLowerCase().includes('appointment id')) {allInputs[i].value = val;allInputs[i].dispatchEvent(new Event('input', { bubbles: true }));allInputs[i].dispatchEvent(new Event('change', { bubbles: true }));return true;}}return false;}function tryPopulateAppointmentId() {var appointmentId = getUrlParameter('appointment_id');if (appointmentId) {setAppointmentIdValue(appointmentId);}}// Try multiple times and on different events for robustnessdocument.addEventListener('DOMContentLoaded', function() {setTimeout(tryPopulateAppointmentId, 200);setTimeout(tryPopulateAppointmentId, 800);});window.addEventListener('load', function() {setTimeout(tryPopulateAppointmentId, 1200);});// Also try periodically for 3 secondsfor (let t = 0; t <= 3000; t += 400) {setTimeout(tryPopulateAppointmentId, t);}})();</script>""")
mediSync/app.py+72-48