<commit_before>/**
 * Stores the state of the Auto-Woot setting
 * @module settings/AutoWootToggle
 */

/**
 * AutoWoot setting constructor
 * @constructor
 * @param {object} toggler - The Toggle API used to keep track of state.
 */
function AutoWoot( toggler, userId ){
	this.toggler = toggler;
	this.userId = userId;
	this.localStorageName = "autowoot";

	toggler.onChange( this.setWootState.bind( this ) );

	if( toggler.isOn ){
		this.setWootState( true );
	}

}

/**
 * Sets auto-woot to ON/OFF
 * @param {boolean} isOn - true to turn auto-woot on, false to turn it off
 */
AutoWoot.prototype.setWootState = function( isOn ){
	if( isOn ){
		this.startWooting.apply(this);
		API.on( API.ADVANCE, this.startWooting.bind(this) );
	}else{
		API.off( API.ADVANCE, this.startWooting.bind(this) );
	}
};

/**
 * Determines when to start wooting for current song
 * @param {object} newSongInfo - Info about the newly started song. (Provided by Plug.dj API)
 */
AutoWoot.prototype.startWooting = function( newSongInfo ){

	var wootButton = $('#woot');

	// Immediately start wooting if the user just turned the feature on
	if( !newSongInfo ){
		wootButton.click();
		return;
	}

	// No need to woot for yourself
	if( newSongInfo.dj.id === this.userId ){
		return;
	}

	// woot at a random time in the first 35 seconds of each song
	var randTimeout = Math.round( 35 * Math.random() ) * 1000;
	setTimeout(function(){
		wootButton.click();
	}, randTimeout);

	return randTimeout;
};

module.exports = AutoWoot;<commit_msg>Moves woot click to a method<commit_after>/**
 * Stores the state of the Auto-Woot setting
 * @module settings/AutoWootToggle
 */

/**
 * AutoWoot setting constructor
 * @constructor
 * @param {object} toggler - The Toggle API used to keep track of state.
 */
function AutoWoot( toggler, userId ){
	this.toggler = toggler;
	this.userId = userId;
	this.localStorageName = "autowoot";

	toggler.onChange( this.setWootState.bind( this ) );

	if( toggler.isOn ){
		this.setWootState( true );
	}

}

/**
 * Sets auto-woot to ON/OFF
 * @param {boolean} isOn - true to turn auto-woot on, false to turn it off
 */
AutoWoot.prototype.setWootState = function( isOn ){
	if( isOn ){
		this.startWooting.apply(this);
		API.on( API.ADVANCE, this.startWooting.bind(this) );
	}else{
		API.off( API.ADVANCE, this.startWooting.bind(this) );
	}
};

/**
 * Determines when to start wooting for current song
 * @param {object} newSongInfo - Info about the newly started song. (Provided by Plug.dj API)
 */
AutoWoot.prototype.startWooting = function( newSongInfo ){

	var wootButton = $('#woot');

	// Immediately start wooting if the user just turned the feature on
	if( !newSongInfo ){
		this.clickWoot();
		return;
	}

	// No need to woot for yourself
	if( newSongInfo.dj.id === this.userId ){
		return;
	}

	// woot at a random time in the first 35 seconds of each song
	var randTimeout = Math.round( 35 * Math.random() ) * 1000;
	setTimeout( this.clickWoot.bind(this), randTimeout );

	return randTimeout;
};

/**
 * Clicks the woot button
 */
AutoWoot.prototype.clickWoot = function(){
	$('#woot').click();
};

module.exports = AutoWoot;
{'fraction_non_alphanumeric': 0.1326530612244898, 'fraction_numerical': 0.00510204081632653, 'mean_word_length': 3.7031484257871066, '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': '5543798', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1083, 'n_words': 313}