f2d9285bcab3484cc5c0795d2fd72a1c4c8735a5
[project/luci.git] / themes / freifunk / luasrc / view / themes / freifunk / 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         <link rel="shortcut icon" href="<%=media%>/images/favicon.ico" />
45         <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
46         <meta http-equiv="content-script-type" content="text/javascript" />
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 <div id="all">
68 <center>
69
70 <div id="wrapper">
71 <div id="main">
72
73
74 <div id="header">
75         <div id="headerleft">
76                 <div id="headerright">
77                         <div id="headerback">
78         <div id="schriftzug"><img src="<%=media%>/images/schriftzug.png" alt="Freifunk  ueberschrift" name="Freifunk_nordost_ueberschrift" border="0"> </div>
79         <div id="logo"><img src="<%=media%>/images/logo.png" alt="Freifunk logo" name="Freifunk_nordost" border="0"></a></div>
80         <div class="clear"></div>
81
82                         </div>
83                 </div>
84         </div>
85 </div>
86
87 <div class="pathbar separator black whitetext bold">
88 <%:Path%>: <%
89 local c = tree
90 local url = controller
91 for k,v in pairs(request) do
92         if c.nodes and c.nodes[v] then
93                 c = c.nodes[v]
94                 url = url .. "/" .. v
95         %><a href="<%=url%>"><%=pcdata(striptags(c.title or v))%></a> <% if k ~= #request then %>&#187; <% end
96         end
97 end
98 %>
99 </div>
100
101 <div class="menubar">
102         <div id="mainmenu" class="mainmenu">
103 <%-
104 local function submenu(prefix, node)
105         if not node.nodes or node.hidden then
106                 return false
107         end
108         local index = {}
109         local count = 0
110         for k, n in pairs(node.nodes) do
111                 if n.title and n.target then
112                         table.insert(index, {name=k, order=n.order or 100})
113                         count = count + 1
114                 end
115         end
116
117         table.sort(index, function(a, b) return a.order < b.order end)
118
119         if count > 0 then
120 %>
121         <ul>
122         <%- for j, v in pairs(index) do
123                 if not v.hidden and #v.name > 0 then
124                         local nnode = node.nodes[v.name]
125                         local href = controller .. prefix .. v.name
126                         href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
127                 %>
128                 <li>
129                         <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(nnode.title))%></a></span>
130                         <%- submenu(prefix .. v.name .. "/", nnode) %>
131                 </li>
132                 <%- end %>
133         <%- end %>
134         </ul>
135 <%-
136         end
137 end
138
139 if cattree and cattree.nodes then
140         local index = {}
141         for k, node in pairs(cattree.nodes) do
142                 table.insert(index, {name=k, order=node.order or 100})
143         end
144
145         table.sort(index, function(a, b) return a.order < b.order end)
146
147         for i, k in ipairs(index) do
148                 node = cattree.nodes[k.name]
149                 if not node.hidden and node.title and node.target then
150                         local href = controller.."/"..category.."/"..k.name
151                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
152                         <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(node.title))%></a>
153                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
154                         </div>
155 <%              end
156         end
157 end
158 %>
159         </div>
160         <div class="modemenu">
161                 <ul><%
162                         for k,node in pairs(tree.nodes) do
163                                 if node.title and not node.hidden then %>
164                                         <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=pcdata(node.title)%></a></li>
165 <%                              end
166                         end%>
167                 </ul>
168         </div>
169
170         <%
171                 if tree.nodes[category] and tree.nodes[category].ucidata then
172                         local ucic = 0
173
174                         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
175                                 for k, l in pairs(j) do
176                                         for m, n in pairs(l) do
177                                                 ucic = ucic + 1;
178                                         end
179                                 end
180                         end
181         %>
182         <div class="mainmenu" style="float:right; margin-right:2em">
183                 <div>
184                         <% if ucic > 0 then %>
185                         <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%>: <%=ucic%></a>
186                         <% submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
187                         <% else %>
188                         <a href="#"><%:Changes%>: 0</a>
189                         <% end %>
190                 </div>
191         </div>
192         <% end %>
193
194         <br class="clear" />
195 </div>
196 <div id="maincontent">