2017-12-28 13:05:36 -05:00
|
|
|
<style type="text/css">
|
|
|
|
#installSearchPluginContainer {
|
|
|
|
margin: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#installSearchPluginContainer button {
|
|
|
|
padding: 3px 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#newPluginPath {
|
|
|
|
width: 100%;
|
|
|
|
line-height: 2em;
|
|
|
|
}
|
2018-12-12 12:23:56 +08:00
|
|
|
|
2017-12-28 13:05:36 -05:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<div id="installSearchPluginContainer">
|
|
|
|
<h2>QBT_TR(Plugin path:)QBT_TR[CONTEXT=PluginSourceDlg]</h2>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none" />
|
|
|
|
<div style="margin-top: 10px; text-align: center;">
|
2019-08-11 23:53:20 -07:00
|
|
|
<button id="newPluginCancel" onclick="qBittorrent.SearchPlugins.closeSearchWindow('installSearchPlugin');">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button>
|
|
|
|
<button id="newPluginOk" onclick="qBittorrent.InstallSearchPlugin.newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button>
|
2017-12-28 13:05:36 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
'use strict';
|
|
|
|
|
2019-08-11 23:53:20 -07:00
|
|
|
if (window.qBittorrent === undefined) {
|
|
|
|
window.qBittorrent = {};
|
|
|
|
}
|
2017-12-28 13:05:36 -05:00
|
|
|
|
2019-08-11 23:53:20 -07:00
|
|
|
window.qBittorrent.InstallSearchPlugin = (function() {
|
|
|
|
const exports = function() {
|
|
|
|
return {
|
|
|
|
newPluginOk: newPluginOk
|
|
|
|
};
|
|
|
|
};
|
2017-12-28 13:05:36 -05:00
|
|
|
|
2019-08-11 23:53:20 -07:00
|
|
|
const init = function() {
|
|
|
|
new Keyboard({
|
|
|
|
defaultEventType: 'keydown',
|
|
|
|
events: {
|
|
|
|
'Enter': function(e) {
|
|
|
|
// accept enter key as a click
|
|
|
|
new Event(e).stop();
|
2017-12-28 13:05:36 -05:00
|
|
|
|
2019-08-11 23:53:20 -07:00
|
|
|
const elem = e.event.srcElement;
|
|
|
|
if ((elem.id === "newPluginPath") || (elem.id === "newPluginOk"))
|
|
|
|
newPluginOk();
|
|
|
|
else if (elem.id === "newPluginCancel")
|
|
|
|
window.qBittorrent.SearchPlugins.closeSearchWindow('installSearchPlugin');
|
|
|
|
}
|
2017-12-28 13:05:36 -05:00
|
|
|
}
|
2019-08-11 23:53:20 -07:00
|
|
|
}).activate();
|
|
|
|
|
|
|
|
$('newPluginPath').select();
|
|
|
|
};
|
|
|
|
|
|
|
|
const newPluginOk = function() {
|
|
|
|
const path = $("newPluginPath").get("value").trim();
|
|
|
|
if (path)
|
|
|
|
new Request({
|
|
|
|
url: 'api/v2/search/installPlugin',
|
|
|
|
noCache: true,
|
|
|
|
method: 'post',
|
|
|
|
data: {
|
|
|
|
sources: path,
|
|
|
|
},
|
|
|
|
onRequest: function() {
|
|
|
|
window.qBittorrent.SearchPlugins.closeSearchWindow('installSearchPlugin');
|
|
|
|
}
|
|
|
|
}).send();
|
|
|
|
};
|
|
|
|
|
|
|
|
init();
|
2017-12-28 13:05:36 -05:00
|
|
|
|
2019-08-11 23:53:20 -07:00
|
|
|
return exports();
|
|
|
|
})();
|
2017-12-28 13:05:36 -05:00
|
|
|
</script>
|