<commit_before>/** Cz Selection Library
 * @author		<NAME> <<EMAIL>>, 2013
 * @license		New BSD License
 * @version		2013-02-25-6
 */

var Cz = Cz || {};
Cz.Selection = Cz.Selection || {};

Cz.Selection.getText = function (textarea) {
	return textarea.value.substring(this.getStartPos(textarea), this.getEndPos(textarea));
};


Cz.Selection.getLines = function (textarea) {
	var selEndPos = this.getEndPos(textarea);
	var startPos = textarea.value.substring(0, this.getStartPos(textarea)).lastIndexOf("\n");
	var endPos = selEndPos + textarea.value.substring(selEndPos).indexOf("\n");
	
	return textarea.value.substring(startPos + 1, endPos).replace("\r", '').split("\n");
};


Cz.Selection.insert = function (textarea, pos, text) {
	textarea.value = textarea.value.substring(0, pos) +
		text +
		textarea.value.substring(pos);
};


Cz.Selection.wrap = function (textarea, prefix, suffix) {
	var start = this.getStartPos(textarea);
	var end = this.getEndPos(textarea);
	
	textarea.value = textarea.value.substring(0, start) +
		prefix +
		textarea.value.substring(start, end)
		+ suffix
		+ textarea.value.substring(end);
	
	// TODO: aby zustal vybran jen uzivatelem vybrany text a ne i prefix|suffix
	// TODO: nastaveni pozice kurzoru
};


Cz.Selection.getStartPos = function (textarea) {
	return textarea.selectionStart;
};


Cz.Selection.getEndPos = function (textarea) {
	return textarea.selectionEnd;
};


Cz.Selection.getLength = function (textarea) {
	return this.getEndPos(textarea) - this.getStartPos(textarea);
};
<commit_msg>updated getLines(), added getStartLinePos() & getEndLinePos()<commit_after>/** Cz Selection Library
 * @author		<NAME> <<EMAIL>>, 2013
 * @license		New BSD License
 * @version		2013-02-25-7
 */

var Cz = Cz || {};
Cz.Selection = Cz.Selection || {};

Cz.Selection.getText = function (textarea) {
	return textarea.value.substring(this.getStartPos(textarea), this.getEndPos(textarea));
};


Cz.Selection.getLines = function (textarea) {
	var startPos = this.getStartLinePos(textarea);
	var endPos = this.getEndLinePos(textarea);
	
	return textarea.value.substring(startPos, endPos).replace("\r", '').split("\n");
};


Cz.Selection.insert = function (textarea, pos, text) {
	textarea.value = textarea.value.substring(0, pos) +
		text +
		textarea.value.substring(pos);
};


Cz.Selection.wrap = function (textarea, prefix, suffix) {
	var start = this.getStartPos(textarea);
	var end = this.getEndPos(textarea);
	
	textarea.value = textarea.value.substring(0, start) +
		prefix +
		textarea.value.substring(start, end)
		+ suffix
		+ textarea.value.substring(end);
	
	// TODO: aby zustal vybran jen uzivatelem vybrany text a ne i prefix|suffix
	// TODO: nastaveni pozice kurzoru
};


Cz.Selection.getStartPos = function (textarea) {
	return textarea.selectionStart;
};


Cz.Selection.getEndPos = function (textarea) {
	return textarea.selectionEnd;
};


Cz.Selection.getLength = function (textarea) {
	return this.getEndPos(textarea) - this.getStartPos(textarea);
};


Cz.Selection.getStartLinePos = function (textarea) {
	return textarea.value.substring(0, this.getStartPos(textarea)).lastIndexOf("\n") + 1;
};


Cz.Selection.getEndLinePos = function (textarea) {
	var selEndPos = this.getEndPos(textarea);
	return selEndPos + textarea.value.substring(selEndPos).indexOf("\n");
};

{'fraction_non_alphanumeric': 0.14855072463768115, 'fraction_numerical': 0.010265700483091788, 'mean_word_length': 4.751736111111111, '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': '1820459', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1106, 'n_words': 224}