themes: fix load number formatting
[project/luci.git] / themes / luci-theme-openwrt / luasrc / view / themes / openwrt.org / header.htm
1 <%#
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.
5 -%>
6
7 <%
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"
13
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 { }
17
18         local request  = disp.context.path
19         local request2 = disp.context.request
20
21         local category = request[1]
22         local cattree  = category and disp.node(category)
23
24         local leaf = request2[#request2]
25
26         local tree = disp.node()
27         local node = disp.context.dispatched
28
29         local categories = disp.node_childs(tree)
30
31         local c = tree
32         local i, r
33
34         -- tag all nodes leading to this page
35         for i, r in ipairs(request) do
36                 if c.nodes and c.nodes[r] then
37                         c = c.nodes[r]
38                         c._menu_selected = true
39                 end
40         end
41
42         http.prepare_content("application/xhtml+xml")
43
44         local function nodeurl(prefix, name, query)
45                 local url = controller .. prefix .. name .. "/"
46                 if query then
47                         url = url .. http.build_querystring(query)
48                 end
49                 return pcdata(url)
50         end
51
52         local function subtree(prefix, node, level)
53                 if not level then
54                         level = 1
55                 end
56
57                 local childs = disp.node_childs(node)
58                 if #childs > 0 then
59 %>
60         <div class="tabmenu<%=level%>">
61         <ul class="tabmenu l<%=level%>">
62                 <%
63                         local selected_node
64                         local selected_name
65                         local i, v
66
67                         for i, v in ipairs(childs) do
68                                 local nnode = node.nodes[v]
69                                 if nnode._menu_selected then
70                                         selected_node = nnode
71                                         selected_name = v
72                                 end
73                 %>
74                         <li class="tabmenu-item-<%=v%><% if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
75                                 <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
76                         </li>
77                 <%
78                         end
79                 %>
80         </ul>
81         <br style="clear:both" />
82 <%
83                         if selected_node then
84                                 subtree(prefix .. selected_name .. "/", selected_node, level + 1)
85                         end
86 %>
87         </div>
88 <%
89                 end
90         end
91 -%>
92
93 <?xml version="1.0" encoding="utf-8"?>
94 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
95 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
96 <head>
97 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
98 <meta http-equiv="Content-Script-Type" content="text/javascript" />
99 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
100 <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie6.css" /><![endif]-->
101 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
102 <!--[if IE 8]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie8.css" /><![endif]-->
103 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
104 <% end -%>
105 <% if css then %><style title="text/css">
106 <%= css %>
107 </style>
108 <% end -%>
109 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
110 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
111 </head>
112 <body class="lang_<%=luci.i18n.context.lang%>">
113
114 <p class="skiplink">
115 <span id="skiplink1"><a href="#navigation"><%:Skip to navigation%></a></span>
116 <span id="skiplink2"><a href="#content"><%:Skip to content%></a></span>
117 </p>
118
119 <div id="menubar">
120 <h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
121
122 <div class="hostinfo">
123         <%=(boardinfo.hostname or "?")%> | <%=ver.distversion%> |
124         <%:Load%>: <%="%.2f" % (loadinfo[1] / 65535.0)%> <%="%.2f" % (loadinfo[2] / 65535.0)%> <%="%.2f" % (loadinfo[3] / 65535.0)%>
125         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
126                 | <%:Auto Refresh%>:
127                 <span id="xhr_poll_status_on"><%:on%></span>
128                 <span id="xhr_poll_status_off" style="display:none"><%:off%></span>
129         </span>
130 </div>
131
132 <% if #categories > 1 then %>
133         <ul id="modemenu">
134                 <% for i, r in ipairs(categories) do %>
135                         <li><a<% if request[1] == r then %> class="active"<%end%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
136                 <% end %>
137         </ul>
138 <% end %>
139
140 <%
141 if tree.nodes[category] and tree.nodes[category].ucidata then
142         local ucic = 0
143         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
144                 for k, l in pairs(j) do
145                         for m, n in pairs(l) do
146                                 ucic = ucic + 1;
147                         end
148                 end
149         end
150 -%>
151 <div id="savemenu">
152         <% if ucic > 0 then %>
153                 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(luci.http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
154         <%- else -%>
155                 <a href="#"><%:Changes%>: 0</a>
156         <% end -%>
157 </div><% end %>
158
159 <div class="clear"></div>
160 </div>
161
162 <div id="maincontainer">
163         <div id="tabmenu">
164                 <% if category then subtree("/" .. category .. "/", cattree) end %>
165         </div>
166
167         <div id="maincontent">
168                 <noscript>
169                         <div class="errorbox">
170                                 <strong><%:Java Script required!%></strong><br />
171                                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
172                         </div>
173                 </noscript>
174
175                 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and category ~= "failsafe" then -%>
176                 <div class="errorbox">
177                         <strong><%:No password set!%></strong><br />
178                         <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br />
179                         <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
180                 </div>
181                 <%- end -%>