diff --git a/js/webui.js b/js/webui.js index c467c2770..fc211f8c0 100644 --- a/js/webui.js +++ b/js/webui.js @@ -1912,7 +1912,7 @@ var theWebUI = return(e.fromTextCtrl); }, - contextMenuTable: function(labelType, el) { + contextMenuTable: function(panelId, labelId) { return theWebUI.getTable('trt'); }, diff --git a/plugins/datadir/init.js b/plugins/datadir/init.js index c6c9b7dae..0a6d6c6da 100644 --- a/plugins/datadir/init.js +++ b/plugins/datadir/init.js @@ -1,12 +1,18 @@ plugin.loadMainCSS(); plugin.loadLang(); +function firstSelectedTorrent() { + const table = theWebUI.getTable("trt"); + const id = table.selCount > 0 ? table.getFirstSelected() : null; + return id && id.length === 40 ? theWebUI.torrents[id] : undefined; +} + theWebUI.EditDataDir = function() { - var id = theWebUI.getTable("trt").getFirstSelected(); - if( id && (id.length==40) && this.torrents[id] ) + const torrent = firstSelectedTorrent(); + if( torrent ) { - var save_path = this.torrents[id].save_path.trim(); + var save_path = torrent.save_path.trim(); if( !save_path.length ) // torrent is not open this.request( "?action=getsavepath&hash=" + id, [this.showDataDirDlg, this] ); else @@ -16,13 +22,13 @@ theWebUI.EditDataDir = function() theWebUI.showDataDirDlg = function( d ) { - var id = theWebUI.getTable("trt").getFirstSelected(); var is_done = false; var is_multy = false; - if( id && (id.length==40) && this.torrents[id] ) + const torrent = firstSelectedTorrent(); + if( torrent ) { - is_done = String(this.torrents[id].done).trim() === "1000"; - is_multy = String(this.torrents[id].multi_file).trim() !== "0"; + is_done = String(torrent.done).trim() === "1000"; + is_multy = String(torrent.multi_file).trim() !== "0"; } $('#edit_datadir').val( d.savepath.trim() ); $('#btn_datadir_ok').prop("disabled",false); @@ -73,12 +79,10 @@ if(plugin.canChangeMenu()) plugin.createMenu.call(this, e, id); if(plugin.enabled && plugin.allStuffLoaded) { - var table = this.getTable("trt"); - var el = theContextMenu.get( theUILang.Properties ); if( el ) theContextMenu.add( el, [theUILang.DataDir + "...", - ((table.selCount > 1) || (table.getFirstSelected().length==40)) ? "theWebUI.EditDataDir()" : null] ); + firstSelectedTorrent() ? "theWebUI.EditDataDir()" : null] ); } } } diff --git a/plugins/extsearch/init.js b/plugins/extsearch/init.js index fd63f95eb..deaad8c6a 100644 --- a/plugins/extsearch/init.js +++ b/plugins/extsearch/init.js @@ -285,7 +285,7 @@ catlist.switchLabel = function(panelId, targetId, toggle=false, range=false) } table.scrollTo(0); table.calcSize().resizeHack(); - } else { + } else if (tegList.is(":visible")) { // switch away from extsearch view tegList.hide(); list.show(); @@ -429,10 +429,10 @@ function idIsExTeg(labelId) { } plugin.contextMenuTable = theWebUI.contextMenuTable; -theWebUI.contextMenuTable = function(panelId, el) { - return panelId === 'psearch' && idIsExTeg(el.id) ? +theWebUI.contextMenuTable = function(panelId, labelId) { + return panelId === 'psearch' && idIsExTeg(labelId) ? theWebUI.getTable('teg') - : plugin.contextMenuTable.call(theWebUI, panelId, el); + : plugin.contextMenuTable.call(theWebUI, panelId, labelId); }, plugin.contextMenuEntries = catlist.contextMenuEntries.bind(catlist); @@ -444,7 +444,7 @@ catlist.contextMenuEntries = function(panelId, labelId) { [ theUILang.tegMenuDelete, "theWebUI.extTegDelete()"] ] : false; } - return catlist.contextMenuEntries(panelId, labelId); + return plugin.contextMenuEntries(panelId, labelId); } plugin.createMenu = theWebUI.createMenu; @@ -465,7 +465,8 @@ catlist.refreshPanel.psearch = (attribs) => psearchEntries(attribs).concat(Objec ...attribs.get(tegId), text: teg.val, icon: `url:./plugins/extsearch/images/${teg.eng === 'all' ? 'search' : teg.eng}.png`, - count: String(teg.data.filter(d => !d.deleted).length) + count: String(teg.data.filter(d => !d.deleted).length), + selected: catlist.isLabelIdSelected("psearch", tegId), } ])); diff --git a/plugins/rss/init.js b/plugins/rss/init.js index fa03f4717..9b72fde12 100644 --- a/plugins/rss/init.js +++ b/plugins/rss/init.js @@ -328,10 +328,10 @@ theWebUI.RSSManager = function() } plugin.contextMenuTable = theWebUI.contextMenuTable; -theWebUI.contextMenuTable = function(panelId, el) { +theWebUI.contextMenuTable = function(panelId, labelId) { return panelId === 'prss' ? theWebUI.getTable('rss') - : plugin.contextMenuTable.call(theWebUI, panelId, el); + : plugin.contextMenuTable.call(theWebUI, panelId, labelId); }, plugin.contextMenuEntries = catlist.contextMenuEntries.bind(catlist);