cd48bd7222a999f0d2f0235dac83a695c6ad7436
[project/luci.git] / themes / fledermaus / luasrc / view / themes / fledermaus / 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 <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
45 <meta http-equiv="content-script-type" content="text/javascript" />
46 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
47 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. node.title or '')) %> - LuCI</title>
48
49 <!--[if lt IE 7]>
50 <script type="text/javascript">
51 function setup_hover() {
52 function ie_hover(e) {
53 e.onmouseover = function() { this.className = "hover" }
54 e.onmouseout = function() { this.className = null }
55 }
56
57 var lis = document.getElementById("mainmenu").getElementsByTagName("LI");
58 var divs = document.getElementById("mainmenu").getElementsByTagName("DIV");
59
60 for( var i = 0; i < lis.length; i++ ) ie_hover( lis[i] );
61 for( var i = 0; i < divs.length; i++ ) ie_hover( divs[i] );
62 }
63 </script>
64 <![endif]-->
65 </head>
66 <body onload="window.setup_hover && setup_hover()">
67
68 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
69 <div class="warning">
70 <strong><%:No password set!%></strong><br />
71 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
72 </div>
73 <%- end -%>
74
75 <div id="header"><div id="header2">
76 <span id="header3">freifunk kamikaze</span><br />
77 <span id="header4">now with even more bats and stuff</span>
78 </div></div>
79
80 <div class="pathbar separator black whitetext bold">
81 <%:Path%>: <%
82 local c = tree
83 local url = controller
84 for k,v in pairs(request) do
85 if c.nodes and c.nodes[v] then
86 c = c.nodes[v]
87 url = url .. "/" .. v
88 %><a href="<%=url%>"><%=pcdata(striptags(c.title or v))%></a> <% if k ~= #request then %>&#187; <% end
89 end
90 end
91 %>
92 </div>
93
94 <div class="menubar">
95 <div id="mainmenu" class="mainmenu">
96 <%-
97 local function submenu(prefix, node)
98 if not node.nodes or node.hidden then
99 return false
100 end
101 local index = {}
102 local count = 0
103 for k, n in pairs(node.nodes) do
104 if n.title and n.target then
105 table.insert(index, {name=k, order=n.order or 100})
106 count = count + 1
107 end
108 end
109
110 table.sort(index, function(a, b) return a.order < b.order end)
111
112 if count > 0 then
113 %>
114 <ul>
115 <%- for j, v in pairs(index) do
116 if not v.hidden and #v.name > 0 then
117 local nnode = node.nodes[v.name]
118 local href = controller .. prefix .. v.name
119 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
120 %>
121 <li>
122 <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(nnode.title))%></a></span>
123 <%- submenu(prefix .. v.name .. "/", nnode) %>
124 </li>
125 <%- end %>
126 <%- end %>
127 </ul>
128 <%-
129 end
130 end
131
132 if cattree and cattree.nodes then
133 local index = {}
134 for k, node in pairs(cattree.nodes) do
135 table.insert(index, {name=k, order=node.order or 100})
136 end
137
138 table.sort(index, function(a, b) return a.order < b.order end)
139
140 for i, k in ipairs(index) do
141 node = cattree.nodes[k.name]
142 if not node.hidden and node.title and node.target then
143 local href = controller.."/"..category.."/"..k.name
144 href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
145 <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(node.title))%></a>
146 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
147 </div>
148 <% end
149 end
150 end
151 %>
152 </div>
153 <div class="modemenu">
154 <ul><%
155 for k,node in pairs(tree.nodes) do
156 if node.title and not node.hidden then %>
157 <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=pcdata(striptags(node.title))%></a></li>
158 <% end
159 end%>
160 </ul>
161 </div>
162
163 <%
164 if tree.nodes[category] and tree.nodes[category].ucidata then
165 local ucic = 0
166
167 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
168 for k, l in pairs(j) do
169 for m, n in pairs(l) do
170 ucic = ucic + 1;
171 end
172 end
173 end
174 %>
175 <div class="mainmenu" style="float:right; margin-right:2em">
176 <div>
177 <% if ucic > 0 then %>
178 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%>: <%=ucic%></a>
179 <% submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
180 <% else %>
181 <a href="#"><%:Changes%>: 0</a>
182 <% end %>
183 </div>
184 </div>
185 <% end %>
186
187 <br class="clear" />
188 </div>
189 <div id="maincontent">
190 <% if category ~= "freifunk" and category ~= "splash" then %>
191 <noscript>
192 <div class="warning">
193 <strong><%:Java Script required!%></strong><br />
194 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
195 </div>
196 </noscript>
197 <% end %>