<commit_before>﻿define(function(require) {
    'use strict';

    var ChromeCommand = require('background/enum/chromeCommand');
    var RepeatButtonState = require('common/enum/repeatButtonState');

    var NextButton = Backbone.Model.extend({
        defaults: {
            enabled: false,
            stream: null,
            radioButton: null,
            shuffleButton: null,
            repeatButton: null,
        },

        initialize: function() {
            //  TODO: There's a LOT of things to listen to here. Once Stream can tell me its nextItem I should be able to clean this up easier.
            this.listenTo(this.get('stream').get('items'), 'add remove reset change:active', this._setEnabled);
            this.listenTo(this.get('radioButton'), 'change:enabled', this._onRadioButtonChangeEnabled);
            this.listenTo(this.get('shuffleButton'), 'change:enabled', this._onShuffleButtonChangeEnabled);
            this.listenTo(this.get('repeatButton'), 'change:state', this._onRepeatButtonChangeState);
            chrome.commands.onCommand.addListener(this._onChromeCommandsCommand.bind(this));

            this._setEnabled();
        },
        
        //  Prevent spamming by only allowing a next click once every 100ms.
        tryActivateNextStreamItem: _.debounce(function() {
            var activatedNextItem = false;

            if (this.get('enabled')) {
                var nextItem = this.get('stream').activateNext();
                activatedNextItem = nextItem !== null;<commit_msg>Fixing #467<commit_after>﻿define(function(require) {
    'use strict';

    var ChromeCommand = require('background/enum/chromeCommand');
    var RepeatButtonState = require('common/enum/repeatButtonState');

    var NextButton = Backbone.Model.extend({
        defaults: {
            enabled: false,
            stream: null,
            radioButton: null,
            shuffleButton: null,
            repeatButton: null,
        },

        initialize: function() {
            //  TODO: There's a LOT of things to listen to here. Once Stream can tell me its nextItem I should be able to clean this up easier.
            this.listenTo(this.get('stream').get('items'), 'add remove reset change:active sort', this._setEnabled);
            this.listenTo(this.get('radioButton'), 'change:enabled', this._onRadioButtonChangeEnabled);
            this.listenTo(this.get('shuffleButton'), 'change:enabled', this._onShuffleButtonChangeEnabled);
            this.listenTo(this.get('repeatButton'), 'change:state', this._onRepeatButtonChangeState);
            chrome.commands.onCommand.addListener(this._onChromeCommandsCommand.bind(this));

            this._setEnabled();
        },
        
        //  Prevent spamming by only allowing a next click once every 100ms.
        tryActivateNextStreamItem: _.debounce(function() {
            var activatedNextItem = false;

            if (this.get('enabled')) {
                var nextItem = this.get('stream').activateNext();
                activatedNextItem = nextItem !== null;
{'fraction_non_alphanumeric': 0.11227495908346972, 'fraction_numerical': 0.0029459901800327334, 'mean_word_length': 2.5995288574793873, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4144097', 'n_tokens_mistral': 803, 'n_tokens_neox': 771, 'n_words': 185}