luci-theme-material: make 'Loading...' text translatable
[project/luci.git] / themes / luci-theme-material / luasrc / view / themes / material / header.htm
1 <%#
2 Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI
3
4 luci-theme-material
5 Copyright 2015-2017 Lutty Yang <lutty@wcan.in>
6
7 Have a bug? Please create an issue here on GitHub!
8 https://github.com/LuttyYang/luci-theme-material/issues
9
10 luci-theme-bootstrap:
11 Copyright 2008 Steven Barth <steven@midlink.org>
12 Copyright 2008-2016 Jo-Philipp Wich <jow@openwrt.org>
13 Copyright 2012 David Menting <david@nut-bolt.nl>
14
15 MUI:
16 https://github.com/muicss/mui
17
18 Licensed to the public under the Apache License 2.0
19 -%>
20
21 <%
22 local sys = require "luci.sys"
23 local util = require "luci.util"
24 local http = require "luci.http"
25 local disp = require "luci.dispatcher"
26
27 local boardinfo = util.ubus("system", "board")
28
29 local request = disp.context.path
30 local request2 = disp.context.request
31
32 local category = request[1]
33 local cattree = category and disp.node(category)
34
35 local leaf = request2[#request2]
36
37 local tree = disp.node()
38 local node = disp.context.dispatched
39
40 local categories = disp.node_childs(tree)
41
42 local c = tree
43 local i, r
44
45 -- tag all nodes leading to this page
46 for i, r in ipairs(request) do
47 if c.nodes and c.nodes[r] then
48 c = c.nodes[r]
49 c._menu_selected = true
50 end
51 end
52
53 -- send as HTML5
54 http.prepare_content("text/html")
55
56 local function nodeurl(prefix, name, query)
57 local u = url(prefix, name)
58 if query then
59 u = u .. http.build_querystring(query)
60 end
61 return pcdata(u)
62 end
63
64 local function render_tabmenu(prefix, node, level)
65 if not level then
66 level = 1
67 end
68
69 local childs = disp.node_childs(node)
70 if #childs > 0 then
71 if level > 2 then
72 write('<ul class="tabs">')
73 end
74
75 local selected_node
76 local selected_name
77 local i, v
78
79 for i, v in ipairs(childs) do
80 local nnode = node.nodes[v]
81 if nnode._menu_selected then
82 selected_node = nnode
83 selected_name = v
84 end
85
86 if level > 2 then
87 write('<li class="tabmenu-item-%s %s"><a href="%s">%s</a></li>' %{
88 v, (nnode._menu_selected or (node.leaf and v == leaf)) and 'active' or '',
89 nodeurl(prefix, v, nnode.query),
90 striptags(translate(nnode.title))
91 })
92 end
93 end
94
95 if level > 2 then
96 write('</ul>')
97 end
98
99 if selected_node then
100 render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1)
101 end
102 end
103 end
104
105 local function render_submenu(prefix, node)
106 local childs = disp.node_childs(node)
107 if #childs > 0 then
108 write('<ul class="slide-menu">')
109
110 for i, r in ipairs(childs) do
111 local nnode = node.nodes[r]
112 local title = striptags(translate(nnode.title))
113
114 write('<li><a data-title="%s" href="%s">%s</a></li>' %{
115 title,
116 nodeurl(prefix, r, nnode.query),
117 title
118 })
119 end
120
121 write('</ul>')
122 end
123 end
124
125 local function render_topmenu()
126 local childs = disp.node_childs(cattree)
127 if #childs > 0 then
128 write('<ul class="nav">')
129
130 for i, r in ipairs(childs) do
131 local nnode = cattree.nodes[r]
132 local grandchildren = disp.node_childs(nnode)
133
134 if #grandchildren > 0 then
135 local title = striptags(translate(nnode.title))
136
137 write('<li class="slide"><a class="menu" data-title="%s" href="#">%s</a>' %{
138 title,
139 title
140 })
141
142 render_submenu(category .. "/" .. r, nnode)
143 write('</li>')
144 else
145 local title = striptags(translate(nnode.title))
146
147 write('<li><a data-title="%s" href="%s">%s</a></li>' %{
148 title,
149 nodeurl(category, r, nnode.query),
150 title
151 })
152 end
153 end
154
155 write('</ul>')
156 end
157 end
158
159 local function render_changes()
160 -- calculate the number of unsaved changes
161 if tree.nodes[category] and tree.nodes[category].ucidata then
162 local ucichanges = 0
163 local i, j
164 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
165 ucichanges = ucichanges + #j
166 end
167
168 if ucichanges > 0 then
169 write('<a class="uci_change_indicator label notice" href="%s?redir=%s">%s: %d</a>' %{
170 url(category, 'uci/changes'),
171 http.urlencode(http.formvalue('redir') or table.concat(disp.context.request, "/")),
172 translate('Unsaved Changes'),
173 ucichanges
174 })
175 end
176 end
177 end
178 -%>
179 <!DOCTYPE html>
180 <html lang="<%=luci.i18n.context.lang%>">
181 <head>
182 <meta charset="utf-8">
183 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
184 <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
185 <meta name="apple-mobile-web-app-capable" content="yes">
186 <meta name="mobile-web-app-capable" content="yes">
187 <meta name="theme-color" content="#09c">
188 <meta name="msapplication-tap-highlight" content="no">
189 <meta name="msapplication-TileColor" content="#09c">
190 <meta name="application-name" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
191 <meta name="apple-mobile-web-app-title" content="<%=striptags( (boardinfo.hostname or "?") ) %> - LuCI">
192 <link rel="stylesheet" href="<%=media%>/cascade.css">
193 <link rel="shortcut icon" href="<%=media%>/favicon.ico">
194 <% if node and node.css then %>
195 <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
196 <% end -%>
197 <% if css then %>
198 <style title="text/css"><%= css %></style>
199 <% end -%>
200 <script src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
201 <script src="<%=resource%>/cbi.js"></script>
202 <script src="<%=resource%>/xhr.js"></script>
203 </head>
204 <body class="lang_<%=luci.i18n.context.lang%> <% if node then %><%= striptags( node.title ) %><% end %> <% if luci.dispatcher.context.authsession then %>logged-in<% end %>" data-page="<%= table.concat(disp.context.requestpath, "-") %>">
205 <header>
206 <div class="fill">
207 <div class="container">
208 <span class="showSide"></span>
209 <a id="logo" href="<%=url("admin/status/overview")%>"><img src="<%=media%>/brand.png" alt="OpenWrt"></a>
210 <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
211 <div class="status">
212 <% render_changes() %>
213 <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
214 <span class="label success" id="xhr_poll_status_on"><span class="mobile-hide"><%:Auto Refresh%></span> <%:on%></span>
215 <span class="label" id="xhr_poll_status_off" style="display:none"><span class="mobile-hide"><%:Auto Refresh%></span> <%:off%></span>
216 </span>
217 </div>
218 </div>
219 </div>
220 </header>
221 <div class="main">
222 <div style="" class="loading"><span><div class="loading-img"></div><%:Loading...%></span></div>
223 <div class="main-left">
224 <% render_topmenu() %>
225 </div>
226 <div class="main-right">
227 <div class="darkMask"></div>
228 <div id="maincontent">
229 <div class="container">
230 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
231 <div class="alert-message warning">
232 <h4><%:No password set!%></h4>
233 <p><%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%></p>
234 <% if disp.lookup("admin/system/admin") then %>
235 <div class="right"><a class="btn" href="<%=url("admin/system/admin")%>"><%:Go to password configuration...%></a></div>
236 <% end %>
237 </div>
238 <%- end -%>
239
240 <noscript>
241 <div class="alert-message warning">
242 <h4><%:JavaScript required!%></h4>
243 <p><%:You must enable JavaScript in your browser or LuCI will not work properly.%></p>
244 </div>
245 </noscript>
246
247 <% if category then render_tabmenu(category, cattree) end %>