<commit_before>/**
 * Disable console output unless DEBUG mode is enabled.
 * Add
 *	 define('DEBUG', true);
 * To the end of config/config.php to enable debug mode.
 * The undefined checks fix the broken ie8 console
 */
var oc_debug;
var oc_webroot;

var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('data-user');
var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');

window.oc_config = window.oc_config || {};

if (typeof oc_webroot === "undefined") {
	oc_webroot = location.pathname;
	var pos = oc_webroot.indexOf('/index.php/');
	if (pos !== -1) {
		oc_webroot = oc_webroot.substr(0, pos);
	}
	else {
		oc_webroot = oc_webroot.substr(0, oc_webroot.lastIndexOf('/'));
	}
}
if (oc_debug !== true || typeof console === "undefined" || typeof console.log === "undefined") {
	if (!window.console) {
		window.console = {};
	}
	var methods = ['log', 'debug', 'warn', 'info', 'error', 'assert', 'time', 'timeEnd'];
	for (var i = 0; i < methods.length; i++) {
		console[methods[i]] = function () { };
	}
}

function initL10N(app) {
	if (!( t.cache[app] )) {
		$.ajax(OC.filePath('core', 'ajax', 'translations.php'), {
			async: false,//todo a proper solution for this without sync ajax calls
			data: {'app': app},
			type: 'POST',
			success: function (jsondata) {
				t.cache[app] = jsondata.data;
				t.plural_form = jsondata.plural_form;
			}
		});

		// Bad answer ...
		if (!( t.cache[app] )) {
			t.cache[app] = [];
		}
	}
	if (typeof t.plural_function[app] == 'undefined') {
		t.plural_function[app] = function (n) {
			var p = (n != 1) ? 1 : 0;
			return { 'nplural' : 2, 'plural' : p };
		};

		/**
		 * code below has been taken from jsgettext - which is LGPL licensed
		 * https://developer.berlios.de/projects/jsgettext/
		 * http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jsgettext/jsgettext/lib/Gettext.js
		 */
		var pf_re = new RegExp('^(\\s*nplurals\\s*=\\s*[0-9]+\\s*;\\s*plural\\s*=\\s*(?:\\s|[-\\?\\|&=!<>+*/%:;a-zA-Z0-9_\(\)])+)', 'm');
		if (pf_re.test(t.plural_form)) {
			//ex english: "Plural-Forms: nplurals=2; plural=(n != 1);\n"
			//pf = "nplurals=2; plural=(n != 1);";
			//ex russian: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10< =4 && (n%100<10 or n%100>=20) ? 1 : 2)
			//pf = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)";
			var pf = t.plural_form;
			if (! /;\s*$/.test(pf)) pf = pf.concat(';');
			/* We used to use eval, but it seems IE has issues with it.
			 * We now use "new Function", though it carries a slightly
			 * bigger performance hit.
			 var code = 'function (n) { var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) }; };';
			 Gettext._locale_data[domain].head.plural_func = eval("("+code+")");
			 */
			var code = 'var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };';
			t.plural_function[app] = new Function("n", code);
		} else {
			console.log("Syntax error in language file. Plural-Forms header is invalid ["+t.plural_forms+"]");
		}
	}
}
/**
 * translate a string
 * @param app the id of the app for which to translate the string
 * @param text the string to translate
 * @param vars (optional) FIXME
 * @param count (optional) number to replace %n with
 * @return string
 */
function t(app, text, vars, count){
	initL10N(app);
	var _build = function (text, vars, count) {
		return text.replace(/%n/g, count).replace(/{([^{}]*)}/g,
			function (a, b) {
				var r = vars[b];
				return typeof r === 'string' || typeof r === 'number' ? r : a;
			}
		);
	};
	var translation = text;
	if( typeof( t.cache[app][text] ) !== 'undefined' ){
		translation = t.cache[app][text];
	}

	if(typeof vars === 'object' || count !== undefined ) {
		return _build(translation, vars, count);
	} else {
		return translation;
	}
}
t.cache = {};
// different apps might or might not redefine the nplurals function correctly
// this is to make sure that a "broken" app doesn't mess up with the
// other app's plural function
t.plural_function = {};

