<commit_before>var ui = window.ui || {};

//ui-specific methods
_.extend(ui, {
    globals: {
        currPage: null
    },

    timers: {
        msg: null
    },

    $body: null,
    $header: null,

    dom: {},

    init: function () {
        this.logger();

        c.log('ui.init');

        this.$body = $("body");
        this.$header = $("body > header");

        $(window).on('popstate.ui', function(){
//            if ( !this.globals.currPage || this.globals.currPage === 'login' ) return;

            var newPage = window.location.href.split('#')[1];

            c.log('popstate ', this.globals.currPage, newPage);

            this.navigateTo(this.globals.currPage, newPage);
        }.bind(this));

        $(document.body).on('click.ui', 'header nav a[href]', function (e) {
            e.preventDefault();

            var currPage = window.location.href.split('#')[1]
                , newPage = $(e.currentTarget).attr('href').split('#')[1];

            //logout
            /*
            if ( newPage === 'logout' ) {
                app.logout(currPage);
                return;
            }
            */

            this.navigateTo(currPage, newPage);
        }.bind(this));
    },

    navigateTo: function (currPage, newPage) {
        var $body = this.$body;

        c.log('navigateTo from ' + currPage + ' to ' + newPage);

        /*
        if ( newPage === 'logout' ) {
            app.logout(currPage);
            return;
        }
        */

        history.pushState(null, null, '#'+newPage);
        this.globals.currPage = newPage;

        if ( currPage ) {
            $body.removeClass(currPage);
            app[currPage].destroy();
        }

        $body.addClass(newPage);
        app[newPage].init();
    },

    logger: function(){
        var fn = function(){};

        window.c = window.console ? console : { log: fn, dir: fn, error: fn, info: fn };
    },

    err: function (m) {
        this.showMsg(m, 'err');
    },

    ok: function (m) {
        this.showMsg(m, 'ok');
    },

    showMsg: function(m, type){
        var $msg = $("#msg");

        clearTimeout(this.timers.msg);

        if ( $msg.is(':animated') ) {
            $msg.stop().css('opacity', 1);
        }

        $msg.addClass(type).html(m).fadeTo(250, 1);
        this.hideMsg();
    },

    hideMsg: function () {
        this.timers.msg = setTimeout(function () {
            $("#msg").fadeTo(600, 0, function () {
                $(this).removeClass('ok err').html('');<commit_msg>console.warn fallback for IE<commit_after>var ui = window.ui || {};

//ui-specific methods
_.extend(ui, {
    globals: {
        currPage: null
    },

    timers: {
        msg: null
    },

    $body: null,
    $header: null,

    dom: {},

    init: function () {
        this.logger();

        c.log('ui.init');

        this.$body = $("body");
        this.$header = $("body > header");

        $(window).on('popstate.ui', function(){
//            if ( !this.globals.currPage || this.globals.currPage === 'login' ) return;

            var newPage = window.location.href.split('#')[1];

            c.log('popstate ', this.globals.currPage, newPage);

            this.navigateTo(this.globals.currPage, newPage);
        }.bind(this));

        $(document.body).on('click.ui', 'header nav a[href]', function (e) {
            e.preventDefault();

            var currPage = window.location.href.split('#')[1]
                , newPage = $(e.currentTarget).attr('href').split('#')[1];

            //logout
            /*
            if ( newPage === 'logout' ) {
                app.logout(currPage);
                return;
            }
            */

            this.navigateTo(currPage, newPage);
        }.bind(this));
    },

    navigateTo: function (currPage, newPage) {
        var $body = this.$body;

        c.log('navigateTo from ' + currPage + ' to ' + newPage);

        /*
        if ( newPage === 'logout' ) {
            app.logout(currPage);
            return;
        }
        */

        history.pushState(null, null, '#'+newPage);
        this.globals.currPage = newPage;

        if ( currPage ) {
            $body.removeClass(currPage);
            app[currPage].destroy();
        }

        $body.addClass(newPage);
        app[newPage].init();
    },

    logger: function(){
        var fn = function(){};

        window.c = window.console ? console : { log: fn, warn: fn, dir: fn, error: fn, info: fn };
    },

    err: function (m) {
        this.showMsg(m, 'err');
    },

    ok: function (m) {
        this.showMsg(m, 'ok');
    },

    showMsg: function(m, type){
        var $msg = $("#msg");

        clearTimeout(this.timers.msg);

        if ( $msg.is(':animated') ) {
            $msg.stop().css('opacity', 1);
        }

        $msg.addClass(type).html(m).fadeTo(250, 1);
        this.hideMsg();
    },

    hideMsg: function () {
        this.timers.msg = setTimeout(function () {
            $("#msg").fadeTo(600, 0, function () {
                $(this).removeClass('ok err').html('');
{'fraction_non_alphanumeric': 0.17914280071104088, 'fraction_numerical': 0.004740272565672526, 'mean_word_length': 1.669478123352662, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6736850', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1560, 'n_words': 284}