3cd2b1af2a8be90657ae3e18b2708b70b1f24cd9
[project/luci.git] / themes / openwrt.org / luasrc / view / themes / openwrt.org / 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("default")
34
35 require("luci.http").prepare_content("text/html")
36 -%>
37
38 <?xml version="1.0" encoding="utf-8"?>
39 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.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="text/xhtml+xml; charset=utf-8" />
45         <meta http-equiv="content-script-type" content="text/javascript" />
46         <title><%=hostname%> - <%=(node and node.title)%> - LuCI</title>
47
48         <!--[if lt IE 7]>
49                 <script type="text/javascript">
50                         function setup_hover() {
51                                 function ie_hover(e) {
52                                         e.onmouseover = function() { this.className = "hover" }
53                                         e.onmouseout  = function() { this.className = null    }
54                                 }
55
56                                 var lis  = document.getElementById("mainmenu").getElementsByTagName("LI");
57                                 var divs = document.getElementById("mainmenu").getElementsByTagName("DIV");
58                                 
59                                 for( var i = 0; i < lis.length;  i++ ) ie_hover( lis[i]  );
60                                 for( var i = 0; i < divs.length; i++ ) ie_hover( divs[i] );
61                         }
62                 </script>
63         <![endif]-->
64 </head>
65 <body onload="window.setup_hover && setup_hover()">
66 <div id="header">
67         <div class="info whitetext smalltext bold right">
68         <%=luci.config.brand.firmware%><br />
69         <%=luci.config.brand.distro%><br />
70         <%:load%>: <%=load1%> <%=load5%> <%=load15%><br />
71         <%:hostname%>: <%=hostname%>
72         </div>
73         <div class="title">
74                 <span class="headertitle"><%=luci.config.brand.title%></span><br />
75                 <span class="whitetext bold"><%=luci.config.brand.subtitle%></span>
76         </div>
77 </div>
78
79 <div class="pathbar separator black whitetext bold">
80 <%:path%>: <%
81 local c = tree
82 local url = controller
83 for k,v in pairs(request) do
84         if c.nodes and c.nodes[v] then
85                 c = c.nodes[v]
86                 url = url .. "/" .. v
87         %><a href="<%=url%>"><%=c.title or v%></a> <% if k ~= #request then %>&#187; <% end
88         end
89 end
90 %>
91 </div>
92
93 <div class="menubar">
94         <div id="mainmenu" class="mainmenu">
95 <%-
96 local function submenu(prefix, node)
97         if not node.nodes then
98                 return false
99         end
100         local index = {}
101         local count = 0
102         for k, n in pairs(node.nodes) do
103                 if n.title and n.target then
104                         table.insert(index, {name=k, order=n.order or 100})
105                         count = count + 1
106                 end
107         end
108
109         table.sort(index, function(a, b) return a.order < b.order end)
110
111         if count > 0 then
112 %>
113         <ul>
114         <%- for j, v in pairs(index) do
115                 if #v.name > 0 then
116                         local nnode = node.nodes[v.name]
117                         local href = controller .. prefix .. v.name
118                         href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
119                 %>
120                 <li>
121                         <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=href%>"><%=nnode.title%></a></span>
122                         <%- submenu(prefix .. v.name .. "/", nnode) %>
123                 </li>
124                 <%- end %>
125         <%- end %>
126         </ul>
127 <%-
128         end
129 end
130
131 if cattree and cattree.nodes then
132         local index = {}
133         for k, node in pairs(cattree.nodes) do
134                 table.insert(index, {name=k, order=node.order or 100})
135         end
136
137         table.sort(index, function(a, b) return a.order < b.order end)
138
139         for i, k in ipairs(index) do
140                 node = cattree.nodes[k.name]
141                 if node.title and node.target then
142                         local href = controller.."/"..category.."/"..k.name
143                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
144                         <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=href%>"><%=node.title%></a>
145                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
146                         </div>
147 <%              end
148         end
149 end
150 %>
151         </div>
152         <div class="modemenu">
153                 <ul><%
154                         for k,node in pairs(tree.nodes) do
155                                 if node.title then %>
156                                         <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=node.title%></a></li>
157 <%                              end
158                         end%>
159                 </ul>
160         </div>
161
162         <%
163                 if tree.nodes[category] and tree.nodes[category].ucidata then
164                         local ucic = 0
165                         for i, j in pairs(require("luci.model.uci").changes()) do
166                                 for k, l in pairs(j) do
167                                         for m, n in pairs(l) do
168                                                 ucic = ucic + 1;
169                                         end
170                                 end
171                         end
172         %>
173         <div class="mainmenu" style="float:right; margin-right:2em">
174                 <div>
175                         <% if ucic > 0 then %>
176                         <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:unsavedchanges%>: <%=ucic%></a>
177                         <ul>
178                                 <li><a href="<%=controller%>/<%=category%>/uci/apply"><%:apply%></a></li>
179                                 <li><a href="<%=controller%>/<%=category%>/uci/revert"><%:revert%></a></li>
180                         </ul>
181                         <% else %>
182                         <a href="#"><%:changes%>: 0</a>
183                         <% end %>
184                 </div>
185         </div>
186         <% end %>
187
188         <br class="clear" />
189 </div>
190 <div id="content">