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

@@ -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});
}
});