<commit_before>import notPath from '../notPath.js';
import notRouter from '../notRouter';

var notTemplateProcessorsLib = {
	content: function (scope, item, helpers) {
		scope.attributeResult = notPath.parseSubs(scope.attributeExpression, item, helpers);
		if (scope.params.indexOf('capitalize') > -1) {
			scope.attributeResult = scope.attributeResult.toUpperCase();
		}
		if (scope.params[0] === 'max' && parseInt(scope.params[1])>0) {
			if (scope.attributeResult.length>parseInt(scope.params[1])){
				scope.attributeResult = scope.attributeResult.substring(0, parseInt(scope.params[1])-1);
				if(scope.params[2] === 'true'){
					scope.attributeResult+='...';
				}
			}
		}
		scope.element.textContent = scope.attributeResult;
	},
	bind: function (scope, item, helpers) {
		if (scope.element.binds) {
			if (scope.element.binds.hasOwnProperty(scope.params[0])) {
				if (scope.element.binds[scope.params[0]].indexOf(scope.attributeExpression) > -1) {
					return;
				}
			}
		}
		scope.element.addEventListener(scope.params[0], (e) => {
			if (scope.params.length === 1 || scope.params[1] !== 'default') {
				e.preventDefault();
			}
			if (scope.attributeResult) {
				return scope.attributeResult({
					scope,
					item,
					helpers,
					e
				});
			} else {
				return true;
			}
		}, false);
		if (!scope.element.hasOwnProperty('binds')) {
			scope.element.binds = {};
		}
		if (!scope.element.binds.hasOwnProperty(scope.params[0])) {
			scope.element.binds[scope.params[0]] = [];
		}
		if (scope.element.binds[scope.params[0]].indexOf(scope.attributeExpression) === -1) {
			scope.element.binds[scope.params[0]].push(scope.attributeExpression);
		}
	},
	value: function (scope, item, helpers) {
		let liveEvents = ['change', 'keyup'],
			onEvent = () => {
				if (['checkbox', 'radio', 'select-multiple'].indexOf(scope.element.type) > -1) {
					switch (scope.element.type) {
					case 'checkbox':
						{
							notPath.set(scope.attributeExpression, item, helpers, scope.element.checked);
						}
						break;
					case 'radio':
						{
							//console.log(helpers.field.name, helpers.data, helpers, scope.element.checked?scope.element.value:null);
							notPath.set(helpers.field.name, helpers.data, helpers, scope.element.checked ? scope.element.value : null);
						}
						break;
					case 'select-multiple':
						{
							let selected = [].slice.call(scope.element.selectedOptions).map(a => a.value);
							//console.log('select-multiple', selected);
							notPath.set(scope.attributeExpression, item, helpers, selected);
						}
						break;
					}
				} else {
					//console.log(notPath.get(scope.attributeExpression, item, helpers), ' -> ',scope.element.value);
					notPath.set(scope.attributeExpression, item, helpers, scope.element.value);
				}
			};
		scope.element.setAttribute('value', notPath.get(scope.attributeExpression, item, helpers));
		if (scope.element.processedValue !== true) {
			if (scope.element.type === 'textarea') {
				scope.element.innerHTML = notPath.get(scope.attributeExpression, item, helpers);
			}
			for (let t of liveEvents) {
				scope.element.addEventListener(t, onEvent);
			}
			scope.element.processedValue = true;
		}
	},
	attr: function (scope, item, helpers) {
		let res = notPath.get(scope.attributeExpression, item, helpers) || notPath.parseSubs(scope.attributeExpression, item, helpers);
		scope.attributeResult = ((typeof res === 'function') ? res({
			scope,
			item,
			helpers
		}) : res);<commit_msg>template processors lib: value, element.focus, after live set<commit_after>import notPath from '../notPath.js';
import notRouter from '../notRouter';

var notTemplateProcessorsLib = {
	content: function (scope, item, helpers) {
		scope.attributeResult = notPath.parseSubs(scope.attributeExpression, item, helpers);
		if (scope.params.indexOf('capitalize') > -1) {
			scope.attributeResult = scope.attributeResult.toUpperCase();
		}
		if (scope.params[0] === 'max' && parseInt(scope.params[1])>0) {
			if (scope.attributeResult.length>parseInt(scope.params[1])){
				scope.attributeResult = scope.attributeResult.substring(0, parseInt(scope.params[1])-1);
				if(scope.params[2] === 'true'){
					scope.attributeResult+='...';
				}
			}
		}
		scope.element.textContent = scope.attributeResult;
	},
	bind: function (scope, item, helpers) {
		if (scope.element.binds) {
			if (scope.element.binds.hasOwnProperty(scope.params[0])) {
				if (scope.element.binds[scope.params[0]].indexOf(scope.attributeExpression) > -1) {
					return;
				}
			}
		}
		scope.element.addEventListener(scope.params[0], (e) => {
			if (scope.params.length === 1 || scope.params[1] !== 'default') {
				e.preventDefault();
			}
			if (scope.attributeResult) {
				return scope.attributeResult({
					scope,
					item,
					helpers,
					e
				});
			} else {
				return true;
			}
		}, false);
		if (!scope.element.hasOwnProperty('binds')) {
			scope.element.binds = {};
		}
		if (!scope.element.binds.hasOwnProperty(scope.params[0])) {
			scope.element.binds[scope.params[0]] = [];
		}
		if (scope.element.binds[scope.params[0]].indexOf(scope.attributeExpression) === -1) {
			scope.element.binds[scope.params[0]].push(scope.attributeExpression);
		}
	},
	value: function (scope, item, helpers) {
		let liveEvents = ['change', 'keyup'],
			onEvent = () => {
				if (['checkbox', 'radio', 'select-multiple'].indexOf(scope.element.type) > -1) {
					switch (scope.element.type) {
					case 'checkbox':
						{
							notPath.set(scope.attributeExpression, item, helpers, scope.element.checked);
						}
						break;
					case 'radio':
						{
							//console.log(helpers.field.name, helpers.data, helpers, scope.element.checked?scope.element.value:null);
							notPath.set(helpers.field.name, helpers.data, helpers, scope.element.checked ? scope.element.value : null);
						}
						break;
					case 'select-multiple':
						{
							let selected = [].slice.call(scope.element.selectedOptions).map(a => a.value);
							//console.log('select-multiple', selected);
							notPath.set(scope.attributeExpression, item, helpers, selected);
						}
						break;
					}
				} else {
					//console.log(notPath.get(scope.attributeExpression, item, helpers), ' -> ',scope.element.value);
					notPath.set(scope.attributeExpression, item, helpers, scope.element.value);
					scope.element.focus();
				}
			};
		scope.element.setAttribute('value', notPath.get(scope.attributeExpression, item, helpers));
		if (scope.element.processedValue !== true) {
			if (scope.element.type === 'textarea') {
				scope.element.innerHTML = notPath.get(scope.attributeExpression, item, helpers);
			}
			for (let t of liveEvents) {
				scope.element.addEventListener(t, onEvent);
			}
			scope.element.processedValue = true;
		}
	},
	attr: function (scope, item, helpers) {
		let res = notPath.get(scope.attributeExpression, item, helpers) || notPath.parseSubs(scope.attributeExpression, item, helpers);
		scope.attributeResult = ((typeof res === 'function') ? res({
			scope,
			item,
			helpers
		}) : res);
{'fraction_non_alphanumeric': 0.16595684270300964, 'fraction_numerical': 0.00596252129471891, 'mean_word_length': 3.5131326073030107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '2480570', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2268, 'n_words': 377}