<commit_before>var TRANSLATE = TRANSLATE || {};

TRANSLATE.pages = (function(self) {

	var config = {};

	var listeners = {
		translate_selected: function(msg) {
			_translateSelected();
		},

		config: function(msg) {
			TRANSLATE.log.debug('Updating config: ' + JSON.stringify(msg.message));
			config = msg.message;
		}
	};

	function getConfig() {
		return config;
	}

	function _listener(msg) {
		var fn = listeners[msg.name] || function(msg) {
				TRANSLATE.log.error("no page listener for name: " + msg.name);
			};
		fn(msg);
	}

	function _reloadConfig() {
		safari.self.tab.dispatchMessage('get_config');
	}
	
	function _notInInput() {
		return document.activeElement.tagName.toLowerCase() != "input";
	}

	function _registerKey() {
		document.body.addEventListener('keydown', function(e) {
			if (e.keyCode == getConfig().key && _notInInput()) {
				_translateSelected();
			}
		});
	}
<commit_msg>Fix - editing textarea does not stop shortcut<commit_after>var TRANSLATE = TRANSLATE || {};

TRANSLATE.pages = (function(self) {

	var config = {};

	var listeners = {
		translate_selected: function(msg) {
			_translateSelected();
		},

		config: function(msg) {
			TRANSLATE.log.debug('Updating config: ' + JSON.stringify(msg.message));
			config = msg.message;
		}
	};

	function getConfig() {
		return config;
	}

	function _listener(msg) {
		var fn = listeners[msg.name] || function(msg) {
				TRANSLATE.log.error("no page listener for name: " + msg.name);
			};
		fn(msg);
	}

	function _reloadConfig() {
		safari.self.tab.dispatchMessage('get_config');
	}
	
	function _notInInput() {
		var tagName = document.activeElement.tagName.toLowerCase();
		return tagName != "input" && tagName != "textarea";
	}

	function _registerKey() {
		document.body.addEventListener('keydown', function(e) {
			if (e.keyCode == getConfig().key && _notInInput()) {
				_translateSelected();
			}
		});
	}

{'fraction_non_alphanumeric': 0.15736842105263157, 'fraction_numerical': 0.0, 'mean_word_length': 3.9121447028423773, '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': '2042686', 'n_tokens_mistral': 713, 'n_tokens_neox': 633, 'n_words': 117}