luci-app-alpha-config: Migration for navbar

This commit is contained in:
Hilman Maulana 2024-02-22 22:47:02 +07:00 committed by GitHub
parent 9d9d94e6fc
commit 40350a9c91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,49 +17,62 @@
Licensed to the public under the Apache License 2.0 Licensed to the public under the Apache License 2.0
-%> -%>
<%
local ver = require "luci.version"
local uci = require "luci.model.uci".cursor()
local config = uci:get_all("alpha", "config")
local icon = {
['/cgi-bin/luci/admin/status/overview'] = '/gaya/icon/navbar/status.png',
['/cgi-bin/luci/admin/services/ttyd'] = '/gaya/icon/navbar/terminal.png',
['/cgi-bin/luci/admin/services/openclash'] = '/gaya/icon/navbar/oc.png',
['/cgi-bin/luci/admin/nas/tinyfm'] = '/gaya/icon/navbar/nas.png',
['/cgi-bin/luci/admin/modem/main'] = '/gaya/icon/navbar/modem.png',
['/cgi-bin/luci/admin/network/network'] = '/gaya/icon/navbar/interface.png'
}
<% local ver = require "luci.version" %> local function getLink(nav)
local link = config[nav]
return (link ~= "none") and link or nil
end
%>
</div> </div>
<footer class="mobile"> <footer class="mobile">
<a href="https://github.com/derisamedia/luci-theme-alpha"><%= ver.luciname %> | <%= ver.luciversion %> | Alpha OS Theme v3.9</a> <a href="https://github.com/derisamedia/luci-theme-alpha"><%=ver.luciname%> | <%=ver.luciversion%> | Alpha OS Theme v3.9</a>
</footer> </footer>
</div> </div>
<div class="navbar active"> <div class="navbar active">
<div class="dropdown"> <div class="dropdown">
<% for i = 1, 6 do
<a href="/cgi-bin/luci/admin/status/overview"><img src="<%=media%>/gaya/icon/navbar/status.png" /></a> local nav_key = 'nav_0' .. i
<a href="/cgi-bin/luci/admin/services/ttyd"><img src="<%=media%>/gaya/icon/navbar/terminal.png" /></a> local link = getLink(nav_key)
<a href="/cgi-bin/luci/admin/services/openclash"><img src="<%=media%>/gaya/icon/navbar/oc.png" /></a> if link then %>
<a href="/cgi-bin/luci/admin/nas/tinyfm"><img src="<%=media%>/gaya/icon/navbar/nas.png" /></a> <a href="<%= link %>">
<a href="/cgi-bin/luci/admin/modem/main"><img src="<%=media%>/gaya/icon/navbar/modem.png" /></a> <img src="<%=media%><%=icon[link]%>"/>
<a href="/cgi-bin/luci/admin/network/network"><img src="<%=media%>/gaya/icon/navbar/interface.png" /></a> </a>
<% end
end %>
</div> </div>
<label class="toggler"> <label class="toggler">
<img src="<%=media%>/gaya/icon/arrow.svg" alt=""> <img src="<%=media%>/gaya/icon/arrow.svg">
</label> </label>
</div> </div>
<script> <script>
{ {
const nav = document.querySelector(".navbar"); const nav = document.querySelector(".navbar");
let lastScrollY = window.scrollY; let lastScrollY = window.scrollY;
window.addEventListener("scroll", () => { window.addEventListener("scroll", () => {
if (lastScrollY < window.scrollY) { if (lastScrollY < window.scrollY) {
nav.classList.add("navbar--hidden"); nav.classList.add("navbar--hidden");
} else { }
else {
nav.classList.remove("navbar--hidden"); nav.classList.remove("navbar--hidden");
} }
lastScrollY = window.scrollY; lastScrollY = window.scrollY;
}); });
} }
</script> </script>
</div> </div>
<script type="text/javascript">L.require('menu-alpha')</script> <script type="text/javascript">L.require('menu-alpha')</script>
<script src="<%=media%>/app.js"></script> <script src="<%=media%>/app.js"></script>
</body> </body>
</html> </html>