19715a579d685994c175e9770ce367268b9b92cd
[project/luci.git] / libs / web / luasrc / view / cbi / value.htm
1 <%+cbi/valueheader%>
2 <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%=
3 attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) ..
4 ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder")
5 %> />
6 <% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
7 <% if #self.keylist > 0 or self.datatype then -%>
8 <script type="text/javascript">//<![CDATA[
9 <% if #self.keylist > 0 then -%>
10 cbi_combobox_init('<%=cbid%>', {
11 <%-
12 for i, k in ipairs(self.keylist) do
13 -%>
14 <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
15 <%-if i<#self.keylist then-%>,<%-end-%>
16 <%-
17 end
18 -%>
19 }, '<%- if not self.rmempty and not self.optional then -%>
20 <%-: -- Please choose -- -%>
21 <%- end -%>', '
22 <%- if self.combobox_manual then -%>
23 <%-=self.combobox_manual-%>
24 <%- else -%>
25 <%-: -- custom -- -%>
26 <%- end -%>');
27 <%- end %>
28 <% if self.datatype then -%>
29 cbi_validate_field('<%=cbid%>', <%=tostring((self.optional or self.rmempty) == true)%>, '<%=self.datatype:gsub("'", "\\'")%>');
30 <%- end %>
31 //]]></script>
32 <% end -%>
33 <%+cbi/valuefooter%>