<commit_before>/**
 * A generic web-page handler.
 * 
 * @param aBrowser The browser object the handler handles
 * @param aImplementation An object with the following functions:
 * <ul>
 * <li>isActive
 * <li>isPlaying
 * <li>play
 * <li>pause
 * <li>next
 * <li>previous
 * <li>initialize
 * <li>registerListeners
 * <li>unregisterListeners
 * </ul>
 */
com.sppad.BeQuiet.Handler = function(aBrowser, aImplementation) {
	
	const prefs = com.sppad.BeQuiet.CurrentPrefs;
	
	let self = this;
	self.browser = aBrowser;
	self.doc = aBrowser.contentDocument;
	
	self.implementation = aImplementation;
	self.initialized = false;
	self.playing = undefined;
	self.lastPlayTime = 0;
	
	self.pauseCheckTimer = null;
	
	self.getLastPlayTime = function() {
		return self.lastPlayTime;
	};
	
	self.onPlay = function() {
		window.clearTimeout(self.pauseCheckTimer);
		
		if(self.playing === true)
			return;
		
		self.playing = true;
		self.lastPlayTime = Date.now();
			
		let evt = document.createEvent('Event');
		evt.initEvent('com_sppad_handler_play', false, false);
		evt.handler = self;
		
		document.dispatchEvent(evt);
	};
	
	self.onPause = function() {
		/*
		 * Guard against brief pauses (e.g. changing video location). Can't rely
		 * on seeking state since it is not available for all sites (e.g.
		 * YouTube Flash videos
		 */
		window.clearTimeout(self.pauseCheckTimer);
		self.pauseCheckTimer = window.setTimeout(self.handlePause, prefs.pauseCheckDelay);
	};
	
	self.handlePause = function() {
		if(self.playing === false)
			return;
		
		self.playing = false;
		
		let evt = document.createEvent('Event');
		evt.initEvent('com_sppad_handler_pause', false, false);
		evt.handler = self;
		
		document.dispatchEvent(evt);
	};
	
	self.updatePlayingState = function() {
		if(self.isPlaying())<commit_msg>Wrapped setTimeout call function to avoid tripping add-on validator.<commit_after>/**
 * A generic web-page handler.
 * 
 * @param aBrowser The browser object the handler handles
 * @param aImplementation An object with the following functions:
 * <ul>
 * <li>isActive
 * <li>isPlaying
 * <li>play
 * <li>pause
 * <li>next
 * <li>previous
 * <li>initialize
 * <li>registerListeners
 * <li>unregisterListeners
 * </ul>
 */
com.sppad.BeQuiet.Handler = function(aBrowser, aImplementation) {
	
	const prefs = com.sppad.BeQuiet.CurrentPrefs;
	
	let self = this;
	self.browser = aBrowser;
	self.doc = aBrowser.contentDocument;
	
	self.implementation = aImplementation;
	self.initialized = false;
	self.playing = undefined;
	self.lastPlayTime = 0;
	
	self.pauseCheckTimer = null;
	
	self.getLastPlayTime = function() {
		return self.lastPlayTime;
	};
	
	self.onPlay = function() {
		window.clearTimeout(self.pauseCheckTimer);
		
		if(self.playing === true)
			return;
		
		self.playing = true;
		self.lastPlayTime = Date.now();
			
		let evt = document.createEvent('Event');
		evt.initEvent('com_sppad_handler_play', false, false);
		evt.handler = self;
		
		document.dispatchEvent(evt);
	};
	
	self.onPause = function() {
		/*
		 * Guard against brief pauses (e.g. changing video location). Can't rely
		 * on seeking state since it is not available for all sites (e.g.
		 * YouTube Flash videos
		 */
		window.clearTimeout(self.pauseCheckTimer);
		self.pauseCheckTimer = window.setTimeout(function() { 
			self.handlePause();
		}, prefs.pauseCheckDelay);
	};
	
	self.handlePause = function() {
		if(self.playing === false)
			return;
		
		self.playing = false;
		
		let evt = document.createEvent('Event');
		evt.initEvent('com_sppad_handler_pause', false, false);
		evt.handler = self;
		
		document.dispatchEvent(evt);
	};
	
	self.updatePlayingState = function() {
		if(self.isPlaying())
{'fraction_non_alphanumeric': 0.1287611818921117, 'fraction_numerical': 0.0005421523448088912, 'mean_word_length': 3.8680738786279685, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6686095', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1195, 'n_words': 264}