2 Copyright
2008 Steven Barth
<steven@midlink.org
>
3 Copyright
2008-
2010 Jo-Philipp Wich
<jow@openwrt.org
>
4 Licensed to the public under the Apache License
2.0.
8 local sys = require
"luci.sys"
9 local util = require
"luci.util"
10 local http = require
"luci.http"
11 local disp = require
"luci.dispatcher"
12 local ver = require
"luci.version"
14 local sysinfo = util.ubus(
"system",
"info") or { }
15 local loadinfo = sysinfo.load or {
0,
0,
0 }
16 local boardinfo = util.ubus(
"system",
"board") or { }
18 local node = disp.context.dispatched
20 http.prepare_content(
"application/xhtml+xml")
23 <?xml version=
"1.0" encoding=
"utf-8"?>
24 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
25 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"<%=luci.i18n.context.lang%>" lang=
"<%=luci.i18n.context.lang%>">
27 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
28 <meta name=
"viewport" content=
"width=device-width, initial-scale=1" />
29 <meta http-equiv=
"Content-Script-Type" content=
"text/javascript" />
30 <link rel=
"stylesheet" type=
"text/css" media=
"screen" href=
"<%=media%>/cascade.css" />
31 <% if node and node.css then %
><link rel=
"stylesheet" type=
"text/css" media=
"screen" href=
"<%=resource%>/<%=node.css%>" />
33 <% if css then %
><style title=
"text/css">
37 <script type=
"text/javascript" src=
"<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
38 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
39 <script type=
"text/javascript" src=
"<%=resource%>/xhr.js"></script>
40 <script type=
"text/javascript">//<![CDATA[
42 function get_children(node) {
45 for (var k in node.children) {
46 if (!node.children.hasOwnProperty(k))
49 if (!node.children[k].satisfied)
52 if (!node.children[k].hasOwnProperty('title'))
55 children.push(Object.assign(node.children[k], { name: k }));
58 return children.sort(function(a, b) {
59 return ((a.order ||
1000) - (b.order ||
1000));
63 function handle_mainmenu_expand(ev) {
64 var a = ev.target, ul1 = a.parentNode.parentNode, ul2 = a.nextElementSibling;
66 document.querySelectorAll('ul.mainmenu.l1
> li.active').forEach(function(li) {
67 if (li !== a.parentNode)
68 li.classList.remove('active');
74 if (ul2.parentNode.offsetLeft + ul2.offsetWidth <= ul1.offsetLeft + ul1.offsetWidth)
75 ul2.classList.add('align-left');
77 ul1.classList.add('active');
78 a.parentNode.classList.add('active');
85 function render_mainmenu(tree, url, level) {
86 var l = (level ||
0) +
1,
87 ul = E('ul', { 'class': 'mainmenu l%d'.format(l) }),
88 children = get_children(tree);
90 if (children.length ==
0 || l
> 2)
93 for (var i =
0; i < children.length; i++) {
94 var isActive = (L.env.dispatchpath[l] == children[i].name),
95 activeClass = 'mainmenu-item-%s%s'.format(children[i].name, isActive ? ' selected' : '');
97 ul.appendChild(E('li', { 'class': activeClass }, [
99 'href': L.url(url, children[i].name),
100 'click': (l ==
1) ? handle_mainmenu_expand : null,
101 }, [ _(children[i].title) ]),
102 render_mainmenu(children[i], url + '/' + children[i].name, l)
107 var container = document.querySelector('#mainmenu');
109 container.appendChild(ul);
110 container.style.display = '';
116 function render_modemenu(tree) {
117 var ul = document.querySelector('#modemenu'),
118 children = get_children(tree);
120 for (var i =
0; i < children.length; i++) {
121 var isActive = (L.env.requestpath.length ? children[i].name == L.env.requestpath[
0] : i ==
0);
123 ul.appendChild(E('li', {}, [
125 'href': L.url(children[i].name),
126 'class': isActive ? 'active' : null
127 }, [ _(children[i].title) ])
131 render_mainmenu(children[i], children[i].name);
134 if (ul.children.length
> 1)
135 ul.style.display = '';
138 function render_tabmenu(tree, url, level) {
139 var container = document.querySelector('#tabmenu'),
140 l = (level ||
0) +
1,
141 ul = E('ul', { 'class': 'cbi-tabmenu' }),
142 children = get_children(tree),
145 if (children.length ==
0)
148 for (var i =
0; i < children.length; i++) {
149 var isActive = (L.env.dispatchpath[l +
2] == children[i].name),
150 activeClass = isActive ? ' cbi-tab' : '',
151 className = 'tabmenu-item-%s %s'.format(children[i].name, activeClass);
153 ul.appendChild(E('li', { 'class': className }, [
154 E('a', { 'href': L.url(url, children[i].name) }, [ _(children[i].title) ] )
158 activeNode = children[i];
161 container.appendChild(ul);
162 container.style.display = '';
165 container.appendChild(render_tabmenu(activeNode, url + '/' + activeNode.name, l));
170 document.addEventListener('luci-loaded', function(ev) {
171 var tree = <%= luci.http.write_json(luci.dispatcher.context.authsession and luci.dispatcher.menu_json() or {}) %
>,
175 render_modemenu(tree);
177 if (L.env.dispatchpath.length
>=
3) {
178 for (var i =
0; i <
3 && node; i++) {
179 node = node.children[L.env.dispatchpath[i]];
180 url = url + (url ? '/' : '') + L.env.dispatchpath[i];
184 render_tabmenu(node, url);
189 <title><%=striptags( (boardinfo.hostname or
"?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %
> - LuCI
</title>
191 <body class=
"lang_<%=luci.i18n.context.lang%>" data-page=
"<%= table.concat(disp.context.requestpath, "-
") %>">
194 <span id=
"skiplink1"><a href=
"#navigation"><%:Skip to navigation%
></a></span>
195 <span id=
"skiplink2"><a href=
"#content"><%:Skip to content%
></a></span>
199 <h2 class=
"navigation"><a id=
"navigation" name=
"navigation"><%:Navigation%
></a></h2>
201 <div class=
"hostinfo">
202 <%=(boardinfo.hostname or
"?")%
> | <%=ver.distversion%
> |
203 <%:Load%
>: <%=
"%.2f" % (loadinfo[
1] /
65535.0)%
> <%=
"%.2f" % (loadinfo[
2] /
65535.0)%
> <%=
"%.2f" % (loadinfo[
3] /
65535.0)%
>
204 <span id=
"xhr_poll_status" style=
"display:none" onclick=
"XHR.running() ? XHR.halt() : XHR.run()">
206 <span id=
"xhr_poll_status_on"><%:on%
></span>
207 <span id=
"xhr_poll_status_off" style=
"display:none"><%:off%
></span>
211 <ul id=
"modemenu" style=
"display:none"></ul>
213 <div class=
"clear"></div>
216 <div id=
"maincontainer">
217 <div id=
"mainmenu" style=
"display:none"></div>
219 <div id=
"maincontent">
220 <div id=
"tabmenu" style=
"display:none"></div>
223 <div class=
"alert-message warning">
224 <h4><%:JavaScript required!%
></h4>
225 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%
></p>
229 <%- if luci.sys.process.info(
"uid") ==
0 and luci.sys.user.getuser(
"root") and not luci.sys.user.getpasswd(
"root") and category ~=
"failsafe" then -%
>
230 <div class=
"alert-message warning">
231 <h4><%:No password set!%
></h4>
232 <p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%
></p>
233 <% if disp.lookup(
"admin/system/admin") then %
>
234 <div class=
"right"><a class=
"btn" href=
"<%=url("admin/system/admin
")%>"><%:Go to password configuration...%
></a></div>