<commit_before>(function ($) {

	"use strict";

	function KeyboardService ($rootScope) {

		$rootScope.__changeKeyboardStatus = {
			'shift' : false,
			'ctrl' : false,
			'alt' : false,
			'meta' : false
		};

		function keydown (event) {
			if (event.shiftKey) {
				$rootScope.__changeKeyboardStatus.shift = true;
			}
			if (event.ctrlKey) {
				$rootScope.__changeKeyboardStatus.ctrl = true;
			}
			if (event.altKey) {
				$rootScope.__changeKeyboardStatus.alt = true;
			}
			if (event.metaKey) {
				$rootScope.__changeKeyboardStatus.meta = true;
			}
			$rootScope.$digest();
		}

		function keyup (event) {
			if (! event.shiftKey) {
				$rootScope.__changeKeyboardStatus.shift = false;
			}
			if (! event.ctrlKey) {
				$rootScope.__changeKeyboardStatus.ctrl = false;
			}
			if (! event.altKey) {
				$rootScope.__changeKeyboardStatus.alt = false;
			}
			if (! event.metaKey) {
				$rootScope.__changeKeyboardStatus.meta = false;
			}
			$rootScope.$digest();
		}

		this.watch = function (scope, key, callback) {
			var expr = '__changeKeyboardStatus.' + key.replace(/\+/g, ' && __changeKeyboardStatus.').replace(/\-/g, ' && !__changeKeyboardStatus.');
			var deregistrationFunc = $rootScope.$watch(expr, function (value) {
				if (value === true || value === false) {
					callback(value);
				}
			}, true);
			scope.$on('$destroy', function () {
				deregistrationFunc();
			});
		};

		$('body').on('keydown', keydown);
		$('body').on('keyup', keyup);
	}


	/**
	 * <rbs-kb-switch>
	 *    <i rbs-kb-when="shift-alt" class="icon-plane icon-3x"></i>
	 *    <i rbs-kb-when="alt-shift" class="icon-bell icon-3x"></i>
	 *    <i rbs-kb-when="alt+shift" class="icon-ambulance icon-3x"></i>
	 *    <i rbs-kb-default="" class="icon-github icon-3x"></i>
	 * </rbs-kb-switch>
	 */
	function rbsKbSwitch (Keyboard) {

		return {
			restrict : 'EAC',

			link : function (scope, elm) {
				var when, whenCounter, def;

				when = elm.find('[rbs-kb-when]');
				whenCounter = when.length;
				def = elm.find('[rbs-kb-default]');

				when.each(function () {
					var $el = $(this);
					Keyboard.watch(scope, $el.attr('rbs-kb-when'), function (value) {
						if (value) {
							def.hide();
							$el.show();
							whenCounter++;
						} else {
							$el.hide();
							whenCounter--;
							if (whenCounter === 0) {
								def.show();
							}
						}
					});

				});
			}
		};
	}

	var app = angular.module('RbsChange');
	app.service('RbsChange.Keyboard', ['$rootScope', KeyboardService]);
	app.directive('rbsKbSwitch', ['RbsChange.Keyboard', rbsKbSwitch]);

})( window.jQuery );<commit_msg>[FIX] rbs-kb-switch<commit_after>(function ($)
{
	"use strict";

	function KeyboardService($rootScope)
	{
		$rootScope.__changeKeyboardStatus = {
			'shift': false,
			'ctrl': false,
			'alt': false,
			'meta': false
		};

		function keyDown(event)
		{
			if (event.shiftKey)
			{
				$rootScope.__changeKeyboardStatus.shift = true;
			}
			if (event.ctrlKey)
			{
				$rootScope.__changeKeyboardStatus.ctrl = true;
			}
			if (event.altKey)
			{
				$rootScope.__changeKeyboardStatus.alt = true;
			}
			if (event.metaKey)
			{
				$rootScope.__changeKeyboardStatus.meta = true;
			}
			$rootScope.$digest();
		}

		function keyUp(event)
		{
			if (!event.shiftKey)
			{
				$rootScope.__changeKeyboardStatus.shift = false;
			}
			if (!event.ctrlKey)
			{
				$rootScope.__changeKeyboardStatus.ctrl = false;
			}
			if (!event.altKey)
			{
				$rootScope.__changeKeyboardStatus.alt = false;
			}
			if (!event.metaKey)
			{
				$rootScope.__changeKeyboardStatus.meta = false;
			}
			$rootScope.$digest();
		}

		this.watch = function (scope, key, callback)
		{
			var expr = '__changeKeyboardStatus.' +
				key.replace(/\+/g, ' && __changeKeyboardStatus.').replace(/\-/g, ' && !__changeKeyboardStatus.');
			var deregistrationFunc = $rootScope.$watch(expr, function (value, oldValue)
			{
				if (value === true || (value === false))
				{
					callback(value, oldValue);
				}
			}, true);
			scope.$on('$destroy', function ()
			{
				deregistrationFunc();
			});
		};

		$('body').on('keydown', keyDown).on('keyup', keyUp);
	}

	/**
	 * <rbs-kb-switch>
	 *    <i rbs-kb-when="shift-alt" class="icon-plane icon-3x"></i>
	 *    <i rbs-kb-when="alt-shift" class="icon-bell icon-3x"></i>
	 *    <i rbs-kb-when="alt+shift" class="icon-ambulance icon-3x"></i>
	 *    <i rbs-kb-default="" class="icon-github icon-3x"></i>
	 * </rbs-kb-switch>
	 */
	function rbsKbSwitch(Keyboard)
	{
		return {
			restrict: 'EAC',
			link: function (scope, elm)
			{
				var when, whenCounter, def;

				when = elm.find('[rbs-kb-when]');
				whenCounter = 0;
				def = elm.find('[rbs-kb-default]');

				when.each(function ()
				{
					var $el = $(this);
					Keyboard.watch(scope, $el.attr('rbs-kb-when'), function (value, oldValue)
					{
						if (value)
						{
							def.hide();
							$el.show();
							whenCounter++;
						}
						else
						{
							$el.hide();
							if (oldValue === true)
							{
								whenCounter--;
							}
							if (whenCounter === 0)
							{
								def.show();
							}
						}
					});
				});
			}
		};
	}

	var app = angular.module('RbsChange');
	app.service('RbsChange.Keyboard', ['$rootScope', KeyboardService]);
	app.directive('rbsKbSwitch', ['RbsChange.Keyboard', rbsKbSwitch]);
})(window.jQuery);
{'fraction_non_alphanumeric': 0.18473368342085522, 'fraction_numerical': 0.0020630157539384846, 'mean_word_length': 2.7009021512838305, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '4820182', 'n_tokens_mistral': 2418, 'n_tokens_neox': 1912, 'n_words': 308}