themes/openwrt.org: use ~= instead of not ( ... == ... )
[project/luci.git] / themes / openwrt / luasrc / view / themes / openwrt.org / header.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
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         local sys  = require "luci.sys"
17         local http = require "luci.http"
18         local disp = require "luci.dispatcher"
19
20         local hostname = sys.hostname()
21         local load1, load5, load15 = sys.loadavg()
22
23         local request  = disp.context.path
24         local request2 = disp.context.request
25
26         local category = request[1]
27         local cattree  = category and disp.node(category)
28
29         local leaf = request2[#request2]
30
31         local tree = disp.node()
32         local node = disp.context.dispatched
33
34         local categories = disp.node_childs(tree)
35
36         local c = tree
37         local i, r
38
39         -- tag all nodes leading to this page
40         for i, r in ipairs(request) do
41                 if c.nodes and c.nodes[r] then
42                         c = c.nodes[r]
43                         c._menu_selected = true
44                 end
45         end
46
47         http.prepare_content("application/xhtml+xml")
48
49         local function nodeurl(prefix, name, query)
50                 local url = controller .. prefix .. name .. "/"
51                 if query then
52                         url = url .. http.build_querystring(query)
53                 end
54                 return pcdata(url)
55         end
56
57         local function subtree(prefix, node, level)
58                 if not level then
59                         level = 1
60                 end
61
62                 local childs = disp.node_childs(node)
63                 if #childs > 0 then
64 %>
65         <div class="tabmenu<%=level%>">
66         <ul class="tabmenu l<%=level%>">
67                 <%
68                         local selected_node
69                         local selected_name
70                         local i, v
71
72                         for i, v in ipairs(childs) do
73                                 local nnode = node.nodes[v]
74                                 if nnode._menu_selected then
75                                         selected_node = nnode
76                                         selected_name = v
77                                 end
78                 %>
79                         <li class="tabmenu-item-<%=v%><% if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
80                                 <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
81                         </li>
82                 <%
83                         end
84                 %>
85         </ul>
86         <br style="clear:both" />
87 <%
88                         if selected_node then
89                                 subtree(prefix .. selected_name .. "/", selected_node, level + 1)
90                         end
91 %>
92         </div>
93 <%
94                 end
95         end
96 -%>
97
98 <?xml version="1.0" encoding="utf-8"?>
99 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
100 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
101 <head>
102 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
103 <meta http-equiv="Content-Script-Type" content="text/javascript" />
104 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
105 <!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie6.css" /><![endif]-->
106 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
107 <!--[if IE 8]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie8.css" /><![endif]-->
108 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
109 <% end -%>
110 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
111 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
112 </head>
113 <body class="lang_<%=luci.i18n.context.lang%>">
114
115 <p class="skiplink">
116 <span id="skiplink1"><a href="#navigation"><%:Skip to navigation%></a></span>
117 <span id="skiplink2"><a href="#content"><%:Skip to content%></a></span>
118 </p>
119
120 <div id="menubar">
121 <h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
122
123 <div class="hostinfo">
124         <%=hostname%> | <%=luci.version.distversion%> |
125         <%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%>
126         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
127                 | <%:Auto Refresh%>:
128                 <span id="xhr_poll_status_on"><%:on%></span>
129                 <span id="xhr_poll_status_off" style="display:none"><%:off%></span>
130         </span>
131 </div>
132
133 <% if #categories > 1 then %>
134         <ul id="modemenu">
135                 <% for i, r in ipairs(categories) do %>
136                         <li><a<% if request[1] == r then %> class="active"<%end%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
137                 <% end %>
138         </ul>
139 <% end %>
140
141 <%
142 if tree.nodes[category] and tree.nodes[category].ucidata then
143         local ucic = 0
144         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
145                 for k, l in pairs(j) do
146                         for m, n in pairs(l) do
147                                 ucic = ucic + 1;
148                         end
149                 end
150         end
151 -%>
152 <div id="savemenu">
153         <% if ucic > 0 then %>
154                 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=luci.http.urlencode(luci.http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
155         <%- else -%>
156                 <a href="#"><%:Changes%>: 0</a>
157         <% end -%>
158 </div><% end %>
159
160 <div class="clear"></div>
161 </div>
162
163 <div id="maincontainer">
164         <div id="tabmenu">
165                 <% if category then subtree("/" .. category .. "/", cattree) end %>
166         </div>
167
168         <div id="maincontent">
169                 <noscript>
170                         <div class="errorbox">
171                                 <strong><%:Java Script required!%></strong><br />
172                                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
173                         </div>
174                 </noscript>
175
176                 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") and category ~= "failsafe" then -%>
177                 <div class="errorbox">
178                         <strong><%:No password set!%></strong><br />
179                         <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br />
180                         <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
181                 </div>
182                 <%- end -%>