* luci/themes/openwrt.org: added usability patch thanks Alina!
[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 require("luci.http").prepare_content("application/xhtml+xml")
35
36 -%>
37 <?xml version="1.0" encoding="utf-8"?>
38 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
39 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.config.main.lang%>" lang="<%=luci.config.main.lang%>">
40 <head>
41 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
42 <meta http-equiv="Content-Script-Type" content="text/javascript" />
43 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
44 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
45 <% end -%>
46 <script type="text/javascript" src="<%=media%>/VarType.js"></script>
47 <script type="text/javascript" src="<%=media%>/XHTML1.js"></script>
48 <script type="text/javascript" src="<%=media%>/Dropdowns.js"></script>
49 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. node.title or '')) %> - LuCI</title>
50 </head>
51 <body class="lang_<%=luci.config.main.lang%>">
52
53 <p class="skiplink">
54 <span id="skiplink1"><a href="#navigation"><%:skiplink1 Skip to navigation%></a></span>
55 <span id="skiplink2"><a href="#content"><%:skiplink2 Skip to content%></a></span>
56 </p>
57
58 <div id="header">
59 <h1><%=luci.config.brand.firmware%></h1>
60 <p>
61 <%=luci.config.brand.distro%><br />
62 <%:load%>: <%=load1%> <%=load5%> <%=load15%><br />
63 <%:hostname%>: <%=hostname%>
64 </p>
65 </div>
66
67 <div id="menubar">
68 <h2 class="navigation"><a id="navigation" name="navigation"><%:navigation Navigation%></a></h2>
69 <ul id="mainmenu" class="dropdowns">
70 <%-
71 local function submenu(prefix, node)
72         if not node.nodes or node.hidden then
73                 return false
74         end
75         local index = {}
76         local count = 0
77         for k, n in pairs(node.nodes) do
78                 if n.title and n.target then
79                         table.insert(index, {name=k, order=n.order or 100})
80                         count = count + 1
81                 end
82         end
83
84         table.sort(index, function(a, b) return a.order < b.order end)
85
86         if count > 0 then
87 %>
88 <ul id="submenu_<%=string.gsub(string.gsub(prefix, "/", "_"), "^_(.-)_$", "%1")%>">
89 <%-
90                 for j, v in pairs(index) do
91                         if #v.name > 0 then
92                                 local nnode = node.nodes[v.name]
93                                 local href = controller .. prefix .. v.name .. "/"
94                                 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
95 %>
96 <li><a<% if nnode._menu_selected then %> class="active"<%end%> href="<%=luci.util.pcdata(href)%>"><%=nnode.title%></a><%-
97 submenu(prefix .. v.name .. "/", nnode)
98 %></li>
99 <%-
100                         end
101                 end
102 %>
103 </ul>
104 <%
105         end
106 end
107
108 if cattree and cattree.nodes then
109         local index = {}
110         for k, node in pairs(cattree.nodes) do
111                 table.insert(index, {name=k, order=node.order or 100})
112         end
113
114         table.sort(index, function(a, b) return a.order < b.order end)
115
116         for i, k in ipairs(index) do
117                 node = cattree.nodes[k.name]
118                 if node.title and node.target and not node.hidden then
119                         local href = controller.."/"..category.."/"..k.name.."/"
120                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href
121 %>
122 <li><a<% if node._menu_selected then %> class="preactive"<%end%> href="<%=href%>"><%=node.title%></a><%
123 submenu("/" .. category .. "/" .. k.name .. "/", node)
124 %></li><% end
125         end
126 end
127 %>
128 </ul>
129
130 <ul id="modemenu"><%
131 for k,node in pairs(tree.nodes) do
132         if node.title and not node.hidden then %>
133 <li><a<% if request[1] == k then %> class="active"<%end%> href="<%=controller%>/<%=k%>/"><%=node.title%></a></li><%     
134         end
135 end
136 %>
137 </ul>
138
139 <%
140 if tree.nodes[category] and tree.nodes[category].ucidata then
141         local ucic = 0
142         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
143                 for k, l in pairs(j) do
144                         for m, n in pairs(l) do
145                                 ucic = ucic + 1;
146                         end
147                 end
148         end
149 -%>
150 <ul id="savemenu" class="dropdowns">
151 <li><% if ucic > 0 then %><a class="warning" href="<%=controller%>/<%=category%>/uci/changes/"><%:unsavedchanges%>: <%=ucic%></a><%
152 submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"])
153 else -%>
154 <a href="#"><%:changes%>: 0</a><% end -%>
155 </li>
156 </ul><% end %>
157
158 <div class="clear"></div>
159 </div>
160 <div id="maincontent">