AdGuardHome_chpass.htm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <%+cbi/valueheader%>
  2. <script type="text/javascript">//<![CDATA[
  3. function chpass(btn)
  4. {
  5. btn.disabled = true;
  6. btn.value = '<%:loading...%>';
  7. if (typeof bcryptloaded == 'undefined' ){
  8. var theHead = document.getElementsByTagName('head').item(0);
  9. //创建脚本的dom对象实例
  10. var myScript = document.createElement('script');
  11. myScript.src = '<%=resource%>/twin-bcrypt.min.js'; //指定脚本路径
  12. myScript.type = 'text/javascript'; //指定脚本类型
  13. myScript.defer = true; //程序下载完后再解析和执行
  14. theHead.appendChild(myScript);
  15. bcryptloaded=1;
  16. btn.value = '<%:Culculate%>';
  17. btn.disabled = false;
  18. return
  19. }
  20. var lv = document.getElementById('cbid.AdGuardHome.AdGuardHome.hashpass');
  21. if (lv.value != ""){
  22. var hash = TwinBcrypt.hashSync(lv.value);
  23. lv.value=hash;
  24. btn.value = '<%:Please save/apply%>';
  25. }else{
  26. btn.value = '<%:is empty%>';
  27. btn.disabled = false;
  28. }
  29. }
  30. //]]>
  31. </script>
  32. <input data-update="change"<%=
  33. attr("id", cbid) ..
  34. attr("name", cbid) ..
  35. attr("type", self.password and "password" or "text") ..
  36. attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
  37. attr("value", self:cfgvalue(section) or self.default) ..
  38. ifattr(self.size, "size") ..
  39. ifattr(self.placeholder, "placeholder") ..
  40. ifattr(self.readonly, "readonly") ..
  41. ifattr(self.maxlength, "maxlength") ..
  42. ifattr(self.datatype, "data-type", self.datatype) ..
  43. ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
  44. ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
  45. ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
  46. %> />
  47. <% 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 %>
  48. <input type="button" class="cbi-button cbi-button-apply" id="cbid.AdGuardHome.AdGuardHome.applychpass" value="<%:Load culculate model%>" onclick="return chpass(this)"/>
  49. <%+cbi/valuefooter%>