diff --git a/template/footer.htm b/template/footer.htm index 71faefb..37d6091 100644 --- a/template/footer.htm +++ b/template/footer.htm @@ -20,39 +20,45 @@ <% 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', - ['/cgi-bin/luci/admin/services/neko'] = '/gaya/icon/navbar/neko.png' -} +local config = uci:get_all("alpha", "theme") -local function getLink(nav) - local link = config[nav] - return (link and link ~= "none") and link or nil -end +-- Table to store navbar icons +local icon = {} +-- Iterate through all navbar entries +uci:foreach("alpha", "navbar", function(section) + local address = section.address + local icon_url = section.icon + + if address and icon_url then + -- Remove '/www/luci-static/alpha/' from icon_url + icon_url = string.gsub(icon_url, "^/www/luci%-static/alpha/", "") + icon[address] = icon_url + end +end) + +-- Check navbar enable status +local navbar_enabled = config.navbar == "1" + +-- Calculate number of enabled navbar links local num_links = 0 -for i = 1, 6 do - local nav_key = 'nav_0' .. i - local link = getLink(nav_key) - if link then +uci:foreach("alpha", "navbar", function(section) + if section.enable == "Enable" then num_links = num_links + 1 end -end +end) +-- Calculate link width for responsive design local link_width = string.format("calc(100%% / %d)", num_links) -local blur_value = tonumber(config.blur) + +-- Retrieve theme properties +local background_color = config.color or '#2222359a' +local blur_value = tonumber(config.blur) or 20 local link_blur = string.format("blur(%dpx)", blur_value) -local background_color = config.color %> @@ -71,17 +83,25 @@ local background_color = config.color