Rename WebUI content files
[qBittorrent.git] / src / webui / www / private / searchplugins.html
bloba757ff65200886431983fd8f1a24dec646f053a1
1 <style type="text/css">
2 #searchPluginsContainer {
3 height: calc(100% - 20px);
4 margin: 10px;
5 overflow: auto;
8 #searchPluginsContainer button {
9 padding: 2px;
12 #searchPluginsContainer span {
13 display: block;
14 margin-top: 10px;
17 #searchPluginsTable {
18 width: 100%;
19 height: calc(100% - 150px);
20 -moz-height: calc(100% - 150px);
21 -webkit-height: calc(100% - 150px);
24 #searchPluginsTable .dynamicTable {
25 width: 100%;
28 #searchPluginsTableDiv {
29 height: calc(100% - 26px);
30 -moz-height: calc(100% - 26px);
31 -webkit-height: calc(100% - 26px);
34 #dynamicTableFixedHeaderDiv {
35 height: 26px;
38 #searchPlugins_content {
39 height: 100%;
42 </style>
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;">
50 <thead>
51 <tr class="dynamicTableHeader" id="searchPluginsTableFixedHeaderRow"></tr>
52 </thead>
53 </table>
54 </div>
55 <div id="searchPluginsTableDiv" class="dynamicTableDiv">
56 <table class="dynamicTable unselectable">
57 <thead>
58 <tr class="dynamicTableHeader"></tr>
59 </thead>
60 <tbody></tbody>
61 </table>
62 </div>
63 </div>
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>
71 </div>
72 </div>
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>
77 </ul>
79 <script>
80 'use strict';
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',
90 actions: {
91 Enabled: enablePlugin,
92 Uninstall: uninstallPlugin
94 offsets: calculateContextMenuOffsets()
95 });
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) {
105 new MochaUI.Window({
106 id: 'installSearchPlugin',
107 title: "QBT_TR(Install plugin)QBT_TR[CONTEXT=PluginSourceDlg]",
108 loadMethod: 'xhr',
109 contentURL: 'installsearchplugin.html',
110 scrollbars: false,
111 resizable: false,
112 maximizable: false,
113 paddingVertical: 0,
114 paddingHorizontal: 0,
115 width: 500,
116 height: 120
120 this.uninstallPlugin = function() {
121 const plugins = searchPluginsTable.selectedRowsIds().join('|');
122 const url = new URI('api/v2/search/uninstallPlugin');
123 new Request({
124 url: url,
125 noCache: true,
126 method: 'post',
127 data: {
128 names: plugins,
130 }).send();
133 this.enablePlugin = function() {
134 const plugins = searchPluginsTable.selectedRowsIds();
135 let enable = true;
136 if (plugins && plugins.length)
137 enable = !getPlugin(plugins[0]).enabled;
139 const url = new URI('api/v2/search/enablePlugin');
140 new Request({
141 url: url,
142 noCache: true,
143 method: 'post',
144 data: {
145 names: plugins.join('|'),
146 enable: enable
148 }).send();
151 this.checkForUpdates = function() {
152 const url = new URI('api/v2/search/updatePlugins');
153 new Request({
154 url: url,
155 noCache: true,
156 method: 'post'
157 }).send();
160 this.calculateContextMenuOffsets = function() {
161 prevOffsetLeft = document.getElementById("searchPlugins").getBoundingClientRect().left;
162 prevOffsetTop = document.getElementById("searchPlugins").getBoundingClientRect().top;
164 return {
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) {
177 if (enable)
178 $$(".searchPluginsTableRow").each(function(target) {
179 target.addEventListener('dblclick', enablePlugin, false);
180 target.addEventListener('contextmenu', updateSearchPluginsTableContextMenuOffset, true);
182 else
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) {
196 let found = false;
197 for (let j = 0; j < searchPlugins.length; ++j) {
198 if (searchPlugins[j].name === oldPlugins[i]) {
199 found = true;
200 break;
203 if (!found)
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);
219 initSearchPlugins();
220 </script>