add handling to some places in javascript that can potentially cause issues #6898

This commit is contained in:
AUTOMATIC 2023-01-19 15:58:32 +03:00
parent 79d802b48a
commit c12d7ddd72
2 changed files with 13 additions and 6 deletions

View file

@ -93,10 +93,12 @@ function checkBrackets(evt) {
}
var shadowRootLoaded = setInterval(function() {
var shadowTextArea = document.querySelector('gradio-app').shadowRoot.querySelectorAll('#txt2img_prompt > label > textarea');
if(shadowTextArea.length < 1) {
return false;
}
var sahdowRoot = document.querySelector('gradio-app').shadowRoot;
if(! sahdowRoot) return false;
var shadowTextArea = sahdowRoot.querySelectorAll('#txt2img_prompt > label > textarea');
if(shadowTextArea.length < 1) return false;
clearInterval(shadowRootLoaded);

View file

@ -81,8 +81,13 @@ function request(url, data, handler, errorHandler){
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
try {
var js = JSON.parse(xhr.responseText);
handler(js)
} catch (error) {
console.error(error);
errorHandler()
}
} else{
errorHandler()
}