Add toggle_password_visibility which is used in options for MQTT password

This commit is contained in:
Isaac Connor 2021-12-29 18:25:21 -05:00
parent 43b62db186
commit b37c894ffc
1 changed files with 18 additions and 1 deletions

View File

@ -103,7 +103,9 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() {
// 'data-on-click-this' calls the global function in the attribute value with the element when a click happens.
function dataOnClickThis() {
document.querySelectorAll("a[data-on-click-this], button[data-on-click-this], input[data-on-click-this]").forEach(function attachOnClick(el) {
console.log("Looking for data-on-click-this");
document.querySelectorAll("a[data-on-click-this], button[data-on-click-this], input[data-on-click-this], span[data-on-click-this]").forEach(function attachOnClick(el) {
console.log(el);
var fnName = el.getAttribute("data-on-click-this");
if ( !window[fnName] ) {
console.error("Nothing found to bind to " + fnName + " on element " + el.name);
@ -986,3 +988,18 @@ function closeFullscreen() {
document.msExitFullscreen();
}
}
function toggle_password_visibility(element) {
input = document.getElementById(element.getAttribute('data-password-input'));
if (!input) {
console.log("Input not found! " + element.getAttribute('data-password-input'));
return;
}
if (element.innerHTML=='visibility') {
input.type = 'text';
element.innerHTML = 'visibility_off';
} else {
input.type = 'password';
element.innerHTML='visibility';
}
}