{"size": 851, "ext": "js", "max_stars_repo_path": "paper_admin/static/paper_admin/src/widgets/password-field/password-field.js", "max_stars_repo_name": "dldevinc/paper_admin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "paper_admin/static/paper_admin/src/widgets/password-field/password-field.js", "max_issues_repo_name": "dldevinc/paper_admin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "paper_admin/static/paper_admin/src/widgets/password-field/password-field.js", "max_forks_repo_name": "dldevinc/paper_admin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.4583333333, "max_line_length": 73, "alphanum_fraction": 0.518213866}
import "./password-field.scss";

document.addEventListener("click", function (event) {
    const button = event.target.closest(".password-field__button");
    if (button) {
        const widget = button.closest(".password-field");
        if (widget) {
            const input = widget.querySelector("input");
            const input_types = ["text", "password"];
            if (input) {
                const index = (input_types.indexOf(input.type) + 1) % 2;
                input.type = input_types[index];

                const icon = widget.querySelector("i.fa");
                const icon_classes = ["fa-eye-slash", "fa-eye"];
                if (icon) {
                    icon.classList.add(icon_classes[index]);
                    icon.classList.remove(icon_classes[(index + 1) % 2]);
                }
            }
        }
    }
});