/**
 * translate a string
 * @param app the id of the app for which to translate the string
 * @param text_singular the string to translate for exactly one object
 * @param text_plural the string to translate for n objects
 * @param count number to determine whether to use singular or plural
 * @param vars (optional) FIXME
 * @return string
 */
function n(app, text_singular, text_plural, count, vars) {
	initL10N(app);
	var identifier = '_' + text_singular + '_::_' + text_plural + '_';
	if( typeof( t.cache[app][identifier] ) !== 'undefined' ){
		var translation = t.cache[app][identifier];
		if ($.isArray(translation)) {
			var plural = t.plural_function[app](count);
			return t(app, translation[plural.plural], vars, count);
		}
	}

	if(count === 1) {
		return t(app, text_singular, vars, count);
	}
	else{
		return t(app, text_plural, vars, count);
	}
}

/**
* Sanitizes a HTML string
* @param s string
* @return Sanitized string
*/
function escapeHTML(s) {
	return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('"').join('&quot;');
}

/**
* Get the path to download a file
* @param file The filename
* @param dir The directory the file is in - e.g. $('#dir').val()
* @return string
* @deprecated use Files.getDownloadURL() instead
*/
function fileDownloadPath(dir, file) {
	return OC.filePath('files', 'ajax', 'download.php')+'?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
}

