From 9c54b78d9dde5601e916f308d9a9d6953ec39430 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 17 May 2023 15:46:58 +0300 Subject: Run `eslint --fix` (and normalize tabs to spaces) --- javascript/imageviewer.js | 221 +++++++++++++++++++++++----------------------- 1 file changed, 111 insertions(+), 110 deletions(-) (limited to 'javascript/imageviewer.js') diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js index 32066ab8..ecd12379 100644 --- a/javascript/imageviewer.js +++ b/javascript/imageviewer.js @@ -5,24 +5,24 @@ function closeModal() { function showModal(event) { const source = event.target || event.srcElement; - const modalImage = gradioApp().getElementById("modalImage") - const lb = gradioApp().getElementById("lightboxModal") - modalImage.src = source.src + const modalImage = gradioApp().getElementById("modalImage"); + const lb = gradioApp().getElementById("lightboxModal"); + modalImage.src = source.src; if (modalImage.style.display === 'none') { lb.style.setProperty('background-image', 'url(' + source.src + ')'); } lb.style.display = "flex"; - lb.focus() + lb.focus(); - const tabTxt2Img = gradioApp().getElementById("tab_txt2img") - const tabImg2Img = gradioApp().getElementById("tab_img2img") + const tabTxt2Img = gradioApp().getElementById("tab_txt2img"); + const tabImg2Img = gradioApp().getElementById("tab_img2img"); // show the save button in modal only on txt2img or img2img tabs if (tabTxt2Img.style.display != "none" || tabImg2Img.style.display != "none") { - gradioApp().getElementById("modal_save").style.display = "inline" + gradioApp().getElementById("modal_save").style.display = "inline"; } else { - gradioApp().getElementById("modal_save").style.display = "none" + gradioApp().getElementById("modal_save").style.display = "none"; } - event.stopPropagation() + event.stopPropagation(); } function negmod(n, m) { @@ -30,14 +30,14 @@ function negmod(n, m) { } function updateOnBackgroundChange() { - const modalImage = gradioApp().getElementById("modalImage") + const modalImage = gradioApp().getElementById("modalImage"); if (modalImage && modalImage.offsetParent) { let currentButton = selected_gallery_button(); if (currentButton?.children?.length > 0 && modalImage.src != currentButton.children[0].src) { modalImage.src = currentButton.children[0].src; if (modalImage.style.display === 'none') { - modal.style.setProperty('background-image', `url(${modalImage.src})`) + modal.style.setProperty('background-image', `url(${modalImage.src})`); } } } @@ -49,108 +49,109 @@ function modalImageSwitch(offset) { if (galleryButtons.length > 1) { var currentButton = selected_gallery_button(); - var result = -1 + var result = -1; galleryButtons.forEach(function(v, i) { if (v == currentButton) { - result = i + result = i; } - }) + }); if (result != -1) { - var nextButton = galleryButtons[negmod((result + offset), galleryButtons.length)] - nextButton.click() + var nextButton = galleryButtons[negmod((result + offset), galleryButtons.length)]; + nextButton.click(); const modalImage = gradioApp().getElementById("modalImage"); const modal = gradioApp().getElementById("lightboxModal"); modalImage.src = nextButton.children[0].src; if (modalImage.style.display === 'none') { - modal.style.setProperty('background-image', `url(${modalImage.src})`) + modal.style.setProperty('background-image', `url(${modalImage.src})`); } setTimeout(function() { - modal.focus() - }, 10) + modal.focus(); + }, 10); } } } -function saveImage(){ - const tabTxt2Img = gradioApp().getElementById("tab_txt2img") - const tabImg2Img = gradioApp().getElementById("tab_img2img") - const saveTxt2Img = "save_txt2img" - const saveImg2Img = "save_img2img" +function saveImage() { + const tabTxt2Img = gradioApp().getElementById("tab_txt2img"); + const tabImg2Img = gradioApp().getElementById("tab_img2img"); + const saveTxt2Img = "save_txt2img"; + const saveImg2Img = "save_img2img"; if (tabTxt2Img.style.display != "none") { - gradioApp().getElementById(saveTxt2Img).click() + gradioApp().getElementById(saveTxt2Img).click(); } else if (tabImg2Img.style.display != "none") { - gradioApp().getElementById(saveImg2Img).click() + gradioApp().getElementById(saveImg2Img).click(); } else { - console.error("missing implementation for saving modal of this type") + console.error("missing implementation for saving modal of this type"); } } function modalSaveImage(event) { - saveImage() - event.stopPropagation() + saveImage(); + event.stopPropagation(); } function modalNextImage(event) { - modalImageSwitch(1) - event.stopPropagation() + modalImageSwitch(1); + event.stopPropagation(); } function modalPrevImage(event) { - modalImageSwitch(-1) - event.stopPropagation() + modalImageSwitch(-1); + event.stopPropagation(); } function modalKeyHandler(event) { switch (event.key) { - case "s": - saveImage() - break; - case "ArrowLeft": - modalPrevImage(event) - break; - case "ArrowRight": - modalNextImage(event) - break; - case "Escape": - closeModal(); - break; + case "s": + saveImage(); + break; + case "ArrowLeft": + modalPrevImage(event); + break; + case "ArrowRight": + modalNextImage(event); + break; + case "Escape": + closeModal(); + break; } } function setupImageForLightbox(e) { - if (e.dataset.modded) - return; + if (e.dataset.modded) { + return; + } - e.dataset.modded = true; - e.style.cursor='pointer' - e.style.userSelect='none' + e.dataset.modded = true; + e.style.cursor = 'pointer'; + e.style.userSelect = 'none'; - var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1 + var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; - // For Firefox, listening on click first switched to next image then shows the lightbox. - // If you know how to fix this without switching to mousedown event, please. - // For other browsers the event is click to make it possiblr to drag picture. - var event = isFirefox ? 'mousedown' : 'click' + // For Firefox, listening on click first switched to next image then shows the lightbox. + // If you know how to fix this without switching to mousedown event, please. + // For other browsers the event is click to make it possiblr to drag picture. + var event = isFirefox ? 'mousedown' : 'click'; - e.addEventListener(event, function (evt) { - if(!opts.js_modal_lightbox || evt.button != 0) return; + e.addEventListener(event, function(evt) { + if (!opts.js_modal_lightbox || evt.button != 0) return; - modalZoomSet(gradioApp().getElementById('modalImage'), opts.js_modal_lightbox_initially_zoomed) - evt.preventDefault() - showModal(evt) - }, true); + modalZoomSet(gradioApp().getElementById('modalImage'), opts.js_modal_lightbox_initially_zoomed); + evt.preventDefault(); + showModal(evt); + }, true); } function modalZoomSet(modalImage, enable) { - if(modalImage) modalImage.classList.toggle('modalImageFullscreen', !!enable); + if (modalImage) modalImage.classList.toggle('modalImageFullscreen', !!enable); } function modalZoomToggle(event) { var modalImage = gradioApp().getElementById("modalImage"); - modalZoomSet(modalImage, !modalImage.classList.contains('modalImageFullscreen')) - event.stopPropagation() + modalZoomSet(modalImage, !modalImage.classList.contains('modalImageFullscreen')); + event.stopPropagation(); } function modalTileImageToggle(event) { @@ -159,99 +160,99 @@ function modalTileImageToggle(event) { const isTiling = modalImage.style.display === 'none'; if (isTiling) { modalImage.style.display = 'block'; - modal.style.setProperty('background-image', 'none') + modal.style.setProperty('background-image', 'none'); } else { modalImage.style.display = 'none'; - modal.style.setProperty('background-image', `url(${modalImage.src})`) + modal.style.setProperty('background-image', `url(${modalImage.src})`); } - event.stopPropagation() + event.stopPropagation(); } function galleryImageHandler(e) { //if (e && e.parentElement.tagName == 'BUTTON') { - e.onclick = showGalleryImage; + e.onclick = showGalleryImage; //} } onUiUpdate(function() { - var fullImg_preview = gradioApp().querySelectorAll('.gradio-gallery > div > img') + var fullImg_preview = gradioApp().querySelectorAll('.gradio-gallery > div > img'); if (fullImg_preview != null) { fullImg_preview.forEach(setupImageForLightbox); } updateOnBackgroundChange(); -}) +}); document.addEventListener("DOMContentLoaded", function() { //const modalFragment = document.createDocumentFragment(); - const modal = document.createElement('div') + const modal = document.createElement('div'); modal.onclick = closeModal; modal.id = "lightboxModal"; - modal.tabIndex = 0 - modal.addEventListener('keydown', modalKeyHandler, true) + modal.tabIndex = 0; + modal.addEventListener('keydown', modalKeyHandler, true); - const modalControls = document.createElement('div') + const modalControls = document.createElement('div'); modalControls.className = 'modalControls gradio-container'; modal.append(modalControls); - const modalZoom = document.createElement('span') + const modalZoom = document.createElement('span'); modalZoom.className = 'modalZoom cursor'; - modalZoom.innerHTML = '⤡' - modalZoom.addEventListener('click', modalZoomToggle, true) + modalZoom.innerHTML = '⤡'; + modalZoom.addEventListener('click', modalZoomToggle, true); modalZoom.title = "Toggle zoomed view"; - modalControls.appendChild(modalZoom) + modalControls.appendChild(modalZoom); - const modalTileImage = document.createElement('span') + const modalTileImage = document.createElement('span'); modalTileImage.className = 'modalTileImage cursor'; - modalTileImage.innerHTML = '⊞' - modalTileImage.addEventListener('click', modalTileImageToggle, true) + modalTileImage.innerHTML = '⊞'; + modalTileImage.addEventListener('click', modalTileImageToggle, true); modalTileImage.title = "Preview tiling"; - modalControls.appendChild(modalTileImage) + modalControls.appendChild(modalTileImage); - const modalSave = document.createElement("span") - modalSave.className = "modalSave cursor" - modalSave.id = "modal_save" - modalSave.innerHTML = "🖫" - modalSave.addEventListener("click", modalSaveImage, true) - modalSave.title = "Save Image(s)" - modalControls.appendChild(modalSave) + const modalSave = document.createElement("span"); + modalSave.className = "modalSave cursor"; + modalSave.id = "modal_save"; + modalSave.innerHTML = "🖫"; + modalSave.addEventListener("click", modalSaveImage, true); + modalSave.title = "Save Image(s)"; + modalControls.appendChild(modalSave); - const modalClose = document.createElement('span') + const modalClose = document.createElement('span'); modalClose.className = 'modalClose cursor'; - modalClose.innerHTML = '×' + modalClose.innerHTML = '×'; modalClose.onclick = closeModal; modalClose.title = "Close image viewer"; - modalControls.appendChild(modalClose) + modalControls.appendChild(modalClose); - const modalImage = document.createElement('img') + const modalImage = document.createElement('img'); modalImage.id = 'modalImage'; modalImage.onclick = closeModal; - modalImage.tabIndex = 0 - modalImage.addEventListener('keydown', modalKeyHandler, true) - modal.appendChild(modalImage) + modalImage.tabIndex = 0; + modalImage.addEventListener('keydown', modalKeyHandler, true); + modal.appendChild(modalImage); - const modalPrev = document.createElement('a') + const modalPrev = document.createElement('a'); modalPrev.className = 'modalPrev'; - modalPrev.innerHTML = '❮' - modalPrev.tabIndex = 0 + modalPrev.innerHTML = '❮'; + modalPrev.tabIndex = 0; modalPrev.addEventListener('click', modalPrevImage, true); - modalPrev.addEventListener('keydown', modalKeyHandler, true) - modal.appendChild(modalPrev) + modalPrev.addEventListener('keydown', modalKeyHandler, true); + modal.appendChild(modalPrev); - const modalNext = document.createElement('a') + const modalNext = document.createElement('a'); modalNext.className = 'modalNext'; - modalNext.innerHTML = '❯' - modalNext.tabIndex = 0 + modalNext.innerHTML = '❯'; + modalNext.tabIndex = 0; modalNext.addEventListener('click', modalNextImage, true); - modalNext.addEventListener('keydown', modalKeyHandler, true) + modalNext.addEventListener('keydown', modalKeyHandler, true); - modal.appendChild(modalNext) + modal.appendChild(modalNext); try { - gradioApp().appendChild(modal); - } catch (e) { - gradioApp().body.appendChild(modal); - } + gradioApp().appendChild(modal); + } catch (e) { + gradioApp().body.appendChild(modal); + } document.body.appendChild(modal); -- cgit v1.2.3 From 57b75f4a037658c1122aa092d1775ac52036b2cf Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 18 May 2023 09:59:10 +0300 Subject: eslint related file edits --- .../javascript/prompt-bracket-checker.js | 2 +- javascript/aspectRatioOverlay.js | 14 +++++------ javascript/contextMenus.js | 10 ++++---- javascript/extraNetworks.js | 4 +-- javascript/generationParams.js | 2 +- javascript/hints.js | 4 +-- javascript/imageMaskFix.js | 1 - javascript/imageviewer.js | 7 +----- javascript/localization.js | 29 +++++++++++----------- javascript/progressbar.js | 4 +-- javascript/ui.js | 22 ++++++---------- javascript/ui_settings_hints.js | 6 ++--- script.js | 16 ++++++------ 13 files changed, 54 insertions(+), 67 deletions(-) (limited to 'javascript/imageviewer.js') diff --git a/extensions-builtin/prompt-bracket-checker/javascript/prompt-bracket-checker.js b/extensions-builtin/prompt-bracket-checker/javascript/prompt-bracket-checker.js index ed9baf9d..114cf94c 100644 --- a/extensions-builtin/prompt-bracket-checker/javascript/prompt-bracket-checker.js +++ b/extensions-builtin/prompt-bracket-checker/javascript/prompt-bracket-checker.js @@ -5,7 +5,7 @@ function checkBrackets(textArea, counterElt) { var counts = {}; - (textArea.value.match(/[(){}\[\]]/g) || []).forEach(bracket => { + (textArea.value.match(/[(){}[\]]/g) || []).forEach(bracket => { counts[bracket] = (counts[bracket] || 0) + 1; }); var errors = []; diff --git a/javascript/aspectRatioOverlay.js b/javascript/aspectRatioOverlay.js index 059338d6..1c08a1a9 100644 --- a/javascript/aspectRatioOverlay.js +++ b/javascript/aspectRatioOverlay.js @@ -50,21 +50,21 @@ function dimensionChange(e, is_width, is_height) { var scaledx = targetElement.naturalWidth * viewportscale; var scaledy = targetElement.naturalHeight * viewportscale; - var cleintRectTop = (viewportOffset.top + window.scrollY); - var cleintRectLeft = (viewportOffset.left + window.scrollX); - var cleintRectCentreY = cleintRectTop + (targetElement.clientHeight / 2); + var cleintRectTop = (viewportOffset.top + window.scrollY); + var cleintRectLeft = (viewportOffset.left + window.scrollX); + var cleintRectCentreY = cleintRectTop + (targetElement.clientHeight / 2); var cleintRectCentreX = cleintRectLeft + (targetElement.clientWidth / 2); var arscale = Math.min(scaledx / currentWidth, scaledy / currentHeight); var arscaledx = currentWidth * arscale; var arscaledy = currentHeight * arscale; - var arRectTop = cleintRectCentreY - (arscaledy / 2); - var arRectLeft = cleintRectCentreX - (arscaledx / 2); - var arRectWidth = arscaledx; + var arRectTop = cleintRectCentreY - (arscaledy / 2); + var arRectLeft = cleintRectCentreX - (arscaledx / 2); + var arRectWidth = arscaledx; var arRectHeight = arscaledy; - arPreviewRect.style.top = arRectTop + 'px'; + arPreviewRect.style.top = arRectTop + 'px'; arPreviewRect.style.left = arRectLeft + 'px'; arPreviewRect.style.width = arRectWidth + 'px'; arPreviewRect.style.height = arRectHeight + 'px'; diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index f7a15cae..f14af1d4 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -1,5 +1,5 @@ -contextMenuInit = function() { +var contextMenuInit = function() { let eventListenerApplied = false; let menuSpecs = new Map(); @@ -126,10 +126,10 @@ contextMenuInit = function() { return [appendContextMenuOption, removeContextMenuOption, addContextMenuEventListener]; }; -initResponse = contextMenuInit(); -appendContextMenuOption = initResponse[0]; -removeContextMenuOption = initResponse[1]; -addContextMenuEventListener = initResponse[2]; +var initResponse = contextMenuInit(); +var appendContextMenuOption = initResponse[0]; +var removeContextMenuOption = initResponse[1]; +var addContextMenuEventListener = initResponse[2]; (function() { //Start example Context Menu Items diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index 0c80fa74..aafe0a00 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -63,8 +63,8 @@ function setupExtraNetworks() { onUiLoaded(setupExtraNetworks); -var re_extranet = /<([^:]+:[^:]+):[\d\.]+>/; -var re_extranet_g = /\s+<([^:]+:[^:]+):[\d\.]+>/g; +var re_extranet = /<([^:]+:[^:]+):[\d.]+>/; +var re_extranet_g = /\s+<([^:]+:[^:]+):[\d.]+>/g; function tryToRemoveExtraNetworkFromPrompt(textarea, text) { var m = text.match(re_extranet); diff --git a/javascript/generationParams.js b/javascript/generationParams.js index f9e84e70..a877f8a5 100644 --- a/javascript/generationParams.js +++ b/javascript/generationParams.js @@ -10,7 +10,7 @@ onUiUpdate(function() { } if (!modal) { modal = gradioApp().getElementById('lightboxModal'); - modalObserver.observe(modal, { attributes: true, attributeFilter: ['style'] }); + modalObserver.observe(modal, {attributes: true, attributeFilter: ['style']}); } }); diff --git a/javascript/hints.js b/javascript/hints.js index 477b7d80..88e550ef 100644 --- a/javascript/hints.js +++ b/javascript/hints.js @@ -1,6 +1,6 @@ // mouseover tooltips for various UI elements -titles = { +var titles = { "Sampling steps": "How many times to improve the generated image iteratively; higher values take longer; very low values can produce bad results", "Sampling method": "Which algorithm to use to produce the image", "GFPGAN": "Restore low quality faces using GFPGAN neural network", @@ -118,7 +118,7 @@ titles = { onUiUpdate(function() { gradioApp().querySelectorAll('span, button, select, p').forEach(function(span) { - if (span.title) return; // already has a title + if (span.title) return; // already has a title let tooltip = localization[titles[span.textContent]] || titles[span.textContent]; diff --git a/javascript/imageMaskFix.js b/javascript/imageMaskFix.js index 91a6377b..3c9b8a6f 100644 --- a/javascript/imageMaskFix.js +++ b/javascript/imageMaskFix.js @@ -5,7 +5,6 @@ function imageMaskResize() { const canvases = gradioApp().querySelectorAll('#img2maskimg .touch-none canvas'); if (!canvases.length) { - canvases_fixed = false; // TODO: this is unused..? window.removeEventListener('resize', imageMaskResize); return; } diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js index ecd12379..78e24eb9 100644 --- a/javascript/imageviewer.js +++ b/javascript/imageviewer.js @@ -37,6 +37,7 @@ function updateOnBackgroundChange() { if (currentButton?.children?.length > 0 && modalImage.src != currentButton.children[0].src) { modalImage.src = currentButton.children[0].src; if (modalImage.style.display === 'none') { + const modal = gradioApp().getElementById("lightboxModal"); modal.style.setProperty('background-image', `url(${modalImage.src})`); } } @@ -169,12 +170,6 @@ function modalTileImageToggle(event) { event.stopPropagation(); } -function galleryImageHandler(e) { - //if (e && e.parentElement.tagName == 'BUTTON') { - e.onclick = showGalleryImage; - //} -} - onUiUpdate(function() { var fullImg_preview = gradioApp().querySelectorAll('.gradio-gallery > div > img'); if (fullImg_preview != null) { diff --git a/javascript/localization.js b/javascript/localization.js index 3d043a9a..eb22b8a7 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -1,10 +1,9 @@ // localization = {} -- the dict with translations is created by the backend -ignore_ids_for_localization = { +var ignore_ids_for_localization = { setting_sd_hypernetwork: 'OPTION', setting_sd_model_checkpoint: 'OPTION', - setting_realesrgan_enabled_models: 'OPTION', modelmerger_primary_model_name: 'OPTION', modelmerger_secondary_model_name: 'OPTION', modelmerger_tertiary_model_name: 'OPTION', @@ -19,11 +18,11 @@ ignore_ids_for_localization = { extras_upscaler_2: 'SPAN', }; -re_num = /^[\.\d]+$/; -re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u; +var re_num = /^[.\d]+$/; +var re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u; -original_lines = {}; -translated_lines = {}; +var original_lines = {}; +var translated_lines = {}; function hasLocalization() { return window.localization && Object.keys(window.localization).length > 0; @@ -31,7 +30,7 @@ function hasLocalization() { function textNodesUnder(el) { var n, a = [], walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false); - while (n = walk.nextNode()) a.push(n); + while ((n = walk.nextNode())) a.push(n); return a; } @@ -64,7 +63,7 @@ function getTranslation(text) { original_lines[text] = 1; } - tl = localization[text]; + var tl = localization[text]; if (tl !== undefined) { translated_lines[tl] = 1; } @@ -77,7 +76,7 @@ function processTextNode(node) { if (!canBeTranslated(node, text)) return; - tl = getTranslation(text); + var tl = getTranslation(text); if (tl !== undefined) { node.textContent = tl; } @@ -90,14 +89,14 @@ function processNode(node) { } if (node.title) { - tl = getTranslation(node.title); + let tl = getTranslation(node.title); if (tl !== undefined) { node.title = tl; } } if (node.placeholder) { - tl = getTranslation(node.placeholder); + let tl = getTranslation(node.placeholder); if (tl !== undefined) { node.placeholder = tl; } @@ -157,21 +156,21 @@ document.addEventListener("DOMContentLoaded", function() { processNode(gradioApp()); - if (localization.rtl) { // if the language is from right to left, + if (localization.rtl) { // if the language is from right to left, (new MutationObserver((mutations, observer) => { // wait for the style to load mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.tagName === 'STYLE') { observer.disconnect(); - for (const x of node.sheet.rules) { // find all rtl media rules + for (const x of node.sheet.rules) { // find all rtl media rules if (Array.from(x.media || []).includes('rtl')) { - x.media.appendMedium('all'); // enable them + x.media.appendMedium('all'); // enable them } } } }); }); - })).observe(gradioApp(), { childList: true }); + })).observe(gradioApp(), {childList: true}); } }); diff --git a/javascript/progressbar.js b/javascript/progressbar.js index cd273e48..29299787 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -53,7 +53,7 @@ function setTitle(progress) { } if (document.title != title) { - document.title = title; + document.title = title; } } @@ -144,7 +144,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre if (res.live_preview && gallery) { - var rect = gallery.getBoundingClientRect(); + rect = gallery.getBoundingClientRect(); if (rect.width) { livePreview.style.width = rect.width + "px"; livePreview.style.height = rect.height + "px"; diff --git a/javascript/ui.js b/javascript/ui.js index f4727ca3..133d6ff3 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -99,13 +99,6 @@ function switch_to_inpaint_sketch() { return args_to_array(arguments); } -function switch_to_inpaint() { - gradioApp().querySelector('#tabs').querySelectorAll('button')[1].click(); - gradioApp().getElementById('mode_img2img').querySelectorAll('button')[2].click(); - - return args_to_array(arguments); -} - function switch_to_extras() { gradioApp().querySelector('#tabs').querySelectorAll('button')[2].click(); @@ -172,7 +165,6 @@ function showRestoreProgressButton(tabname, show) { } function submit() { - rememberGallerySelection('txt2img_gallery'); showSubmitButtons('txt2img', false); var id = randomId(); @@ -192,7 +184,6 @@ function submit() { } function submit_img2img() { - rememberGallerySelection('img2img_gallery'); showSubmitButtons('img2img', false); var id = randomId(); @@ -273,7 +264,7 @@ function confirm_clear_prompt(prompt, negative_prompt) { } -promptTokecountUpdateFuncs = {}; +var promptTokecountUpdateFuncs = {}; function recalculatePromptTokens(name) { if (promptTokecountUpdateFuncs[name]) { @@ -304,7 +295,8 @@ onUiUpdate(function() { var textarea = json_elem.querySelector('textarea'); var jsdata = textarea.value; opts = JSON.parse(jsdata); - executeCallbacks(optionsChangedCallbacks); + + executeCallbacks(optionsChangedCallbacks); /*global optionsChangedCallbacks*/ Object.defineProperty(textarea, 'value', { set: function(newValue) { @@ -390,7 +382,9 @@ function update_txt2img_tokens(...args) { } function update_img2img_tokens(...args) { - update_token_counter("img2img_token_button"); + update_token_counter( + "img2img_token_button" + ); if (args.length == 2) { return args[0]; } @@ -423,7 +417,7 @@ function restart_reload() { // Simulate an `input` DOM event for Gradio Textbox component. Needed after you edit its contents in javascript, otherwise your edits // will only visible on web page and not sent to python. function updateInput(target) { - let e = new Event("input", { bubbles: true }); + let e = new Event("input", {bubbles: true}); Object.defineProperty(e, "target", {value: target}); target.dispatchEvent(e); } @@ -435,7 +429,7 @@ function selectCheckpoint(name) { gradioApp().getElementById('change_checkpoint').click(); } -function currentImg2imgSourceResolution(_, _, scaleBy) { +function currentImg2imgSourceResolution(w, h, scaleBy) { var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img'); return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy]; } diff --git a/javascript/ui_settings_hints.js b/javascript/ui_settings_hints.js index 0db41b11..e216852b 100644 --- a/javascript/ui_settings_hints.js +++ b/javascript/ui_settings_hints.js @@ -1,6 +1,6 @@ // various hints and extra info for the settings tab -settingsHintsSetup = false; +var settingsHintsSetup = false; onOptionsChanged(function() { if (settingsHintsSetup) return; @@ -30,7 +30,7 @@ onOptionsChanged(function() { span.parentElement.insertBefore(document.createTextNode('\xa0'), span); } if (commentAfter) { - var comment = document.createElement('DIV'); + comment = document.createElement('DIV'); comment.className = 'settings-comment'; comment.innerHTML = commentAfter; span.parentElement.insertBefore(comment, span.nextSibling); @@ -50,7 +50,7 @@ function settingsHintsShowQuicksettings() { td.textContent = obj.name; tr.appendChild(td); - var td = document.createElement('td'); + td = document.createElement('td'); td.textContent = obj.label; tr.appendChild(td); diff --git a/script.js b/script.js index f6a3883a..db4d9157 100644 --- a/script.js +++ b/script.js @@ -18,11 +18,11 @@ function get_uiCurrentTabContent() { return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])'); } -uiUpdateCallbacks = []; -uiLoadedCallbacks = []; -uiTabChangeCallbacks = []; -optionsChangedCallbacks = []; -let uiCurrentTab = null; +var uiUpdateCallbacks = []; +var uiLoadedCallbacks = []; +var uiTabChangeCallbacks = []; +var optionsChangedCallbacks = []; +var uiCurrentTab = null; function onUiUpdate(callback) { uiUpdateCallbacks.push(callback); @@ -66,7 +66,7 @@ document.addEventListener("DOMContentLoaded", function() { executeCallbacks(uiTabChangeCallbacks); } }); - mutationObserver.observe(gradioApp(), { childList: true, subtree: true }); + mutationObserver.observe(gradioApp(), {childList: true, subtree: true}); }); /** @@ -80,7 +80,7 @@ document.addEventListener('keydown', function(e) { if ((e.keyCode == 13 && (e.metaKey || e.ctrlKey || e.altKey))) handled = true; } if (handled) { - button = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); + var button = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); if (button) { button.click(); } @@ -97,7 +97,7 @@ function uiElementIsVisible(el) { return false; } - while (isVisible = el.closest('.tabitem')?.style.display !== 'none') { + while ((isVisible = el.closest('.tabitem')?.style.display) !== 'none') { if (!isVisible) { return false; } else if (el.parentElement) { -- cgit v1.2.3