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