1 <style type=
"text/css">
2 #searchPluginsContainer {
3 height: calc
(100% - 20px);
8 #searchPluginsContainer button
{
12 #searchPluginsContainer span
{
19 height: calc
(100% - 150px);
20 -moz-height: calc
(100% - 150px);
21 -webkit-height: calc
(100% - 150px);
24 #searchPluginsTable .dynamicTable
{
28 #searchPluginsTableDiv {
29 height: calc
(100% - 26px);
30 -moz-height: calc
(100% - 26px);
31 -webkit-height: calc
(100% - 26px);
34 #dynamicTableFixedHeaderDiv {
38 #searchPlugins_content {
44 <div id=
"searchPluginsContainer">
45 <h2>QBT_TR(Installed search plugins:)QBT_TR[CONTEXT=PluginSelectDlg]
</h2>
47 <div id=
"searchPluginsTable">
48 <div id=
"searchPluginsTableFixedHeaderDiv" class=
"dynamicTableFixedHeaderDiv">
49 <table class=
"dynamicTable unselectable" style=
"position:relative;">
51 <tr class=
"dynamicTableHeader" id=
"searchPluginsTableFixedHeaderRow"></tr>
55 <div id=
"searchPluginsTableDiv" class=
"dynamicTableDiv">
56 <table class=
"dynamicTable unselectable">
58 <tr class=
"dynamicTableHeader"></tr>
65 <span>QBT_TR(Warning: Be sure to comply with your country's copyright laws when downloading torrents from any of these search engines.)QBT_TR[CONTEXT=PluginSelectDlg]
</span>
66 <span style=
"font-style: italic;">QBT_TR(You can get new search engine plugins here:)QBT_TR[CONTEXT=PluginSelectDlg]
<a href=
"http://plugins.qbittorrent.org" target=
"_blank">http://plugins.qbittorrent.org
</a></span>
67 <div style=
"width: 100%; margin-top: 10px;">
68 <button style=
"width: 33%; line-height: 1.4em;" onclick=
"installPlugin();">QBT_TR(Install new plugin)QBT_TR[CONTEXT=PluginSelectDlg]
</button>
69 <button style=
"width: 33%; line-height: 1.4em;" onclick=
"checkForUpdates();">QBT_TR(Check for updates)QBT_TR[CONTEXT=PluginSelectDlg]
</button>
70 <button style=
"width: 32%; line-height: 1.4em;" onclick=
"closeSearchWindow('searchPlugins');">QBT_TR(Close)QBT_TR[CONTEXT=PluginSelectDlg]
</button>
74 <ul id=
"searchPluginsTableMenu" class=
"contextMenu">
75 <li><a href=
"#Enabled"><img src=
"images/qbt-theme/checked.svg" alt=
"QBT_TR(Enabled)QBT_TR[CONTEXT=PluginSelectDlg]"/> QBT_TR(Enabled)QBT_TR[CONTEXT=PluginSelectDlg]
</a></li>
76 <li class=
"separator"><a href=
"#Uninstall"><img src=
"images/qbt-theme/list-remove.svg" alt=
"QBT_TR(Uninstall)QBT_TR[CONTEXT=PluginSelectDlg]"/> QBT_TR(Uninstall)QBT_TR[CONTEXT=PluginSelectDlg]
</a></li>
82 this.searchPluginsTableContextMenu
= undefined;
83 this.prevOffsetLeft
= undefined;
84 this.prevOffsetTop
= undefined;
86 this.initSearchPlugins = function() {
87 searchPluginsTableContextMenu
= new SearchPluginsTableContextMenu({
88 targets
: '.searchPluginsTableRow',
89 menu
: 'searchPluginsTableMenu',
91 Enabled
: enablePlugin
,
92 Uninstall
: uninstallPlugin
94 offsets
: calculateContextMenuOffsets()
96 searchPluginsTable
.setup('searchPluginsTableDiv', 'searchPluginsTableFixedHeaderDiv', searchPluginsTableContextMenu
);
97 updateSearchPluginsTable();
100 this.closeSearchWindow = function(id
) {
101 window
.parent
.MochaUI
.closeWindow(window
.parent
.$(id
));
104 this.installPlugin = function(path
) {
106 id
: 'installSearchPlugin',
107 title
: "QBT_TR(Install plugin)QBT_TR[CONTEXT=PluginSourceDlg]",
109 contentURL
: 'installsearchplugin.html',
114 paddingHorizontal
: 0,
120 this.uninstallPlugin = function() {
121 const plugins
= searchPluginsTable
.selectedRowsIds().join('|');
122 const url
= new URI('api/v2/search/uninstallPlugin');
133 this.enablePlugin = function() {
134 const plugins
= searchPluginsTable
.selectedRowsIds();
136 if (plugins
&& plugins
.length
)
137 enable
= !getPlugin(plugins
[0]).enabled
;
139 const url
= new URI('api/v2/search/enablePlugin');
145 names
: plugins
.join('|'),
151 this.checkForUpdates = function() {
152 const url
= new URI('api/v2/search/updatePlugins');
160 this.calculateContextMenuOffsets = function() {
161 prevOffsetLeft
= document
.getElementById("searchPlugins").getBoundingClientRect().left
;
162 prevOffsetTop
= document
.getElementById("searchPlugins").getBoundingClientRect().top
;
165 x
: -(prevOffsetLeft
+ 20),
166 y
: -(prevOffsetTop
+ 2)
170 this.updateSearchPluginsTableContextMenuOffset = function() {
171 // only re-calculate if window has moved
172 if ((prevOffsetLeft
!== document
.getElementById("searchPlugins").getBoundingClientRect().left
) || (prevOffsetTop
!== document
.getElementById("searchPlugins").getBoundingClientRect().top
))
173 searchPluginsTableContextMenu
.options
.offsets
= calculateContextMenuOffsets();
176 this.setupSearchPluginTableEvents = function(enable
) {
178 $$(".searchPluginsTableRow").each(function(target
) {
179 target
.addEventListener('dblclick', enablePlugin
, false);
180 target
.addEventListener('contextmenu', updateSearchPluginsTableContextMenuOffset
, true);
183 $$(".searchPluginsTableRow").each(function(target
) {
184 target
.removeEventListener('dblclick', enablePlugin
, false);
185 target
.removeEventListener('contextmenu', updateSearchPluginsTableContextMenuOffset
, true);
189 this.updateSearchPluginsTable = function() {
190 // clear event listeners
191 setupSearchPluginTableEvents(false);
193 const oldPlugins
= Object
.keys(searchPluginsTable
.rows
);
194 // remove old rows from the table
195 for (let i
= 0; i
< oldPlugins
.length
; ++i
) {
197 for (let j
= 0; j
< searchPlugins
.length
; ++j
) {
198 if (searchPlugins
[j
].name
=== oldPlugins
[i
]) {
204 searchPluginsTable
.removeRow(oldPlugins
[i
]);
207 for (let i
= 0; i
< searchPlugins
.length
; ++i
) {
208 searchPlugins
[i
].rowId
= searchPlugins
[i
].name
;
209 searchPluginsTable
.updateRowData(searchPlugins
[i
]);
212 searchPluginsTable
.updateTable();
213 searchPluginsTable
.altRow();
215 // add event listeners
216 setupSearchPluginTableEvents(true);