From 6d126649f01ac817149d4f36324c161bb1a4650b Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 10 Feb 2016 18:11:49 +0100 Subject: luci-base: cbi: further refactoring Eliminate more inline scripts in favor to global initialization, use a global object for sharing fixed strings instead of passing them to each invocation. Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/view/cbi/ucisection.htm | 41 +++++++++++------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'modules/luci-base/luasrc/view/cbi/ucisection.htm') diff --git a/modules/luci-base/luasrc/view/cbi/ucisection.htm b/modules/luci-base/luasrc/view/cbi/ucisection.htm index ba0cc53e87..2cb1e75d0e 100644 --- a/modules/luci-base/luasrc/view/cbi/ucisection.htm +++ b/modules/luci-base/luasrc/view/cbi/ucisection.htm @@ -32,30 +32,25 @@ <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
- <% if self.dynamic then %> - - <% if self.optionals[section] and #self.optionals[section] > 0 then %> - - <% end %> + <% + if self.dynamic then + local keys, vals, name, opt = { }, { } + for name, opt in pairs(self.optionals[section]) do + keys[#keys+1] = name + vals[#vals+1] = opt.title + end + %> + 0, "data-choices", luci.util.json_encode({keys, vals})) + %> /> <% else %> - - <% end %> + + <% end %>
<% end %> -- cgit v1.2.3