112 | <% if self.title and #self.title > 0 then -%>
113 |
<%=self.title%>
114 | <%- end %>
115 | <%- if self.sortable then -%>
116 |
117 | <%- end -%>
118 |
<%=self.description%>
119 |
120 | <%-
121 | render_titles()
122 | render_descriptions()
123 |
124 | local isempty, section, i, k = true, nil, nil
125 | for i, k in ipairs(self:cfgsections()) do
126 | isempty = false
127 | section = k
128 |
129 | local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
130 | local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true)
131 | local colorclass = (self.extedit or self.rowcolors) and rowstyle() or ""
132 | local scope = {
133 | valueheader = "cbi/cell_valueheader",
134 | valuefooter = "cbi/cell_valuefooter"
135 | }
136 | -%>
137 |
>
138 | <%-
139 | local node
140 | for k, node in ipairs(self.children) do
141 | if not node.optional then
142 | node:render(section, scope or {})
143 | end
144 | end
145 | -%>
146 |
147 | <%- if self.sortable or self.extedit or self.addremove then -%>
148 |
149 |
150 | <%- if self.sortable then -%>
151 |
152 |
153 | <% end; if self.extedit then -%>
154 | onclick="location.href='<%=self.extedit:format(section)%>'"
157 | <%- elseif type(self.extedit) == "function" then
158 | %> onclick="location.href='<%=self:extedit(section)%>'"
159 | <%- end
160 | %> alt="<%:Edit%>" title="<%:Edit%>" />
161 | <% end; if self.addremove then %>
162 |
163 | <%- end -%>
164 |
165 |
166 | <%- end -%>
167 |
168 | <%- end -%>
169 |
170 | <%- if isempty then -%>
171 |
172 |
<%:This section contains no values yet%>
173 |
174 | <%- end -%>
175 |
176 |
177 | <% if self.error then %>
178 |
179 |
<% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
180 |
<%=pcdata(e):gsub("\n"," ")%>
181 | <%- end end %>
182 |
183 | <% end %>
184 |
185 | <%- if self.addremove then -%>
186 | <% if self.template_addremove then include(self.template_addremove) else -%>
187 |
188 | <% if self.anonymous then %>
189 |
190 | <% else %>
191 | <% if self.invalid_cts then -%>
192 |
<%:Invalid%>
193 | <%- end %>
194 |
195 |
196 |
197 |
198 | <% end %>
199 |
200 | <%- end %>
201 | <%- end -%>
202 |
203 |
204 |
--------------------------------------------------------------------------------
/luasrc/view/modem/tblsection_command.htm:
--------------------------------------------------------------------------------
1 | <%-
2 | local rowcnt = 0
3 |
4 | function rowstyle()
5 | rowcnt = rowcnt + 1
6 | if rowcnt % 2 == 0 then
7 | return " cbi-rowstyle-1"
8 | else
9 | return " cbi-rowstyle-2"
10 | end
11 | end
12 |
13 | function width(o)
14 | if o.width then
15 | if type(o.width) == 'number' then
16 | return ' style="width:%dpx"' % o.width
17 | end
18 | return ' style="width:%s"' % o.width
19 | end
20 | return ''
21 | end
22 |
23 | local has_titles = false
24 | local has_descriptions = false
25 |
26 | local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous"
27 | local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name"))
28 |
29 | local i, k
30 | for i, k in pairs(self.children) do
31 | if not k.typename then
32 | k.typename = k.template and k.template:gsub("^.+/", "") or ""
33 | end
34 |
35 | if not has_titles and k.title and #k.title > 0 then
36 | has_titles = true
37 | end
38 |
39 | if not has_descriptions and k.description and #k.description > 0 then
40 | has_descriptions = true
41 | end
42 | end
43 |
44 | function render_titles()
45 | if not has_titles then
46 | return
47 | end
48 |
49 | %>
>
50 |
<%:Serial Number%>
51 | <%
52 | local i, k
53 | for i, k in ipairs(self.children) do
54 | if not k.optional then
55 | %>
113 | <% if self.title and #self.title > 0 then -%>
114 |
<%=self.title%>
115 | <%- end %>
116 | <%- if self.sortable then -%>
117 |
118 | <%- end -%>
119 |
<%=self.description%>
120 |
121 | <%-
122 | render_titles()
123 | render_descriptions()
124 |
125 | local num = 1
126 | local isempty, section, i, k = true, nil, nil
127 | for i, k in ipairs(self:cfgsections()) do
128 | isempty = false
129 | section = k
130 |
131 | local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
132 | local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true)
133 | local colorclass = (self.extedit or self.rowcolors) and rowstyle() or ""
134 | local scope = {
135 | valueheader = "cbi/cell_valueheader",
136 | valuefooter = "cbi/cell_valuefooter"
137 | }
138 | -%>
139 |
>
140 |
141 |
<%=num%>
142 | <% num = num + 1 -%>
143 |
144 | <%-
145 | local node
146 | for k, node in ipairs(self.children) do
147 | if not node.optional then
148 | node:render(section, scope or {})
149 | end
150 | end
151 | -%>
152 | <%- if self.sortable or self.extedit or self.addremove then -%>
153 |
154 |
155 | <%- if self.sortable then -%>
156 |
157 |
158 | <% end; if self.extedit then -%>
159 | onclick="location.href='<%=self.extedit:format(section)%>'"
162 | <%- elseif type(self.extedit) == "function" then
163 | %> onclick="location.href='<%=self:extedit(section)%>'"
164 | <%- end
165 | %> alt="<%:Edit%>" title="<%:Edit%>" />
166 | <% end; if self.addremove then %>
167 |
168 | <%- end -%>
169 |
170 |
171 | <%- end -%>
172 |
173 | <%- end -%>
174 |
175 | <%- if isempty then -%>
176 |
177 |
<%:This section contains no values yet%>
178 |
179 | <%- end -%>
180 |
181 |
182 | <% if self.error then %>
183 |
184 |
<% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
185 |
<%=pcdata(e):gsub("\n"," ")%>
186 | <%- end end %>
187 |
188 | <% end %>
189 |
190 | <%- if self.addremove then -%>
191 | <% if self.template_addremove then include(self.template_addremove) else -%>
192 |
193 | <% if self.anonymous then %>
194 |
195 | <% else %>
196 | <% if self.invalid_cts then -%>
197 |