<commit_before>/*
 * HTML5 Notifications
 * @version 1.0
 * @author <NAME> <<EMAIL>>
 *
 * Notify user if new messages come in.
 */

var CandyShop = (function(self) { return self; }(CandyShop || {}));

CandyShop.Notifications = (function(self, Candy, $) {
	/** Function: init
	 * Initializes the notifications plugin.
	 * 
	 * @return void
	 */
	self.init = function() {
		// Setup Permissions (has to be kicked on with some user-events)
		jQuery(document).on('click keydown', setupPermissions);
		
		// Add Listener for Notifications
		$(Candy).on('candy:view.message.after-show', handleOnShow);
	};
	
	/** Function: checkPermissions
	 * Check if the plugin has permission to send notifications.
	 * 
	 * @return boid
	 */
	function setupPermissions() {
		// Check if permissions is given
		if (window.webkitNotifications.checkPermission() != 0) { // 0 is PERMISSION_ALLOWED
			// Request for it
			window.webkitNotifications.requestPermission();
		}
		// Unbind the permission setup events
		jQuery(document).unbind('click keydown', setupPermissions);
	};
	

	/** Function: handleOnShow
	 * Descriptions
	 *
	 * Parameters:
	 *   (Array) args
	 * 
	 * @return void
	 */
	function handleOnShow(e, args) {
		// Check if window has focus, so no notification needed
		if (!document.hasFocus()) {
			// Check if notifications are allowed
			if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED
				// Send Notification
				var notification = window.webkitNotifications.createNotification(
						window.location + '/' + Candy.View.getOptions().resources + '/img/favicon.png',
						args.name,
						args.message);
				notification.show();
			}
		}
	};

	return self;
}(CandyShop.Notifications || {}, Candy, jQuery));
<commit_msg>Little Fix to ensure it doesn’t break on non-webkit-browsers.<commit_after>/*
 * HTML5 Notifications
 * @version 1.0
 * @author <NAME> <<EMAIL>>
 *
 * Notify user if new messages come in.
 */

var CandyShop = (function(self) { return self; }(CandyShop || {}));

CandyShop.Notifications = (function(self, Candy, $) {
	/** Function: init
	 * Initializes the notifications plugin.
	 * 
	 * @return void
	 */
	self.init = function() {
		// Just init if notifications are supported
		if (window.webkitNotifications) {
			// Setup Permissions (has to be kicked on with some user-events)
			jQuery(document).on('click keydown', setupPermissions);
			
			// Add Listener for Notifications
			$(Candy).on('candy:view.message.after-show', handleOnShow);
		}
	};
	
	/** Function: checkPermissions
	 * Check if the plugin has permission to send notifications.
	 * 
	 * @return boid
	 */
	function setupPermissions() {
		// Check if permissions is given
		if (window.webkitNotifications.checkPermission() != 0) { // 0 is PERMISSION_ALLOWED
			// Request for it
			window.webkitNotifications.requestPermission();
		}
		// Unbind the permission setup events
		jQuery(document).unbind('click keydown', setupPermissions);
	};
	

	/** Function: handleOnShow
	 * Descriptions
	 *
	 * Parameters:
	 *   (Array) args
	 * 
	 * @return void
	 */
	function handleOnShow(e, args) {
		// Check if window has focus, so no notification needed
		if (!document.hasFocus()) {
			// Check if notifications are allowed
			if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED
				// Send Notification
				var notification = window.webkitNotifications.createNotification(
						window.location + '/' + Candy.View.getOptions().resources + '/img/favicon.png',
						args.name,
						args.message);
				notification.show();
			}
		}
	};

	return self;
}(CandyShop.Notifications || {}, Candy, jQuery));

{'fraction_non_alphanumeric': 0.1317447274719255, 'fraction_numerical': 0.003834565872363736, 'mean_word_length': 3.405307599517491, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5487351', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1068, 'n_words': 296}