mirror of
https://github.com/Carve/qbittorrent-webui-cjratliff.com.git
synced 2025-02-28 15:40:28 +01:00
83 lines
2.5 KiB
HTML
83 lines
2.5 KiB
HTML
<style>
|
|
#installSearchPluginContainer {
|
|
margin: 10px;
|
|
}
|
|
|
|
#installSearchPluginContainer button {
|
|
padding: 3px 20px;
|
|
}
|
|
|
|
#newPluginPath {
|
|
width: 100%;
|
|
}
|
|
|
|
</style>
|
|
|
|
<div id="installSearchPluginContainer">
|
|
<label for="newPluginPath">Plugin path:</label>
|
|
|
|
<div>
|
|
<input type="text" id="newPluginPath" placeholder="URL or local directory" autocorrect="off" autocapitalize="none">
|
|
<div style="margin-top: 10px; text-align: center;">
|
|
<button type="button" id="newPluginCancel" onclick="qBittorrent.SearchPlugins.closeSearchWindow('installSearchPlugin');">Cancel</button>
|
|
<button type="button" id="newPluginOk" onclick="qBittorrent.InstallSearchPlugin.newPluginOk();">Ok</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
"use strict";
|
|
|
|
window.qBittorrent ??= {};
|
|
window.qBittorrent.InstallSearchPlugin ??= (() => {
|
|
const exports = () => {
|
|
return {
|
|
setup: setup,
|
|
newPluginOk: newPluginOk
|
|
};
|
|
};
|
|
|
|
const setup = function() {
|
|
new Keyboard({
|
|
defaultEventType: "keydown",
|
|
events: {
|
|
"Enter": function(e) {
|
|
// accept enter key as a click
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
const elem = e.event.srcElement;
|
|
if ((elem.id === "newPluginPath") || (elem.id === "newPluginOk"))
|
|
newPluginOk();
|
|
else if (elem.id === "newPluginCancel")
|
|
window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin");
|
|
}
|
|
}
|
|
}).activate();
|
|
|
|
$("newPluginPath").select();
|
|
};
|
|
|
|
const newPluginOk = function() {
|
|
const path = $("newPluginPath").value.trim();
|
|
if (path) {
|
|
new Request({
|
|
url: "api/v2/search/installPlugin",
|
|
method: "post",
|
|
data: {
|
|
sources: path,
|
|
},
|
|
onRequest: function() {
|
|
window.qBittorrent.SearchPlugins.closeSearchWindow("installSearchPlugin");
|
|
}
|
|
}).send();
|
|
}
|
|
};
|
|
|
|
return exports();
|
|
})();
|
|
Object.freeze(window.qBittorrent.InstallSearchPlugin);
|
|
|
|
window.qBittorrent.InstallSearchPlugin.setup();
|
|
</script>
|