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\');" />';
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 (auth_port.value == "") {
49 auth_port_value = "6800"
51 auth_port_value = auth_port.value
53 if (auth_method.value == "token") {
54 var auth_token = document.getElementById("cbid.aria2.main.rpc_secret");
55 newTextNode.value = protocol + "://token:" + auth_token.value + "@" + document.domain + ":" + auth_port_value + "/jsonrpc";
56 } else if (auth_method.value == "user_pass") {
57 var auth_user = document.getElementById("cbid.aria2.main.rpc_user");
58 var auth_passwd = document.getElementById("cbid.aria2.main.rpc_passwd");
59 newTextNode.value = protocol + "://" + auth_user.value + ":" + auth_passwd.value + "@" + document.domain + ":" + auth_port_value + "/jsonrpc";
61 newTextNode.value = protocol + "://" + document.domain + ":" + auth_port_value + "/jsonrpc";
65 function openWebUI(path) {
66 var curWwwPath = window.document.location.href;
67 var pathName = window.document.location.pathname;
68 var pos = curWwwPath.indexOf(pathName);
69 var localhostPath = curWwwPath.substring(0, pos);
70 var url = localhostPath + "/" + path;
75 <style>.mar-10 {margin-left: 10px; margin-right: 10px;}</style>
76 <fieldset class="cbi-section">
77 <legend><%:Aria2 Status%></legend>
79 <em><%:Collecting data...%></em>