05d9419a80c70207e5c27494147db6737c38e492
[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 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 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 url = controller .. prefix .. name .. "/"
58                 if query then
59                         url = url .. http.build_querystring(query)
60                 end
61                 return pcdata(url)
62         end
63
64         local function subtree(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         
72             if level > 2 then
73 %>
74         <ul class="tabs">
75                 <%  
76             end
77
78                         local selected_node
79                         local selected_name
80                         local i, v
81
82                         for i, v in ipairs(childs) do
83                                 local nnode = node.nodes[v]
84                                 if nnode._menu_selected then
85                                         selected_node = nnode
86                                         selected_name = v
87                                 end
88                 if level > 2 then
89                 %>
90                         <li class="tabmenu-item-<%=v%><%- if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
91                             <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
92                         </li>
93                 <%      end
94                         end
95             
96             if level > 2 then
97                 %>
98         </ul>
99 <%          end
100
101                         if selected_node then
102                                 subtree(prefix .. selected_name .. "/", selected_node, level + 1)
103                         end
104                 end
105         end
106 -%>
107 <!DOCTYPE html>
108 <html lang="<%=luci.i18n.context.lang%>">
109 <head>
110     <meta charset="utf-8">
111     <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
112     <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
113     <meta name="format-detection" content="telephone=no, email=no"/>
114     <meta name="apple-mobile-web-app-capable" content="yes">
115     <meta name="mobile-web-app-capable" content="yes">
116     <meta name="x5-fullscreen" content="true">
117     <meta name="full-screen" content="yes">
118     <meta name="x5-page-mode" content="app">
119     <meta name="browsermode" content="application">
120     <meta name="theme-color" content="#0099CC">
121     <meta name="msapplication-tap-highlight" content="no">
122     <meta name="msapplication-TileColor" content="#0099CC">
123     <meta name="msapplication-TileImage" content="<%=media%>/logo.png"/>
124     <link rel="stylesheet" href="<%=media%>/css/style.css">
125     <link rel="shortcut icon" href="<%=media%>/favicon.ico">
126     <% if node and node.css then %>
127         <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
128     <% end -%>
129     <% if css then %>
130         <style title="text/css">
131             <%-= css %>
132         </style>
133     <% end -%>
134     <script src="<%=resource%>/xhr.js"></script>
135 </head>
136
137 <body class="lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %>">
138
139 <header>
140         <div class="container">
141                 <span class="showSide"></span>
142                 <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
143                 <div class="pull-right">
144                 <%
145                 -- calculate the number of unsaved changes
146                 if tree.nodes[category] and tree.nodes[category].ucidata then
147                         local ucichanges = 0
148                         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
149                                 for k, l in pairs(j) do
150                                         for m, n in pairs(l) do
151                                                 ucichanges = ucichanges + 1;
152                                         end
153                                 end
154                         end
155                         %>
156                         <% if ucichanges > 0 then %>
157                         <a class="label notice" href="<%=controller%>/<%=category%>/uci/changes"><span class="mobile-hide"><%:Unsaved Changes%>: </span><%=ucichanges%></a>
158                         <% end %>
159                         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
160                                 <span class="label success" id="xhr_poll_status_on"><span class="mobile-hide"><%:Auto Refresh%> </span><%:on%></span>
161                                 <span class="label" id="xhr_poll_status_off" style="display:none"><span class="mobile-hide"><%:Auto Refresh%> </span><%:off%></span>
162                         </span>
163                 <% end %>
164                 </div>
165         </div>
166 </header>
167
168  <div class="main">
169          <div style="" class="loading"><span><div class="loading-img"></div>Loading...</span></div>
170          <div class="main-left">
171                  <ul class="nav">
172                          <%-
173                          local function submenu(prefix, node)
174                          local childs = disp.node_childs(node)
175                          if #childs > 0 then
176                          %>
177                          <ul class="slide-menu">
178                                  <%-
179                                  for i, r in ipairs(childs) do
180                                  local nnode = node.nodes[r]
181                                  local href  = controller .. prefix .. r ..
182                                  (nnode.query and http.build_querystring(nnode.query) or "")
183                                  %>
184                                  <li><a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></li>
185                                  <%-
186                                  end
187                                  %>
188                          </ul>
189                          <%-
190                          end
191                          end
192
193                          childs = disp.node_childs(cattree)
194
195                          if #childs > 0 then
196                          for i, r in ipairs(childs) do
197                          local nnode = cattree.nodes[r]
198                          local href  = controller .. "/" .. category .. "/" .. r ..
199                          (nnode.query and http.build_querystring(k.query) or "")
200                          local grandchildren = disp.node_childs(nnode)
201
202                          if #grandchildren > 0 then
203                          %>
204                          <li class="slide">
205                                  <a class="menu" data-title="<%=pcdata(striptags(nnode.title))%>" href="#"><%=pcdata(striptags(translate(nnode.title)))%></a>
206                                  <%- submenu("/" .. category .. "/" .. r .. "/", nnode) %>
207                          </li>
208                          <%          else %>
209                          <li>
210                                  <a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
211                          </li>
212                          <%
213                          end
214                          end
215                          end
216                          %>
217                  </ul>
218          </div>
219          <div class="main-right">
220                  <div class="darkMask"></div>
221                  <div id="maincontent">
222                          <div class="container">
223                                  <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
224                                          <div class="alert-message warning">
225                                                  <h4><%:No password set!%></h4>
226                                                  <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br>
227                                                  <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
228                                          </div>
229                                  <%- end -%>
230                                  <% if category then subtree("/" .. category .. "/", cattree) end %>
231