eslint related file edits

This commit is contained in:
AUTOMATIC 2023-05-18 09:59:10 +03:00
parent f88169a9e7
commit 57b75f4a03
13 changed files with 54 additions and 67 deletions

View File

@ -5,7 +5,7 @@
function checkBrackets(textArea, counterElt) { function checkBrackets(textArea, counterElt) {
var counts = {}; var counts = {};
(textArea.value.match(/[(){}\[\]]/g) || []).forEach(bracket => { (textArea.value.match(/[(){}[\]]/g) || []).forEach(bracket => {
counts[bracket] = (counts[bracket] || 0) + 1; counts[bracket] = (counts[bracket] || 0) + 1;
}); });
var errors = []; var errors = [];

View File

@ -1,5 +1,5 @@
contextMenuInit = function() { var contextMenuInit = function() {
let eventListenerApplied = false; let eventListenerApplied = false;
let menuSpecs = new Map(); let menuSpecs = new Map();
@ -126,10 +126,10 @@ contextMenuInit = function() {
return [appendContextMenuOption, removeContextMenuOption, addContextMenuEventListener]; return [appendContextMenuOption, removeContextMenuOption, addContextMenuEventListener];
}; };
initResponse = contextMenuInit(); var initResponse = contextMenuInit();
appendContextMenuOption = initResponse[0]; var appendContextMenuOption = initResponse[0];
removeContextMenuOption = initResponse[1]; var removeContextMenuOption = initResponse[1];
addContextMenuEventListener = initResponse[2]; var addContextMenuEventListener = initResponse[2];
(function() { (function() {
//Start example Context Menu Items //Start example Context Menu Items

View File

@ -63,8 +63,8 @@ function setupExtraNetworks() {
onUiLoaded(setupExtraNetworks); onUiLoaded(setupExtraNetworks);
var re_extranet = /<([^:]+:[^:]+):[\d\.]+>/; var re_extranet = /<([^:]+:[^:]+):[\d.]+>/;
var re_extranet_g = /\s+<([^:]+:[^:]+):[\d\.]+>/g; var re_extranet_g = /\s+<([^:]+:[^:]+):[\d.]+>/g;
function tryToRemoveExtraNetworkFromPrompt(textarea, text) { function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
var m = text.match(re_extranet); var m = text.match(re_extranet);

View File

@ -1,6 +1,6 @@
// mouseover tooltips for various UI elements // 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 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", "Sampling method": "Which algorithm to use to produce the image",
"GFPGAN": "Restore low quality faces using GFPGAN neural network", "GFPGAN": "Restore low quality faces using GFPGAN neural network",

View File

@ -5,7 +5,6 @@
function imageMaskResize() { function imageMaskResize() {
const canvases = gradioApp().querySelectorAll('#img2maskimg .touch-none canvas'); const canvases = gradioApp().querySelectorAll('#img2maskimg .touch-none canvas');
if (!canvases.length) { if (!canvases.length) {
canvases_fixed = false; // TODO: this is unused..?
window.removeEventListener('resize', imageMaskResize); window.removeEventListener('resize', imageMaskResize);
return; return;
} }

View File

@ -37,6 +37,7 @@ function updateOnBackgroundChange() {
if (currentButton?.children?.length > 0 && modalImage.src != currentButton.children[0].src) { if (currentButton?.children?.length > 0 && modalImage.src != currentButton.children[0].src) {
modalImage.src = currentButton.children[0].src; modalImage.src = currentButton.children[0].src;
if (modalImage.style.display === 'none') { if (modalImage.style.display === 'none') {
const modal = gradioApp().getElementById("lightboxModal");
modal.style.setProperty('background-image', `url(${modalImage.src})`); modal.style.setProperty('background-image', `url(${modalImage.src})`);
} }
} }
@ -169,12 +170,6 @@ function modalTileImageToggle(event) {
event.stopPropagation(); event.stopPropagation();
} }
function galleryImageHandler(e) {
//if (e && e.parentElement.tagName == 'BUTTON') {
e.onclick = showGalleryImage;
//}
}
onUiUpdate(function() { onUiUpdate(function() {
var fullImg_preview = gradioApp().querySelectorAll('.gradio-gallery > div > img'); var fullImg_preview = gradioApp().querySelectorAll('.gradio-gallery > div > img');
if (fullImg_preview != null) { if (fullImg_preview != null) {

View File

@ -1,10 +1,9 @@
// localization = {} -- the dict with translations is created by the backend // 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_hypernetwork: 'OPTION',
setting_sd_model_checkpoint: 'OPTION', setting_sd_model_checkpoint: 'OPTION',
setting_realesrgan_enabled_models: 'OPTION',
modelmerger_primary_model_name: 'OPTION', modelmerger_primary_model_name: 'OPTION',
modelmerger_secondary_model_name: 'OPTION', modelmerger_secondary_model_name: 'OPTION',
modelmerger_tertiary_model_name: 'OPTION', modelmerger_tertiary_model_name: 'OPTION',
@ -19,11 +18,11 @@ ignore_ids_for_localization = {
extras_upscaler_2: 'SPAN', extras_upscaler_2: 'SPAN',
}; };
re_num = /^[\.\d]+$/; var re_num = /^[.\d]+$/;
re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u; var re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u;
original_lines = {}; var original_lines = {};
translated_lines = {}; var translated_lines = {};
function hasLocalization() { function hasLocalization() {
return window.localization && Object.keys(window.localization).length > 0; return window.localization && Object.keys(window.localization).length > 0;
@ -31,7 +30,7 @@ function hasLocalization() {
function textNodesUnder(el) { function textNodesUnder(el) {
var n, a = [], walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false); 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; return a;
} }
@ -64,7 +63,7 @@ function getTranslation(text) {
original_lines[text] = 1; original_lines[text] = 1;
} }
tl = localization[text]; var tl = localization[text];
if (tl !== undefined) { if (tl !== undefined) {
translated_lines[tl] = 1; translated_lines[tl] = 1;
} }
@ -77,7 +76,7 @@ function processTextNode(node) {
if (!canBeTranslated(node, text)) return; if (!canBeTranslated(node, text)) return;
tl = getTranslation(text); var tl = getTranslation(text);
if (tl !== undefined) { if (tl !== undefined) {
node.textContent = tl; node.textContent = tl;
} }
@ -90,14 +89,14 @@ function processNode(node) {
} }
if (node.title) { if (node.title) {
tl = getTranslation(node.title); let tl = getTranslation(node.title);
if (tl !== undefined) { if (tl !== undefined) {
node.title = tl; node.title = tl;
} }
} }
if (node.placeholder) { if (node.placeholder) {
tl = getTranslation(node.placeholder); let tl = getTranslation(node.placeholder);
if (tl !== undefined) { if (tl !== undefined) {
node.placeholder = tl; node.placeholder = tl;
} }

View File

@ -144,7 +144,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
if (res.live_preview && gallery) { if (res.live_preview && gallery) {
var rect = gallery.getBoundingClientRect(); rect = gallery.getBoundingClientRect();
if (rect.width) { if (rect.width) {
livePreview.style.width = rect.width + "px"; livePreview.style.width = rect.width + "px";
livePreview.style.height = rect.height + "px"; livePreview.style.height = rect.height + "px";

View File

@ -99,13 +99,6 @@ function switch_to_inpaint_sketch() {
return args_to_array(arguments); 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() { function switch_to_extras() {
gradioApp().querySelector('#tabs').querySelectorAll('button')[2].click(); gradioApp().querySelector('#tabs').querySelectorAll('button')[2].click();
@ -172,7 +165,6 @@ function showRestoreProgressButton(tabname, show) {
} }
function submit() { function submit() {
rememberGallerySelection('txt2img_gallery');
showSubmitButtons('txt2img', false); showSubmitButtons('txt2img', false);
var id = randomId(); var id = randomId();
@ -192,7 +184,6 @@ function submit() {
} }
function submit_img2img() { function submit_img2img() {
rememberGallerySelection('img2img_gallery');
showSubmitButtons('img2img', false); showSubmitButtons('img2img', false);
var id = randomId(); var id = randomId();
@ -273,7 +264,7 @@ function confirm_clear_prompt(prompt, negative_prompt) {
} }
promptTokecountUpdateFuncs = {}; var promptTokecountUpdateFuncs = {};
function recalculatePromptTokens(name) { function recalculatePromptTokens(name) {
if (promptTokecountUpdateFuncs[name]) { if (promptTokecountUpdateFuncs[name]) {
@ -304,7 +295,8 @@ onUiUpdate(function() {
var textarea = json_elem.querySelector('textarea'); var textarea = json_elem.querySelector('textarea');
var jsdata = textarea.value; var jsdata = textarea.value;
opts = JSON.parse(jsdata); opts = JSON.parse(jsdata);
executeCallbacks(optionsChangedCallbacks);
executeCallbacks(optionsChangedCallbacks); /*global optionsChangedCallbacks*/
Object.defineProperty(textarea, 'value', { Object.defineProperty(textarea, 'value', {
set: function(newValue) { set: function(newValue) {
@ -390,7 +382,9 @@ function update_txt2img_tokens(...args) {
} }
function update_img2img_tokens(...args) { function update_img2img_tokens(...args) {
update_token_counter("img2img_token_button"); update_token_counter(
"img2img_token_button"
);
if (args.length == 2) { if (args.length == 2) {
return args[0]; return args[0];
} }
@ -435,7 +429,7 @@ function selectCheckpoint(name) {
gradioApp().getElementById('change_checkpoint').click(); gradioApp().getElementById('change_checkpoint').click();
} }
function currentImg2imgSourceResolution(_, _, scaleBy) { function currentImg2imgSourceResolution(w, h, scaleBy) {
var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img'); var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img');
return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy]; return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy];
} }

View File

@ -1,6 +1,6 @@
// various hints and extra info for the settings tab // various hints and extra info for the settings tab
settingsHintsSetup = false; var settingsHintsSetup = false;
onOptionsChanged(function() { onOptionsChanged(function() {
if (settingsHintsSetup) return; if (settingsHintsSetup) return;
@ -30,7 +30,7 @@ onOptionsChanged(function() {
span.parentElement.insertBefore(document.createTextNode('\xa0'), span); span.parentElement.insertBefore(document.createTextNode('\xa0'), span);
} }
if (commentAfter) { if (commentAfter) {
var comment = document.createElement('DIV'); comment = document.createElement('DIV');
comment.className = 'settings-comment'; comment.className = 'settings-comment';
comment.innerHTML = commentAfter; comment.innerHTML = commentAfter;
span.parentElement.insertBefore(comment, span.nextSibling); span.parentElement.insertBefore(comment, span.nextSibling);
@ -50,7 +50,7 @@ function settingsHintsShowQuicksettings() {
td.textContent = obj.name; td.textContent = obj.name;
tr.appendChild(td); tr.appendChild(td);
var td = document.createElement('td'); td = document.createElement('td');
td.textContent = obj.label; td.textContent = obj.label;
tr.appendChild(td); tr.appendChild(td);

View File

@ -18,11 +18,11 @@ function get_uiCurrentTabContent() {
return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])'); return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])');
} }
uiUpdateCallbacks = []; var uiUpdateCallbacks = [];
uiLoadedCallbacks = []; var uiLoadedCallbacks = [];
uiTabChangeCallbacks = []; var uiTabChangeCallbacks = [];
optionsChangedCallbacks = []; var optionsChangedCallbacks = [];
let uiCurrentTab = null; var uiCurrentTab = null;
function onUiUpdate(callback) { function onUiUpdate(callback) {
uiUpdateCallbacks.push(callback); uiUpdateCallbacks.push(callback);
@ -80,7 +80,7 @@ document.addEventListener('keydown', function(e) {
if ((e.keyCode == 13 && (e.metaKey || e.ctrlKey || e.altKey))) handled = true; if ((e.keyCode == 13 && (e.metaKey || e.ctrlKey || e.altKey))) handled = true;
} }
if (handled) { if (handled) {
button = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); var button = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
if (button) { if (button) {
button.click(); button.click();
} }
@ -97,7 +97,7 @@ function uiElementIsVisible(el) {
return false; return false;
} }
while (isVisible = el.closest('.tabitem')?.style.display !== 'none') { while ((isVisible = el.closest('.tabitem')?.style.display) !== 'none') {
if (!isVisible) { if (!isVisible) {
return false; return false;
} else if (el.parentElement) { } else if (el.parentElement) {