luci-app-qbittorrent: improve button

This commit is contained in:
CN_SZTL 2020-03-08 16:11:16 +08:00
parent 42808701c2
commit 2e4a7d8319
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 12 additions and 12 deletions

View File

@ -1,13 +1,3 @@
local e=require"luci.model.uci".cursor()
local o=e:get_first("qbittorrent","qbittorrent","port") or 8080
local a=(luci.sys.call("pidof qbittorrent-nox > /dev/null")==0)
local t=""
if a then
t="<br/><br/><input type=\"button\" value=\" " .. translate("Open Web Interface") .. " \" onclick=\"window.open('http://'+window.location.hostname+':" .. o .. "')\"/>"
end
m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client.").."<br/>"..translate("Default login username: admin, password: adminadmin.")..t)
m:section(SimpleSection).template="qbittorrent/qbittorrent_status"

View File

@ -4,7 +4,7 @@ XHR.poll(3, '<%=url([[admin]], [[nas]], [[qBittorrent]], [[status]])%>', null,
var tb = document.getElementById('qBittorrent_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>qBittorrent <%:RUNNING%></font></b></em>';
var links = '<em><b><font color=green>qBittorrent <%:RUNNING%></font></b></em><input class="cbi-button mar-10" type="button" value="<%:Open Web Interface%>" onclick="openClient();" />';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>qBittorrent <%:NOT RUNNING%></font></b></em>';
@ -12,6 +12,16 @@ XHR.poll(3, '<%=url([[admin]], [[nas]], [[qBittorrent]], [[status]])%>', null,
}
}
);
function openClient() {
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
var localhostPath = curWwwPath.substring(0, pos);
var clientPort = window.document.getElementById("cbid.qbittorrent.config.port").value
var url = "http:" + localhostPath.substring(window.location.protocol.length) + ":" + clientPort;
window.open(url)
};
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
@ -19,4 +29,4 @@ XHR.poll(3, '<%=url([[admin]], [[nas]], [[qBittorrent]], [[status]])%>', null,
<p id="qBittorrent_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>
</fieldset>