themes: eliminate uses of luci.sys.loadavg()
[project/luci.git] / themes / luci-theme-freifunk-bno / luasrc / view / themes / freifunk-bno / header.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13
14 -%>
15 <%
16 require("luci.sys")
17 require("luci.util")
18
19 local boardinfo = luci.util.ubus("system", "board")
20
21 local request  = require("luci.dispatcher").context.path
22 local category = request[1]
23 local tree     = luci.dispatcher.node()
24 local cattree  = category and luci.dispatcher.node(category)
25 local node     = luci.dispatcher.context.dispatched
26
27 local c = tree
28 for i,r in ipairs(request) do
29         if c.nodes and c.nodes[r] then
30                 c = c.nodes[r]
31                 c._menu_selected = true
32         end
33 end
34
35 require("luci.http").prepare_content("text/html")
36
37 -%>
38
39 <?xml version="1.0" encoding="utf-8"?>
40 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
41 <html xmlns="http://www.w3.org/1999/xhtml">
42 <head>
43         <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
44         <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
45         <% if css then %><style title="text/css">
46         <%-= css %>
47         </style>
48         <% end -%>
49         <link rel="shortcut icon" href="<%=media%>/images/favicon.ico" />
50         <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
51         <meta http-equiv="content-script-type" content="text/javascript" />
52         <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
53         <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
54
55         <!--[if lt IE 7]>
56                 <script type="text/javascript">
57                         function setup_hover() {
58                                 function ie_hover(e) {
59                                         e.onmouseover = function() { this.className = "hover" }
60                                         e.onmouseout  = function() { this.className = null    }
61                                 }
62
63                                 var lis  = document.getElementById("mainmenu").getElementsByTagName("LI");
64                                 var divs = document.getElementById("mainmenu").getElementsByTagName("DIV");
65
66                                 for( var i = 0; i < lis.length;  i++ ) ie_hover( lis[i]  );
67                                 for( var i = 0; i < divs.length; i++ ) ie_hover( divs[i] );
68                         }
69                 </script>
70         <![endif]-->
71 </head>
72 <body onload="window.setup_hover && setup_hover()">
73 <div id="all">
74 <center>
75
76 <div id="wrapper">
77 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
78         <div class="warning">
79                 <strong><%:No password set!%></strong><br />
80                 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
81         </div>
82 <%- end -%>
83 <div id="main">
84
85
86 <div id="header">
87         <div id="headerleft">
88                 <div id="headerright">
89                         <div id="headerback">
90         <div id="schriftzug"><img src="<%=media%>/images/schriftzug.gif" alt="Freifunk Nordost ueberschrift" name="Freifunk_nordost_ueberschrift" border="0"> </div>
91         <div id="logo"><img src="<%=media%>/images/logo.gif" alt="Freifunk Nordost logo" name="Freifunk_nordost" border="0"></a></div>
92         <div class="clear"></div>
93
94                         </div>
95                 </div>
96         </div>
97 </div>
98
99 <div class="pathbar separator black whitetext bold">
100 <%:Path%>: <%
101 local c = tree
102 local url = controller
103 for k,v in pairs(request) do
104         if c.nodes and c.nodes[v] then
105                 c = c.nodes[v]
106                 url = url .. "/" .. v
107         %><a href="<%=url%>"><%=pcdata(striptags(translate(c.title) or v))%></a> <% if k ~= #request then %>&#187; <% end
108         end
109 end
110 %>
111 </div>
112
113 <div class="menubar">
114         <div id="mainmenu" class="mainmenu">
115 <%-
116 local function submenu(prefix, node)
117         if not node.nodes or node.hidden then
118                 return false
119         end
120         local index = {}
121         local count = 0
122         for k, n in pairs(node.nodes) do
123                 if n.title and n.target then
124                         table.insert(index, {name=k, order=n.order or 100})
125                         count = count + 1
126                 end
127         end
128
129         table.sort(index, function(a, b) return a.order < b.order end)
130
131         if count > 0 then
132 %>
133         <ul>
134         <%- for j, v in pairs(index) do
135                 if not v.hidden and #v.name > 0 then
136                         local nnode = node.nodes[v.name]
137                         local href = controller .. prefix .. v.name
138                         href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
139                 %>
140                 <li>
141                         <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></span>
142                         <%- submenu(prefix .. v.name .. "/", nnode) %>
143                 </li>
144                 <%- end %>
145         <%- end %>
146         </ul>
147 <%-
148         end
149 end
150
151 if cattree and cattree.nodes then
152         local index = {}
153         for k, node in pairs(cattree.nodes) do
154                 table.insert(index, {name=k, order=node.order or 100})
155         end
156
157         table.sort(index, function(a, b) return a.order < b.order end)
158
159         for i, k in ipairs(index) do
160                 node = cattree.nodes[k.name]
161                 if not node.hidden and node.title and node.target then
162                         local href = controller.."/"..category.."/"..k.name
163                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
164                         <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(node.title)))%></a>
165                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
166                         </div>
167 <%              end
168         end
169 end
170 %>
171         </div>
172         <div class="modemenu">
173                 <ul><%
174                         for k,node in pairs(tree.nodes) do
175                                 if node.title and not node.hidden then %>
176                                         <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=pcdata(striptags(translate(node.title)))%></a></li>
177 <%                              end
178                         end%>
179                 </ul>
180         </div>
181
182         <%
183                 if tree.nodes[category] and tree.nodes[category].ucidata then
184                         local ucic = 0
185
186                         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
187                                 for k, l in pairs(j) do
188                                         for m, n in pairs(l) do
189                                                 ucic = ucic + 1;
190                                         end
191                                 end
192                         end
193         %>
194         <div class="mainmenu" style="float:right; margin-right:2em">
195                 <div>
196                         <% if ucic > 0 then %>
197                         <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%>: <%=ucic%></a>
198                         <% submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
199                         <% else %>
200                         <a href="#"><%:Changes%>: 0</a>
201                         <% end %>
202                 </div>
203         </div>
204         <% end %>
205
206         <br class="clear" />
207 </div>
208
209 <div id="maincontent">
210 <% if category ~= "freifunk" and category ~= "splash" then %>
211 <noscript>
212         <div class="errorbox">
213                 <strong><%:Java Script required!%></strong><br />
214                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
215         </div>
216 </noscript>
217 <% end %>