<commit_before>(function () {
    //##################################################################################################################
    //GLOBAL VARS
    //##################################################################################################################
    var currentPage = "login",
        currentScope = "logged_out",
        currentAlert,
        switchingPage = false,
        spinnerSVG = '<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"><circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg>',
        spinnerSVGSmall = '<svg class="spinner" width="20px" height="20px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"><circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg>',
        rippleSettings = {
            debug: false,
            on: 'mousedown',
            opacity: 0.3,
            color: "auto",
            multi: true,
            duration: 0.3,
            easing: 'linear'
        }, hideAlert;

    //##################################################################################################################
    //GLOBAL METHODS
    //##################################################################################################################
    function showAlert(object, timeout) {
        if (hideAlert != null)
            hideAlert();
        clearInterval(currentAlert);
        object.fadeIn(100, function () {
            var me = $(this);
            hideAlert = function () {
                me.fadeOut(100);
                hideAlert = null;
            };
            if (timeout > 0) {
                currentAlert = setTimeout(hideAlert, timeout)
            }
        });
    }

    function startsWith(haystack, needle) {
        return haystack.substr(0, needle.length) == needle;
    }

    function endsWith(haystack, needle) {
        return haystack.substr(needle.length, haystack.length) == needle;
    }

    function getCurrentPage() {
        var anchor = location.href.substring(location.href.indexOf("#"));
        if (anchor.substring(0, 4) === "#!p=" && anchor.length > 1) {
            return anchor.substring(4);
        }
        return currentPage;
    }

    function loadPage(page, callback) {
        if (switchingPage)
            return;
        switchingPage = true;
        var oldPage = $("#page_" + currentPage), newPage = $("#page_" + page), spinner = $(".load-spinner");
        currentPage = page;
        changePageScope(newPage.attr("data-apply-page-scope"));

        spinner.addClass("shown");

        $("*[data-page-highlight]").each(function (index, elem) {
            elem = $(elem);
            if (elem.attr("data-page-highlight") != page) {
                elem.removeClass("active");
            }
        });

        var show = function () {
            $("*[data-page-highlight]").each(function (index, elem) {
                elem = $(elem);
                if (elem.attr("data-page-highlight") == page) {
                    elem.addClass("active");
                }
            });
            spinner.removeClass("shown");
            newPage.fadeIn(300);
            switchingPage = false;
            if (callback != null)
                callback();
        };

        oldPage.fadeOut(300, function () {
            if (page == "passwords" || page == "archive") {
                fetchPasswords(show);
            } else if (page == "login_history") {
                fetchIPLog(show);
            } else {
                show();
            }
        });
    }

    function refresh() {
        var refreshButton = $("#btnRefresh"), icon = refreshButton.find(".material-icons");
        icon.addClass("spin");
        refreshButton.addClass("disabled");
        refreshButton.attr("disabled", "");
        setTimeout(function () {
            loadPage(currentPage, function () {
                icon.removeClass("spin");
                refreshButton.removeClass("disabled");
                refreshButton.attr("disabled", null);
            });
        }, 100);
    }

    function changePageScope(scope) {
        currentScope = scope;
        $("*[data-page-scope]").each(function (i, elem) {
            elem = $(elem);
            if (elem.data("page-scope") != scope) {
                elem.attr("style", "display: none");
            } else {
                elem.attr("style", null);
            }
        });
    }

    function logout() {
        $.ajax({
            url: "backend/logout.php",
            success: function () {
                showAlert($("#successLoggedOut"), 3000);
                loadPage("login");
            }
        })
    }

    function sessionExpired() {
        showAlert($("#warningInactive"), 0);
        switchingPage = false;
        loadPage("login");
    }

    //##################################################################################################################
    //DOCUMENT LOAD
    //##################################################################################################################
    $(document).ready(function () {
        currentPage = getCurrentPage();

        $.ajax({
            url: "backend/status.php",
            success: function (data) {
                if (data.msg == "success" && currentPage == "login") {
                    currentPage = "passwords";
                } else if (data.msg == "no_login" && currentPage != "login") {
                    sessionExpired();
                }
                loadPage(currentPage);
                registerPageListeners();
            }
        });

        setInterval(function () {
            $.ajax({
                url: "backend/status.php",
                success: function (data) {
                    if (data.msg == "no_login" && currentScope != "logged_out") {
                        sessionExpired();
                    }
                    if(data.msg == "success") {
                        $("#inputCurrentEmail").val(data.data.user_email);
                        $("#inputCurrentEmail").change();
                    }
                }
            });
        }, 2000);
    });

    function registerPageListeners() {
        var passwordTable = $('#tbodyPasswords'),
            archivedPasswordTable = $('#tbodyArchivedPasswords'),
            anchor = location.href.substring(location.href.indexOf("#")),
            inputs = $(".text > input"),
            contextMenu = $("#dropdownContextMenu"),
            formEditPass = $("#formEditPasswordPassword");

        if (anchor == "#!r") {
            location.replace("#");
            location.reload(true)
        }

        $.ripple(".nav > li > a", rippleSettings);
        $.ripple(".btn:not([disabled])", rippleSettings);


        if (inputs.val().length > 0)
            me.addClass("hastext");

        inputs.change(function () {
            var me = $(this);
            if (me.val().length > 0)
                me.addClass("hastext");
            else
                me.removeClass("hastext");
        });

        var delay = 100;
        $(".dropdown-menu").find("li").each(function (index, item) {<commit_msg>fixed hasstext on load<commit_after>(function () {
    //##################################################################################################################
    //GLOBAL VARS
    //##################################################################################################################
    var currentPage = "login",
        currentScope = "logged_out",
        currentAlert,
        switchingPage = false,
        spinnerSVG = '<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"><circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg>',
        spinnerSVGSmall = '<svg class="spinner" width="20px" height="20px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"><circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg>',
        rippleSettings = {
            debug: false,
            on: 'mousedown',
            opacity: 0.3,
            color: "auto",
            multi: true,
            duration: 0.3,
            easing: 'linear'
        }, hideAlert;

    //##################################################################################################################
    //GLOBAL METHODS
    //##################################################################################################################
    function showAlert(object, timeout) {
        if (hideAlert != null)
            hideAlert();
        clearInterval(currentAlert);
        object.fadeIn(100, function () {
            var me = $(this);
            hideAlert = function () {
                me.fadeOut(100);
                hideAlert = null;
            };
            if (timeout > 0) {
                currentAlert = setTimeout(hideAlert, timeout)
            }
        });
    }

    function startsWith(haystack, needle) {
        return haystack.substr(0, needle.length) == needle;
    }

    function endsWith(haystack, needle) {
        return haystack.substr(needle.length, haystack.length) == needle;
    }

    function getCurrentPage() {
        var anchor = location.href.substring(location.href.indexOf("#"));
        if (anchor.substring(0, 4) === "#!p=" && anchor.length > 1) {
            return anchor.substring(4);
        }
        return currentPage;
    }

    function loadPage(page, callback) {
        if (switchingPage)
            return;
        switchingPage = true;
        var oldPage = $("#page_" + currentPage), newPage = $("#page_" + page), spinner = $(".load-spinner");
        currentPage = page;
        changePageScope(newPage.attr("data-apply-page-scope"));

        spinner.addClass("shown");

        $("*[data-page-highlight]").each(function (index, elem) {
            elem = $(elem);
            if (elem.attr("data-page-highlight") != page) {
                elem.removeClass("active");
            }
        });

        var show = function () {
            $("*[data-page-highlight]").each(function (index, elem) {
                elem = $(elem);
                if (elem.attr("data-page-highlight") == page) {
                    elem.addClass("active");
                }
            });
            spinner.removeClass("shown");
            newPage.fadeIn(300);
            switchingPage = false;
            if (callback != null)
                callback();
        };

        oldPage.fadeOut(300, function () {
            if (page == "passwords" || page == "archive") {
                fetchPasswords(show);
            } else if (page == "login_history") {
                fetchIPLog(show);
            } else {
                show();
            }
        });
    }

    function refresh() {
        var refreshButton = $("#btnRefresh"), icon = refreshButton.find(".material-icons");
        icon.addClass("spin");
        refreshButton.addClass("disabled");
        refreshButton.attr("disabled", "");
        setTimeout(function () {
            loadPage(currentPage, function () {
                icon.removeClass("spin");
                refreshButton.removeClass("disabled");
                refreshButton.attr("disabled", null);
            });
        }, 100);
    }

    function changePageScope(scope) {
        currentScope = scope;
        $("*[data-page-scope]").each(function (i, elem) {
            elem = $(elem);
            if (elem.data("page-scope") != scope) {
                elem.attr("style", "display: none");
            } else {
                elem.attr("style", null);
            }
        });
    }

    function logout() {
        $.ajax({
            url: "backend/logout.php",
            success: function () {
                showAlert($("#successLoggedOut"), 3000);
                loadPage("login");
            }
        })
    }

    function sessionExpired() {
        showAlert($("#warningInactive"), 0);
        switchingPage = false;
        loadPage("login");
    }

    //##################################################################################################################
    //DOCUMENT LOAD
    //##################################################################################################################
    $(document).ready(function () {
        currentPage = getCurrentPage();

        $.ajax({
            url: "backend/status.php",
            success: function (data) {
                if (data.msg == "success" && currentPage == "login") {
                    currentPage = "passwords";
                } else if (data.msg == "no_login" && currentPage != "login") {
                    sessionExpired();
                }
                loadPage(currentPage);
                registerPageListeners();
            }
        });

        setInterval(function () {
            $.ajax({
                url: "backend/status.php",
                success: function (data) {
                    if (data.msg == "no_login" && currentScope != "logged_out") {
                        sessionExpired();
                    }
                    if(data.msg == "success") {
                        $("#inputCurrentEmail").val(data.data.user_email);
                        $("#inputCurrentEmail").change();
                    }
                }
            });
        }, 2000);
    });

    function registerPageListeners() {
        var passwordTable = $('#tbodyPasswords'),
            archivedPasswordTable = $('#tbodyArchivedPasswords'),
            anchor = location.href.substring(location.href.indexOf("#")),
            inputs = $(".text > input"),
            contextMenu = $("#dropdownContextMenu"),
            formEditPass = $("#formEditPasswordPassword");

        if (anchor == "#!r") {
            location.replace("#");
            location.reload(true)
        }

        $.ripple(".nav > li > a", rippleSettings);
        $.ripple(".btn:not([disabled])", rippleSettings);

        inputs.each(function (index, elem) {
            elem = $(elem);
            if (elem.val().length > 0)
                elem.addClass("hastext");
        });

        inputs.change(function () {
            var me = $(this);
            if (me.val().length > 0)
                me.addClass("hastext");
            else
                me.removeClass("hastext");
        });

        var delay = 100;
        $(".dropdown-menu").find("li").each(function (index, item) {
{'fraction_non_alphanumeric': 0.233640395769362, 'fraction_numerical': 0.01132719208461276, 'mean_word_length': 1.8613822725497853, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, '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': '299129', 'n_tokens_mistral': 3831, 'n_tokens_neox': 3560, 'n_words': 660}