'use strict';

/**
 * Switches the lock state (open/closed) and updates the corresponding input field
 * 
 * @param {HTMLElement} target - the HTML element that was clicked (the lock icon)
 * 
 * @returns {void}
 */
function remember_switch(target) {

    if (target.classList.contains('fa-unlock')) {
        // An "open lock" has been found

        // Rewriting to "closed lock"
        target.classList.remove('fa-unlock');
        target.classList.add('fa-lock');

        // Changing the value being sent
        document.querySelector('input[name=' + target.getAttribute('for') + ']').checked = true;
    } else {
        // No "open lock" found, which means a "closed lock" was found

        // Rewriting to "open lock"
        target.classList.remove('fa-lock');
        target.classList.add('fa-unlock');

        // Changing the value being sent
        document.querySelector('input[name=' + target.getAttribute('for') + ']').checked = false;
    }

}

/**
 * Handles the authentication form by setting the URL for submission
 * 
 * @param {HTMLFormElement} form - The HTML form to be processed
 * 
 * @returns {boolean} Always returns true (successful processing)
 */
function authentication(form) {

    // Initializing the form submission address
    form.action = '/account/authentication';

    //Exit (succes)
    return true;
}

/**
 * Handles the registration form by setting the submission URL
 * 
 * @param {HTMLFormElement} form - The HTML form to be processed
 * 
 * @returns {boolean} Always returns true (successful processing)
 */
function registration(form) {

    // Initializing the form submission address
    form.action = '/account/registration';

    //Exit (succes)
    return true;
}
