%- local rowcnt = 1 -- Follow the parent Map cursor so every caller keeps its own config dir local uci = self.map.uci or require("luci.model.uci").cursor() local fs = require "luci.openclash" function rowstyle() rowcnt = rowcnt + 1 return (rowcnt % 2) + 1 end function width(o) if o.width then if type(o.width) == 'number' then return ' style="width:%dpx"' % o.width end return ' style="width:%s"' % o.width end return '' end local a={} local e={} if self.sectiontype == "dns_servers" then table.insert(e, {name="nameserver", title="nameserver"}) table.insert(e, {name="fallback", title="fallback"}) table.insert(e, {name="default", title="default-nameserver"}) else for t,o in ipairs(fs.glob("/etc/openclash/config/*"))do a=fs.stat(o) if a then e[t]={} e[t].name=fs.basename(o) end end table.insert(e, 1, {name="all"}) end local file_path = fs.get_file_path_from_request() local cfg_name = (file_path and fs.basename(file_path)) or nil local function tab_exists(name) if not name then return false end for _, tab in ipairs(e) do if tab.name == name then return true end end return false end if not tab_exists(cfg_name) then local current_path = uci:get("openclash", "config", "config_path") cfg_name = current_path and fs.basename(current_path) or nil if not tab_exists(cfg_name) then cfg_name = nil end end local sectiontype = "_"..(self.config:gsub("[^%w_]", "_")).."_"..(self.sectiontype:gsub("[^%w_]", "_")) local pin_tab = file_path and self.sectiontype ~= "dns_servers" -%>