From 8ccc27127bd5abcba05f30f8a72fc37025b588ac Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 30 Apr 2023 22:08:52 +0300 Subject: Fix a whole bunch of implicit globals --- javascript/contextMenus.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'javascript/contextMenus.js') diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index 9468c107..5107e524 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -16,8 +16,7 @@ contextMenuInit = function(){ oldMenu.remove() } - let tabButton = uiCurrentTab - let baseStyle = window.getComputedStyle(tabButton) + let baseStyle = window.getComputedStyle(uiCurrentTab) const contextMenu = document.createElement('nav') contextMenu.id = "context-menu" @@ -63,7 +62,7 @@ contextMenuInit = function(){ function appendContextMenuOption(targetElementSelector,entryName,entryFunction){ - currentItems = menuSpecs.get(targetElementSelector) + var currentItems = menuSpecs.get(targetElementSelector) if(!currentItems){ currentItems = [] -- cgit v1.2.3 From f6a40a2ffacaba63915f11c47e77e84a06ed073c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 30 Apr 2023 22:12:24 +0300 Subject: Fix unused variables --- javascript/contextMenus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'javascript/contextMenus.js') 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){ -- cgit v1.2.3 From 4bb441bb08aa3692bdd7d347016b4d70e9cdf365 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 30 Apr 2023 22:15:11 +0300 Subject: Remove redundant return --- javascript/contextMenus.js | 1 - 1 file changed, 1 deletion(-) (limited to 'javascript/contextMenus.js') diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index ec7960e1..1f682c74 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -111,7 +111,6 @@ contextMenuInit = function(){ if(e.composedPath()[0].matches(k)){ showContextMenu(e,e.composedPath()[0],v) e.preventDefault() - return } }) }); -- cgit v1.2.3 From c714300265919e325ae1340459c4866541940687 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sun, 30 Apr 2023 22:15:59 +0300 Subject: Use substring instead of deprecated substr --- javascript/contextMenus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript/contextMenus.js') diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index 1f682c74..42f301ab 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -4,7 +4,7 @@ contextMenuInit = function(){ let menuSpecs = new Map(); const uid = function(){ - return Date.now().toString(36) + Math.random().toString(36).substr(2); + return Date.now().toString(36) + Math.random().toString(36).substring(2); } function showContextMenu(event,element,menuEntries){ -- cgit v1.2.3 From 11ae5399f667aec3fa00d99a0e5eeeeb3bafeb43 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Tue, 9 May 2023 10:52:02 +0300 Subject: make it so that custom context menu from contextMenu.js only disappears after user's click, ignoring non-user click events --- javascript/contextMenus.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'javascript/contextMenus.js') diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index 42f301ab..b2bdf053 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -92,8 +92,7 @@ contextMenuInit = function(){ return; } gradioApp().addEventListener("click", function(e) { - let source = e.composedPath()[0] - if(source.id && source.id.indexOf('check_progress')>-1){ + if(! e.isTrusted){ return } -- cgit v1.2.3