1ae5df92299f6c5f34cf09b407674cd7cd39ef57
[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
24 local c = tree
25 for i,r in ipairs(request) do
26         if c.nodes and c.nodes[r] then
27                 c = c.nodes[r]
28                 c._menu_selected = true
29         end
30 end
31
32 require("luci.i18n").loadc("default")
33
34 require("luci.http").prepare_content("text/html")
35 -%>
36
37 <?xml version="1.0" encoding="utf-8"?>
38 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
39 <html xmlns="http://www.w3.org/1999/xhtml">
40 <head>
41         <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
42         <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
43         <meta http-equiv="content-type" content="text/xhtml+xml; charset=utf-8" />
44         <meta http-equiv="content-script-type" content="text/javascript" />
45         <title>LuCI - Lua Configuration Interface - <%=(node and node.title)%></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="header">
66         <div class="info whitetext smalltext bold right">
67         <%=luci.config.brand.firmware%><br />
68         <%=luci.config.brand.distro%><br />
69         <%:load%>: <%=load1%> <%=load5%> <%=load15%><br />
70         <%:hostname%>: <%=luci.sys.hostname()%>
71         </div>
72         <div class="title">
73                 <span class="headertitle"><%=luci.config.brand.title%></span><br />
74                 <span class="whitetext bold"><%=luci.config.brand.subtitle%></span>
75         </div>
76 </div>
77
78 <div class="pathbar separator black whitetext bold">
79 <%:path%>: <%
80 local c = tree
81 local url = controller
82 for k,v in pairs(request) do
83         if c.nodes and c.nodes[v] then
84                 c = c.nodes[v]
85                 url = url .. "/" .. v
86         %><a href="<%=url%>"><%=c.title or v%></a> <% if k ~= #request then %>&#187; <% end
87         end
88 end
89 %>
90 </div>
91
92 <div class="menubar">
93         <div id="mainmenu" class="mainmenu">
94 <%
95 local function submenu(prefix, node)
96         if not node.nodes then
97                 return false
98         end
99         local index = {}
100         local count = 0
101         for k, n in pairs(node.nodes) do
102                 if n.title and n.target then
103                         table.insert(index, {name=k, order=n.order or 100})
104                         count = count + 1
105                 end
106         end
107
108         table.sort(index, function(a, b) return a.order < b.order end)
109
110         if count > 0 then
111 %>
112         <ul>
113         <% for j, v in pairs(index) do
114                 local nnode = node.nodes[v.name]
115                 local href = controller .. prefix .. v.name
116                 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
117                 %>
118                 <li>
119                         <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=href%>"><%=nnode.title%></a></span>
120                         <% submenu(prefix .. v.name .. "/", nnode) %>
121                 </li>
122         <% end %>
123         </ul>
124 <%
125         end
126 end
127
128 if cattree and cattree.nodes then
129         local index = {}
130         for k, node in pairs(cattree.nodes) do
131                 table.insert(index, {name=k, order=node.order or 100})
132         end
133
134         table.sort(index, function(a, b) return a.order < b.order end)
135
136         for i, k in ipairs(index) do
137                 node = cattree.nodes[k.name]
138                 if node.title and node.target then
139                         local href = controller.."/"..category.."/"..k.name
140                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
141                         <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=href%>"><%=node.title%></a>
142                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
143                         </div>
144 <%              end
145         end
146 end
147 %>
148         </div>
149         <div class="modemenu">
150                 <ul><%
151                         for k,node in pairs(tree.nodes) do
152                                 if node.title then %>
153                                         <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=node.title%></a></li>
154 <%                              end
155                         end%>
156                 </ul>
157         </div>
158
159         <%
160                 if "admin" == request[1] then
161                         local ucic = 0
162                         for i, j in pairs(require("luci.model.uci").changes()) do
163                                 for k, l in pairs(j) do
164                                         for m, n in pairs(l) do
165                                                 ucic = ucic + 1;
166                                         end
167                                 end
168                         end
169         %>
170         <div class="mainmenu" style="float:right; margin-right:2em">
171                 <div>
172                         <% if ucic > 0 then %>
173                         <a href="<%=controller%>/admin/uci/changes"><%:changes%>: <%=ucic%></a>
174                         <ul>
175                                 <li><a href="<%=controller%>/admin/uci/apply"><%:apply%></a></li>
176                                 <li><a href="<%=controller%>/admin/uci/revert"><%:revert%></a></li>
177                         </ul>
178                         <% else %>
179                         <a href="#"><%:changes%>: 0</a>
180                         <% end %>
181                 </div>
182         </div>
183         <% end %>
184
185         <br class="clear" />
186 </div>
187 <div id="content">