1 <script type=
"text/javascript">//<![CDATA[
2 XHR.poll(
5, '<%=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\');" />';
16 tb.innerHTML = '
<em><%:The Aria2 service is not running.%
></em>';
22 function randomString(len) {
24 var $chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
25 var maxPos = $chars.length;
27 for (i =
0; i < len; i++) {
28 pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
33 function randomSecret() {
34 var Token = document.getElementById(
"cbid.aria2.main.rpc_secret");
35 Token.value = randomString(
32);
38 function showRPCURL() {
39 var websocket = document.getElementById(
"use_websocket");
40 var protocol = (websocket.checked) ?
"ws" :
"http";
41 var newTextNode = document.getElementById(
"aria2rpcpath");
42 var auth_method = document.getElementById(
"cbid.aria2.main.rpc_auth_method");
43 var auth_port = document.getElementById(
"cbid.aria2.main.rpc_listen_port");
44 if (auth_port.value ==
"") {
45 auth_port_value =
"6800"
47 auth_port_value = auth_port.value
49 if (auth_method.value ==
"token") {
50 var auth_token = document.getElementById(
"cbid.aria2.main.rpc_secret");
51 newTextNode.value = protocol +
"://token:" + auth_token.value +
"@" + document.domain +
":" + auth_port_value +
"/jsonrpc";
52 } else if (auth_method.value ==
"user_pass") {
53 var auth_user = document.getElementById(
"cbid.aria2.main.rpc_user");
54 var auth_passwd = document.getElementById(
"cbid.aria2.main.rpc_passwd");
55 newTextNode.value = protocol +
"://" + auth_user.value +
":" + auth_passwd.value +
"@" + document.domain +
":" + auth_port_value +
"/jsonrpc";
57 newTextNode.value = protocol +
"://" + document.domain +
":" + auth_port_value +
"/jsonrpc";
61 function openWebUI(path) {
62 var curWwwPath = window.document.location.href;
63 var pathName = window.document.location.pathname;
64 var pos = curWwwPath.indexOf(pathName);
65 var localhostPath = curWwwPath.substring(
0, pos);
66 var url =
"http:" + localhostPath.substring(window.location.protocol.length) +
"/" + path;
71 <style>.mar-
10 {margin-left:
10px; margin-right:
10px;}
</style>
72 <fieldset class=
"cbi-section">
73 <legend><%:Aria2 Status%
></legend>
75 <em><%:Collecting data...%
></em>