WebUI: Improve hash copy actions in context menu
[qBittorrent.git] / src / webui / www / private / views / installsearchplugin.html
blob8445e0ca83c28e3128949e8afe31d053b69d3140
1 <style>
2 #installSearchPluginContainer {
3 margin: 10px;
6 #installSearchPluginContainer button {
7 padding: 3px 20px;
10 #newPluginPath {
11 width: 100%;
14 </style>
16 <div id="installSearchPluginContainer">
17 <label for="newPluginPath">QBT_TR(Plugin path:)QBT_TR[CONTEXT=PluginSourceDlg]</label>
19 <div>
20 <input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none">
21 <div style="margin-top: 10px; text-align: center;">
22 <button type="button" id="newPluginCancel" onclick="qBittorrent.SearchPlugins.closeSearchWindow('installSearchPlugin');">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button>
23 <button type="button" id="newPluginOk" onclick="qBittorrent.InstallSearchPlugin.newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button>
24 </div>
25 </div>
26 </div>
28 <script>
29 "use strict";
31 window.qBittorrent ??= {};
32 window.qBittorrent.InstallSearchPlugin ??= (() => {
33 const exports = () => {
34 return {
35 setup: setup,
36 newPluginOk: newPluginOk
40 const setup = function() {
41 new Keyboard({
42 defaultEventType: "keydown",
43 events: {
44 "Enter": function(e) {
45 // accept enter key as a click
46 e.preventDefault();
47 e.stopPropagation();
49 const elem = e.event.srcElement;
50 if ((elem.id === "newPluginPath") || (elem.id === "newPluginOk"))
51 newPluginOk();
52 else if (elem.id === "newPluginCancel")
53 window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin");
56 }).activate();
58 $("newPluginPath").select();
61 const newPluginOk = function() {
62 const path = $("newPluginPath").value.trim();
63 if (path) {
64 new Request({
65 url: "api/v2/search/installPlugin",
66 method: "post",
67 data: {
68 sources: path,
70 onRequest: function() {
71 window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin");
73 }).send();
77 return exports();
78 })();
79 Object.freeze(window.qBittorrent.InstallSearchPlugin);
81 window.qBittorrent.InstallSearchPlugin.setup();
82 </script>