<commit_before>var DesktopNotification = Notification;

var Notification = {
    inhibed : false,
    focused : false,
    tab_counter1 : 0,
    tab_counter2 : 0,
    tab_counter1_key : 'chat',
    tab_counter2_key : 'news',
    document_title : document.title,
    notifs_key : '',
    favicon : null,

    inhibit : function(sec) {
        Notification.inhibed = true;

        if(sec == null) sec = 5;

        setTimeout(function() {
                Notification.inhibed = false;
            },
            sec*1000);
    },
    refresh : function(keys) {
        var counters = document.querySelectorAll('.counter');
        for(i = 0; i < counters.length; i++) {
            var n = counters[i];
            if(n.dataset.key != null
            && keys[n.dataset.key] != null) {
                n.innerHTML = keys[n.dataset.key];
            }
        }

        for(var key in keys) {
            var counter = keys[key];
            Notification.setTab(key, counter);
        }

        Notification.displayTab();
    },
    counter : function(key, counter) {
        var counters = document.querySelectorAll('.counter');
        for(i = 0; i < counters.length; i++) {
            var n = counters[i];
            if(n.dataset.key != null
            && n.dataset.key == key) {
                n.innerHTML = counter;
            }
        }

        Notification.setTab(key, counter);
        Notification.displayTab();
    },
    setTab : function(key, counter) {
        if(counter == '') counter = 0;

        if(Notification.tab_counter1_key == key) {
            Notification.tab_counter1 = counter;
        }
        if(Notification.tab_counter2_key == key) {
            Notification.tab_counter2 = counter;
        }
    },
    displayTab : function() {
        if(Notification.tab_counter1 == 0 && Notification.tab_counter2 == 0) {
            document.title = Notification.document_title;
            Notification.favicon.badge(0);
        } else {
            Notification.favicon.badge(Notification.tab_counter1 + Notification.tab_counter2);
            document.title = '(' + Notification.tab_counter1 + '/' + Notification.tab_counter2 + ') ' + Notification.document_title;
        }
    },
    current : function(key) {
        Notification.notifs_key = key;
        Notification_ajaxCurrent(Notification.notifs_key);
    },
    toast : function(html) {
        // Android notification
        if(typeof Android !== 'undefined') {
            Android.showToast(html);
            return;
        }

        target = document.getElementById('toast');

        if(target) {
            target.innerHTML = html;
        }

        setTimeout(function() {
            target = document.getElementById('toast');
            target.innerHTML = '';
            },
            3000);
    },
    snackbar : function(html, time) {
        if(typeof Android !== 'undefined'
        || Notification.inhibed == true) return;

        target = document.getElementById('snackbar');

        if(target) {
            target.innerHTML = html;
        }

        setTimeout(function() {
            target = document.getElementById('snackbar');
            target.innerHTML = '';
            },
            time*1000);
    },
    desktop : function(title, body, picture, action) {
        if(Notification.inhibed == true
        || Notification.focused) return;

        // Android notification
        if(typeof Android !== 'undefined') {
            Android.showNotification(title, body, picture);
            return;
        }

        var notification = new DesktopNotification(title, { icon: picture, body: body });

        if(action !== null) {
            notification.onclick = function() {
                window.location.href = action;
            }
        }
    }
}

MovimWebsocket.attach(function() {
    Notification.favicon = new Favico({
        animation: 'none',
        fontStyle: 'normal',<commit_msg>Enable actions in Android notifications<commit_after>var DesktopNotification = Notification;

var Notification = {
    inhibed : false,
    focused : false,
    tab_counter1 : 0,
    tab_counter2 : 0,
    tab_counter1_key : 'chat',
    tab_counter2_key : 'news',
    document_title : document.title,
    notifs_key : '',
    favicon : null,

    inhibit : function(sec) {
        Notification.inhibed = true;

        if(sec == null) sec = 5;

        setTimeout(function() {
                Notification.inhibed = false;
            },
            sec*1000);
    },
    refresh : function(keys) {
        var counters = document.querySelectorAll('.counter');
        for(i = 0; i < counters.length; i++) {
            var n = counters[i];
            if(n.dataset.key != null
            && keys[n.dataset.key] != null) {
                n.innerHTML = keys[n.dataset.key];
            }
        }

        for(var key in keys) {
            var counter = keys[key];
            Notification.setTab(key, counter);
        }

        Notification.displayTab();
    },
    counter : function(key, counter) {
        var counters = document.querySelectorAll('.counter');
        for(i = 0; i < counters.length; i++) {
            var n = counters[i];
            if(n.dataset.key != null
            && n.dataset.key == key) {
                n.innerHTML = counter;
            }
        }

        Notification.setTab(key, counter);
        Notification.displayTab();
    },
    setTab : function(key, counter) {
        if(counter == '') counter = 0;

        if(Notification.tab_counter1_key == key) {
            Notification.tab_counter1 = counter;
        }
        if(Notification.tab_counter2_key == key) {
            Notification.tab_counter2 = counter;
        }
    },
    displayTab : function() {
        if(Notification.tab_counter1 == 0 && Notification.tab_counter2 == 0) {
            document.title = Notification.document_title;
            Notification.favicon.badge(0);
        } else {
            Notification.favicon.badge(Notification.tab_counter1 + Notification.tab_counter2);
            document.title = '(' + Notification.tab_counter1 + '/' + Notification.tab_counter2 + ') ' + Notification.document_title;
        }
    },
    current : function(key) {
        Notification.notifs_key = key;
        Notification_ajaxCurrent(Notification.notifs_key);
    },
    toast : function(html) {
        // Android notification
        if(typeof Android !== 'undefined') {
            Android.showToast(html);
            return;
        }

        target = document.getElementById('toast');

        if(target) {
            target.innerHTML = html;
        }

        setTimeout(function() {
            target = document.getElementById('toast');
            target.innerHTML = '';
            },
            3000);
    },
    snackbar : function(html, time) {
        if(typeof Android !== 'undefined'
        || Notification.inhibed == true) return;

        target = document.getElementById('snackbar');

        if(target) {
            target.innerHTML = html;
        }

        setTimeout(function() {
            target = document.getElementById('snackbar');
            target.innerHTML = '';
            },
            time*1000);
    },
    desktop : function(title, body, picture, action) {
        if(Notification.inhibed == true
        || Notification.focused) return;

        // Android notification
        if(typeof Android !== 'undefined') {
            Android.showNotification(title, body, picture, action);
            return;
        }

        var notification = new DesktopNotification(title, { icon: picture, body: body });

        if(action !== null) {
            notification.onclick = function() {
                window.location.href = action;
            }
        }
    }
}

MovimWebsocket.attach(function() {
    Notification.favicon = new Favico({
        animation: 'none',
        fontStyle: 'normal',
{'fraction_non_alphanumeric': 0.12186152675627694, 'fraction_numerical': 0.00887648998224702, 'mean_word_length': 1.8268817204301075, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5817930', 'n_tokens_mistral': 2218, 'n_tokens_neox': 2076, 'n_words': 402}