1 <script type=
"text/javascript">//<![CDATA[
2 XHR.poll(-
1, '<%=luci.dispatcher.build_url(
"admin/services/aria2/status")%
>', null,
4 var tb = document.getElementById('aria2_status');
7 var links = '
<em><%:The Aria2 service is running.%
></em>';
9 links += '
<input class=
"cbi-button mar-10" type=
"button" value=
"<%:Open YAAW%>" onclick=
"openWebUI(\'yaaw\');" />';
12 links += '
<input class=
"cbi-button mar-10" type=
"button" value=
"<%:Open WebUI-Aria2%>" onclick=
"openWebUI(\'webui-aria2\');" />';
15 links += '
<input class=
"cbi-button mar-10" type=
"button" value=
"<%:Open AriaNg%>" onclick=
"openWebUI(\'ariang\');" />';
19 tb.innerHTML = '
<em><%:The Aria2 service is not running.%
></em>';
25 function randomString(len) {
27 var $chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
28 var maxPos = $chars.length;
30 for (var i =
0; i < len; i++) {
31 pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
36 function randomSecret() {
37 var Token = document.getElementById(
"cbid.aria2.main.rpc_secret");
38 Token.value = randomString(
32);
41 function showRPCURL() {
42 var websocket = document.getElementById(
"use_websocket");
43 var protocol = (websocket.checked) ?
"ws" :
"http";
44 var newTextNode = document.getElementById(
"aria2rpcpath");
45 var auth_method = document.getElementById(
"cbid.aria2.main.rpc_auth_method");
46 var auth_port = document.getElementById(
"cbid.aria2.main.rpc_listen_port");
48 if (window.location.protocol ==
"https:") {
51 if (auth_port.value ==
"") {
52 auth_port_value =
"6800";
54 auth_port_value = auth_port.value;
56 if (auth_method.value ==
"token") {
57 var auth_token = document.getElementById(
"cbid.aria2.main.rpc_secret");
58 newTextNode.value = protocol +
"://token:" + auth_token.value +
"@" + document.domain +
":" + auth_port_value +
"/jsonrpc";
59 } else if (auth_method.value ==
"user_pass") {
60 var auth_user = document.getElementById(
"cbid.aria2.main.rpc_user");
61 var auth_passwd = document.getElementById(
"cbid.aria2.main.rpc_passwd");
62 newTextNode.value = protocol +
"://" + auth_user.value +
":" + auth_passwd.value +
"@" + document.domain +
":" + auth_port_value +
"/jsonrpc";
64 newTextNode.value = protocol +
"://" + document.domain +
":" + auth_port_value +
"/jsonrpc";
68 function openWebUI(path) {
69 var curWwwPath = window.document.location.href;
70 var pathName = window.document.location.pathname;
71 var pos = curWwwPath.indexOf(pathName);
72 var localhostPath = curWwwPath.substring(
0, pos);
73 var url = localhostPath +
"/" + path;
78 <style>.mar-
10 {margin-left:
10px; margin-right:
10px;}
</style>
79 <fieldset class=
"cbi-section">
80 <legend><%:Aria2 Status%
></legend>
82 <em><%:Collecting data...%
></em>