<%- local rowcnt = 1 local uci = 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 function table_include(table, value) if table == nil then return false end for k, v in pairs(table) do if v == value then return true end end return false end local head_width local a={} local e={} 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 local has_all = false for _, v in ipairs(e) do if v.name == "all" then has_all = true break end end if not has_all then table.insert(e, 1, {name="all"}) end if #e > 4 then head_width = (95 / #e).."%" else head_width = "120px" end local cfg_name if uci:get("openclash", "config", "config_path") then cfg_name = fs.basename(uci:get("openclash", "config", "config_path")) end local sectiontype = "_"..self.config.."_"..string.match(self.sectiontype, "[%w_]+") or "self.sectiontype" -%>
<% if self.title and #self.title > 0 then -%>

<%=self.title%>

<%- end %> <%- if self.sortable then -%> <%- end -%>
<%=self.description%>
<%- local count = 0 -%>
<%- for t,o in ipairs(e)do local should_display = false if #e ~= 1 then if cfg_name and o.name == cfg_name then should_display = true elseif not cfg_name and o.name == "all" then should_display = true end else should_display = true end -%>
data-config="<%=o.name%>"> <%- if not self.anonymous then -%> <%- if self.sectionhead then -%> <%- else -%> <%- end -%> <%- end -%> <%- for i, k in pairs(self.children) do if not k.optional then -%> <%- if i == 1 then -%> <%- end -%> <%- count = count + 1; end; end; if self.sortable then -%> <%- end; if self.extedit or self.addremove then -%> <%- count = count + 1; end -%> <%- if not self.anonymous then -%> <%- if self.sectiondesc then -%> <%- else -%> <%- end -%> <%- end; if self.extedit or self.addremove then -%> <%- end -%> <%- for i, k in pairs(self.children) do if not k.optional then -%> <%- end; end; if self.sortable then -%> <%- end; if self.extedit or self.addremove then -%> <%- end -%> <%- local isempty = true local num = 1 for i, k in ipairs(self:cfgsections()) do local section = k if not uci:get("openclash", section, "config") then uci:set("openclash", section, "config", "all") uci:save("openclash") end local section_config = uci:get("openclash", section, "config") if section_config == o.name then isempty = false local scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" } -%> <% if not self.anonymous then -%> <%- end %> <%- for k, node in ipairs(self.children) do if not node.optional then node:render(section, scope or {}) end end -%> <%- if self.sortable then -%> <%- end -%> <%- if self.extedit or self.addremove then -%> <%- end -%> <%- end -%> <%- end -%> <%- if isempty then -%> <%- end -%>
<%=self.sectionhead%> <%:Serial Number%>> <%- if k.titleref then -%><%- end -%> <%-=k.title-%> <%- if k.titleref then -%><%- end -%> <%:Sort%><%:Edit%>
<%=self.sectiondesc%>><%=k.description%>

<%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%>

<%=num%>

<% num = num + 1 -%>
<%- if self.extedit then -%> onclick="location.href='<%=self.extedit:format(section)%>';return switch_to_tab<%=sectiontype%>()" <%- elseif type(self.extedit) == "function" then %> onclick="location.href='<%=self:extedit(section)%>';return switch_to_tab<%=sectiontype%>()" <%- end %> alt="<%:Edit%>" title="<%:Edit%>" /> <%- end; if self.addremove then %> <%- end -%>

<%:This section contains no values yet%>
<% if self.error then %>
    <% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
  • <%=pcdata(e):gsub("\n","
    ")%>
  • <%- end end %>
<% end %> <%- if self.addremove then -%> <% if self.template_addremove then include(self.template_addremove) else -%>
<% if self.anonymous then %> <% else %> <% if self.invalid_cts then -%>
<% end %> <% if self.invalid_cts then -%>
<%:Invalid%>
<%- end %> <% end %>
<%- end %> <%- end -%>
<%- end -%>