<commit_before>var Users = {
    currentUser: {
        userId: 2,
        userName: 'Houba',
        icons: [{path: '2_1'}, {path: '2_2'}, {path: '2_3'}, {path: '2_4'}]
    },
    init: () => {
        let signedIn = localStorage.getItem('signedIn');
        Users.currentUser.userName = localStorage.getItem('userName');

        if (signedIn) {
            Messages.init();
        } else {
            Login.init();
        }
    },
};


var Login = {
    init: () => {
        let template = `<header>
    
</header>

<main>
    <aside>
        <header></header>
        <section></section>
    </aside>
    <section id="login">   
         <form data-click="Login.submit">
            <section>
                <p><label><NAME></label><span><input name="username" type="text" autocomplete="off"/></span></p>
                <p><label>Heslo</label><span><input name="password" type="password"/></span></p>
            </section>
            <p><button type="submit"><span class="progress">...</span></button></p>           
         </form>
    </section>
</main>`;

        document.querySelector('.content').insertAdjacentHTML('afterBegin', template);

        document.querySelector('input[name=username]').addEventListener('blur', Login.validations.username);

        let password = document.querySelector('input[name=password]');

        password.addEventListener('focus', Login.validations.username);
        password.addEventListener('blur', Login.validations.password);

        Buttons.initForms(document.querySelectorAll('form'));
    },
    submit: (form) => {
        let button = form.querySelector('button');

        if (!button.classList.contains('progress')) {
            if (!Login.validations.all()) {
                return;
            }

            button.classList.add('progress');
            setTimeout(() => {
                Users.currentUser.userName = form.querySelector('input[name=username]').value;

                localStorage.setItem('signedIn', 'true');
                localStorage.setItem('userName', Users.currentUser.userName);

                Content.clean();

                Messages.init();
            }, 500);
        }
    },
    logout: (button) => {
        if (!button.classList.contains('progress')) {
            button.classList.add('progress');
            setTimeout(() => {
                Content.clean();
                Messages.menu.remove();

                localStorage.removeItem('signedIn');
                localStorage.removeItem('userName');

                Login.init();
            }, 300);
        }
    },
    values: {
        username: () => {
            return document.querySelector('input[name=username]').value;
        },
        password: () => {
            return document.querySelector('input[name=password]').value;
        }
    },
    validations: {<commit_msg>Adding persistent userId on client side<commit_after>var Users = {
    currentUser: {
        userId: 2,
        userName: 'Houba',
        icons: [{path: '2_1'}, {path: '2_2'}, {path: '2_3'}, {path: '2_4'}]
    },
    init: () => {
        let signedIn = localStorage.getItem('signedIn');
        Users.currentUser.userName = localStorage.getItem('userName');
        Users.currentUser.userId = localStorage.getItem('userId');

        if (signedIn) {
            Messages.init();
        } else {
            Login.init();
        }
    },
};


var Login = {
    init: () => {
        let template = `<header>
    
</header>

<main>
    <aside>
        <header></header>
        <section></section>
    </aside>
    <section id="login">   
         <form data-click="Login.submit">
            <section>
                <p><label><NAME></label><span><input name="username" type="text" autocomplete="off"/></span></p>
                <p><label>Heslo</label><span><input name="password" type="password"/></span></p>
            </section>
            <p><button type="submit"><span class="progress">...</span></button></p>           
         </form>
    </section>
</main>`;

        document.querySelector('.content').insertAdjacentHTML('afterBegin', template);

        document.querySelector('input[name=username]').addEventListener('blur', Login.validations.username);

        let password = document.querySelector('input[name=password]');

        password.addEventListener('focus', Login.validations.username);
        password.addEventListener('blur', Login.validations.password);

        Buttons.initForms(document.querySelectorAll('form'));
    },
    submit: (form) => {
        let button = form.querySelector('button');

        if (!button.classList.contains('progress')) {
            if (!Login.validations.all()) {
                return;
            }

            button.classList.add('progress');
            setTimeout(() => {
                Users.currentUser.userName = form.querySelector('input[name=username]').value;
                Users.currentUser.userId = new Date().getTime() + '-' + Math.random();

                localStorage.setItem('signedIn', 'true');
                localStorage.setItem('userName', Users.currentUser.userName);
                localStorage.setItem('userId', Users.currentUser.userId);

                Content.clean();

                Messages.init();
            }, 500);
        }
    },
    logout: (button) => {
        if (!button.classList.contains('progress')) {
            button.classList.add('progress');
            setTimeout(() => {
                Content.clean();
                Messages.menu.remove();

                localStorage.removeItem('signedIn');
                localStorage.removeItem('userName');
                localStorage.removeItem('userId');

                Login.init();
            }, 300);
        }
    },
    values: {
        username: () => {
            return document.querySelector('input[name=username]').value;
        },
        password: () => {
            return document.querySelector('input[name=password]').value;
        }
    },
    validations: {
{'fraction_non_alphanumeric': 0.1665283081520837, 'fraction_numerical': 0.004980906524987548, 'mean_word_length': 2.0059880239520957, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2797561', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1605, 'n_words': 236}