From f6a40a2ffacaba63915f11c47e77e84a06ed073c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 30 Apr 2023 22:12:24 +0300 Subject: [PATCH] Fix unused variables --- javascript/aspectRatioOverlay.js | 11 +++-------- javascript/contextMenus.js | 4 ++-- javascript/extensions.js | 4 ++-- javascript/extraNetworks.js | 4 ++-- javascript/imageMaskFix.js | 1 - javascript/imageParams.js | 1 - javascript/notification.js | 2 +- javascript/progressbar.js | 4 ++-- javascript/ui.js | 4 ++-- 9 files changed, 14 insertions(+), 21 deletions(-) diff --git a/javascript/aspectRatioOverlay.js b/javascript/aspectRatioOverlay.js index 10ac81c7..5160081d 100644 --- a/javascript/aspectRatioOverlay.js +++ b/javascript/aspectRatioOverlay.js @@ -55,19 +55,14 @@ function dimensionChange(e, is_width, is_height){ var cleintRectCentreY = cleintRectTop + (targetElement.clientHeight/2) var cleintRectCentreX = cleintRectLeft + (targetElement.clientWidth/2) - var viewRectTop = cleintRectCentreY-(scaledy/2) // TODO: unused? - var viewRectLeft = cleintRectCentreX-(scaledx/2) // TODO: unused? - var arRectWidth = scaledx - var arRectHeight = scaledy - - var arscale = Math.min( arRectWidth/currentWidth, arRectHeight/currentHeight ) + 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) - arRectWidth = arscaledx - arRectHeight = arscaledy + var arRectWidth = arscaledx + var arRectHeight = arscaledy arPreviewRect.style.top = arRectTop+'px'; arPreviewRect.style.left = arRectLeft+'px'; diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index 5107e524..ec7960e1 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -35,7 +35,7 @@ contextMenuInit = function(){ menuEntries.forEach(function(entry){ let contextMenuEntry = document.createElement('a') contextMenuEntry.innerHTML = entry['name'] - contextMenuEntry.addEventListener("click", function(e) { + contextMenuEntry.addEventListener("click", function() { entry['func'](); }) contextMenuList.append(contextMenuEntry); @@ -78,7 +78,7 @@ contextMenuInit = function(){ } function removeContextMenuOption(uid){ - menuSpecs.forEach(function(v,k) { + menuSpecs.forEach(function(v) { let index = -1 v.forEach(function(e,ei){if(e['id']==uid){index=ei}}) if(index>=0){ diff --git a/javascript/extensions.js b/javascript/extensions.js index 872259af..cb68344b 100644 --- a/javascript/extensions.js +++ b/javascript/extensions.js @@ -1,5 +1,5 @@ -function extensions_apply(_, _, disable_all){ +function extensions_apply(_disabled_list, _update_list, disable_all){ var disable = [] var update = [] @@ -16,7 +16,7 @@ function extensions_apply(_, _, disable_all){ return [JSON.stringify(disable), JSON.stringify(update), disable_all] } -function extensions_check(_, _){ +function extensions_check(){ var disable = [] gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){ diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index 963d5b02..c8f6b386 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -10,7 +10,7 @@ function setupExtraNetworksForTab(tabname){ tabs.appendChild(search) tabs.appendChild(refresh) - search.addEventListener("input", function(evt){ + search.addEventListener("input", function(){ var searchTerm = search.value.toLowerCase() gradioApp().querySelectorAll('#'+tabname+'_extra_tabs div.card').forEach(function(elem){ @@ -55,7 +55,7 @@ function tryToRemoveExtraNetworkFromPrompt(textarea, text){ var partToSearch = m[1] var replaced = false - var newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found, index){ + var newTextareaText = textarea.value.replaceAll(re_extranet_g, function(found){ m = found.match(re_extranet); if(m[1] == partToSearch){ replaced = true; diff --git a/javascript/imageMaskFix.js b/javascript/imageMaskFix.js index bd0be627..a612705d 100644 --- a/javascript/imageMaskFix.js +++ b/javascript/imageMaskFix.js @@ -23,7 +23,6 @@ function imageMaskResize() { const nw = previewImage.naturalWidth; const nh = previewImage.naturalHeight; const portrait = nh > nw; - const factor = portrait; const wW = Math.min(w, portrait ? h/nh*nw : w/nw*nw); const wH = Math.min(h, portrait ? h/nh*nh : w/nw*nh); diff --git a/javascript/imageParams.js b/javascript/imageParams.js index 67404a89..64aee93b 100644 --- a/javascript/imageParams.js +++ b/javascript/imageParams.js @@ -1,7 +1,6 @@ window.onload = (function(){ window.addEventListener('drop', e => { const target = e.composedPath()[0]; - const idx = selected_gallery_index(); if (target.placeholder.indexOf("Prompt") == -1) return; let prompt_target = get_tab_index('tabs') == 1 ? "img2img_prompt_image" : "txt2img_prompt_image"; diff --git a/javascript/notification.js b/javascript/notification.js index a40de7c3..32913bac 100644 --- a/javascript/notification.js +++ b/javascript/notification.js @@ -9,7 +9,7 @@ onUiUpdate(function(){ notificationButton = gradioApp().getElementById('request_notifications') if(notificationButton != null){ - notificationButton.addEventListener('click', function (evt) { + notificationButton.addEventListener('click', () => { Notification.requestPermission(); },true); } diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 7b853a40..8d2c3492 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -1,10 +1,10 @@ // code related to showing and updating progressbar shown as the image is being made -function rememberGallerySelection(id_gallery){ +function rememberGallerySelection(){ } -function getGallerySelectedIndex(id_gallery){ +function getGallerySelectedIndex(){ } diff --git a/javascript/ui.js b/javascript/ui.js index fed96f98..aa440bf6 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -207,7 +207,7 @@ function submit_img2img(){ return res } -function restoreProgressTxt2img(x){ +function restoreProgressTxt2img(){ var id = localStorage.getItem("txt2img_task_id") if(id) { @@ -218,7 +218,7 @@ function restoreProgressTxt2img(x){ return [id] } -function restoreProgressImg2img(x){ +function restoreProgressImg2img(){ var id = localStorage.getItem("img2img_task_id") if(id) {