<commit_before>import DesktopNotifications from '../libs/notifications';
import Session from '../libs/session';

/**
 * Manager alerts counter (set, get or clear)
 */
class Notifications
{
    constructor() {
        this._self = $('#btn-alerts');
        this._dropdown = $('#dropdown-alerts');
        this._modal = this._dropdown.find('.dropdown-modal');

        // original page title
        this._pageTitle = $('head title').text();

        this._self.find('a[data-toggle="dropdown"]').click(this._onDropdownClick.bind(this));
        this._dropdown.on('mousedown', 'li a', this._onItemClick.bind(this)).on('click', '#btn-mark-read', this._onMarkClick.bind(this)).on('click', '.btn-delete-alert', this._onDeleteClick.bind(this));
    }

    /**
     * Set alerts counter
     *
     * @param value
     */
    set(value) {
        if (value > 0) {
            this._setTitle('(' + (value) + ') ' + this._pageTitle);
            this._setIcon(_config.cdn + '/img/xicon/favicon' + Math.min(value, 6) + '.png');
        } else {
            this._setTitle(this._pageTitle);
            this._setIcon(_config.cdn + '/img/favicon.png');
        }

        this._setBadge(value);
    }

    /**
     * Set alerts counter and save it in local storage.
     *
     * @param value
     */
    store(value) {
        Session.setItem('alerts', parseInt(value));

        this.set(value);
    }

    /**
     * Get notifications counter
     *
     * @returns {Number|number}
     */
    get() {
        return parseInt(this._self.find('.badge').text()) || 0;
    }

    /**
     * Remove alerts list
     */
    clear() {
        $('li', this._dropdown).remove();

        if (this._self.hasClass('open')) {
            this._self.dropdown('toggle');
        }
    }

    /**
     * Set unread notification's counter.
     *
     * @param value
     * @private
     */
    _setBadge(value) {
        let badge = $('.badge', this._self);

        if (value === 0) {
            badge.remove();
        }
        else {
            if (!badge.length) {
                $('> a:first', this._self).prepend('<span class="badge">' + value + '</span>');<commit_msg>bugfix: 0 niekoniecznie jest int w tym przypadku?<commit_after>import DesktopNotifications from '../libs/notifications';
import Session from '../libs/session';

/**
 * Manager alerts counter (set, get or clear)
 */
class Notifications
{
    constructor() {
        this._self = $('#btn-alerts');
        this._dropdown = $('#dropdown-alerts');
        this._modal = this._dropdown.find('.dropdown-modal');

        // original page title
        this._pageTitle = $('head title').text();

        this._self.find('a[data-toggle="dropdown"]').click(this._onDropdownClick.bind(this));
        this._dropdown.on('mousedown', 'li a', this._onItemClick.bind(this)).on('click', '#btn-mark-read', this._onMarkClick.bind(this)).on('click', '.btn-delete-alert', this._onDeleteClick.bind(this));
    }

    /**
     * Set alerts counter
     *
     * @param value
     */
    set(value) {
        if (value > 0) {
            this._setTitle('(' + (value) + ') ' + this._pageTitle);
            this._setIcon(_config.cdn + '/img/xicon/favicon' + Math.min(value, 6) + '.png');
        } else {
            this._setTitle(this._pageTitle);
            this._setIcon(_config.cdn + '/img/favicon.png');
        }

        this._setBadge(value);
    }

    /**
     * Set alerts counter and save it in local storage.
     *
     * @param value
     */
    store(value) {
        Session.setItem('alerts', parseInt(value));

        this.set(value);
    }

    /**
     * Get notifications counter
     *
     * @returns {Number|number}
     */
    get() {
        return parseInt(this._self.find('.badge').text()) || 0;
    }

    /**
     * Remove alerts list
     */
    clear() {
        $('li', this._dropdown).remove();

        if (this._self.hasClass('open')) {
            this._self.dropdown('toggle');
        }
    }

    /**
     * Set unread notification's counter.
     *
     * @param value
     * @private
     */
    _setBadge(value) {
        let badge = $('.badge', this._self);

        if (!value) {
            badge.remove();
        }
        else {
            if (!badge.length) {
                $('> a:first', this._self).prepend('<span class="badge">' + value + '</span>');
{'fraction_non_alphanumeric': 0.1769177608845888, 'fraction_numerical': 0.0018428933425478, 'mean_word_length': 2.0027662517289073, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2133049', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1312, 'n_words': 241}