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