var OC={
	PERMISSION_CREATE:4,
	PERMISSION_READ:1,
	PERMISSION_UPDATE:2,
	PERMISSION_DELETE:8,
	PERMISSION_SHARE:16,
	PERMISSION_ALL:31,
	webroot:oc_webroot,
	appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
	currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
	coreApps:['', 'admin','log','search','settings','core','3rdparty'],
	/**
	 * get an absolute url to a file in an appen
	 * @param app the id of the app the file belongs to
	 * @param file the file path relative to the app folder
	 * @return string<commit_msg>Also encode > and '<commit_after>/**
 * Disable console output unless DEBUG mode is enabled.
 * Add
 *	 define('DEBUG', true);
 * To the end of config/config.php to enable debug mode.
 * The undefined checks fix the broken ie8 console
 */
var oc_debug;
var oc_webroot;

var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('data-user');
var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');

window.oc_config = window.oc_config || {};

if (typeof oc_webroot === "undefined") {
	oc_webroot = location.pathname;
	var pos = oc_webroot.indexOf('/index.php/');
	if (pos !== -1) {
		oc_webroot = oc_webroot.substr(0, pos);
	}
	else {
		oc_webroot = oc_webroot.substr(0, oc_webroot.lastIndexOf('/'));
	}
}
if (oc_debug !== true || typeof console === "undefined" || typeof console.log === "undefined") {
	if (!window.console) {
		window.console = {};
	}
	var methods = ['log', 'debug', 'warn', 'info', 'error', 'assert', 'time', 'timeEnd'];
	for (var i = 0; i < methods.length; i++) {
		console[methods[i]] = function () { };
	}
}

function initL10N(app) {
	if (!( t.cache[app] )) {
		$.ajax(OC.filePath('core', 'ajax', 'translations.php'), {
			async: false,//todo a proper solution for this without sync ajax calls
			data: {'app': app},
			type: 'POST',
			success: function (jsondata) {
				t.cache[app] = jsondata.data;
				t.plural_form = jsondata.plural_form;
			}
		});

		// Bad answer ...
		if (!( t.cache[app] )) {
			t.cache[app] = [];
		}
	}
	if (typeof t.plural_function[app] == 'undefined') {
		t.plural_function[app] = function (n) {
			var p = (n != 1) ? 1 : 0;
			return { 'nplural' : 2, 'plural' : p };
		};

		/**
		 * code below has been taken from jsgettext - which is LGPL licensed
		 * https://developer.berlios.de/projects/jsgettext/
		 * http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jsgettext/jsgettext/lib/Gettext.js
		 */
		var pf_re = new RegExp('^(\\s*nplurals\\s*=\\s*[0-9]+\\s*;\\s*plural\\s*=\\s*(?:\\s|[-\\?\\|&=!<>+*/%:;a-zA-Z0-9_\(\)])+)', 'm');
		if (pf_re.test(t.plural_form)) {
			//ex english: "Plural-Forms: nplurals=2; plural=(n != 1);\n"
			//pf = "nplurals=2; plural=(n != 1);";
			//ex russian: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10< =4 && (n%100<10 or n%100>=20) ? 1 : 2)
			//pf = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)";
			var pf = t.plural_form;
			if (! /;\s*$/.test(pf)) pf = pf.concat(';');
			/* We used to use eval, but it seems IE has issues with it.
			 * We now use "new Function", though it carries a slightly
			 * bigger performance hit.
			 var code = 'function (n) { var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) }; };';
			 Gettext._locale_data[domain].head.plural_func = eval("("+code+")");
			 */
			var code = 'var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };';
			t.plural_function[app] = new Function("n", code);
		} else {
			console.log("Syntax error in language file. Plural-Forms header is invalid ["+t.plural_forms+"]");
		}
	}
}
/**
 * translate a string
 * @param app the id of the app for which to translate the string
 * @param text the string to translate
 * @param vars (optional) FIXME
 * @param count (optional) number to replace %n with
 * @return string
 */
function t(app, text, vars, count){
	initL10N(app);
	var _build = function (text, vars, count) {
		return text.replace(/%n/g, count).replace(/{([^{}]*)}/g,
			function (a, b) {
				var r = vars[b];
				return typeof r === 'string' || typeof r === 'number' ? r : a;
			}
		);
	};
	var translation = text;
	if( typeof( t.cache[app][text] ) !== 'undefined' ){
		translation = t.cache[app][text];
	}

	if(typeof vars === 'object' || count !== undefined ) {
		return _build(translation, vars, count);
	} else {
		return translation;
	}
}
t.cache = {};
// different apps might or might not redefine the nplurals function correctly
// this is to make sure that a "broken" app doesn't mess up with the
// other app's plural function
t.plural_function = {};

/**
 * translate a string
 * @param app the id of the app for which to translate the string
 * @param text_singular the string to translate for exactly one object
 * @param text_plural the string to translate for n objects
 * @param count number to determine whether to use singular or plural
 * @param vars (optional) FIXME
 * @return string
 */
function n(app, text_singular, text_plural, count, vars) {
	initL10N(app);
	var identifier = '_' + text_singular + '_::_' + text_plural + '_';
	if( typeof( t.cache[app][identifier] ) !== 'undefined' ){
		var translation = t.cache[app][identifier];
		if ($.isArray(translation)) {
			var plural = t.plural_function[app](count);
			return t(app, translation[plural.plural], vars, count);
		}
	}

	if(count === 1) {
		return t(app, text_singular, vars, count);
	}
	else{
		return t(app, text_plural, vars, count);
	}
}

/**
* Sanitizes a HTML string
* @param s string
* @return Sanitized string
*/
function escapeHTML(s) {
	return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;').split('"').join('&quot;').split('\'').join('&#039;');
}

/**
* Get the path to download a file
* @param file The filename
* @param dir The directory the file is in - e.g. $('#dir').val()
* @return string
* @deprecated use Files.getDownloadURL() instead
*/
function fileDownloadPath(dir, file) {
	return OC.filePath('files', 'ajax', 'download.php')+'?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
}

var OC={
	PERMISSION_CREATE:4,
	PERMISSION_READ:1,
	PERMISSION_UPDATE:2,
	PERMISSION_DELETE:8,
	PERMISSION_SHARE:16,
	PERMISSION_ALL:31,
	webroot:oc_webroot,
	appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
	currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
	coreApps:['', 'admin','log','search','settings','core','3rdparty'],
	/**
	 * get an absolute url to a file in an appen
	 * @param app the id of the app the file belongs to
	 * @param file the file path relative to the app folder
	 * @return string
{'fraction_non_alphanumeric': 0.1867484464530708, 'fraction_numerical': 0.015575821160519731, 'mean_word_length': 3.9252782193958664, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2792853', 'n_tokens_mistral': 4757, 'n_tokens_neox': 4425, 'n_words': 1190}