<commit_before>Emerald = { };

Emerald.baseUrl = '';

/**
 * Emerald.Popup handles all things popup-related.
 * 
 */
Emerald.Popup = { };

/**
 * 
 * Opens a popup window.
 * 
 * @param {String} theurl
 * @param {String} winname
 * @param {String} features
 */
Emerald.Popup.open = function(theurl,winname,features) {
  msgWindow = window.open(theurl,winname,features);
  if (msgWindow != null && msgWindow.opener != null) msgWindow.opener=window;
  msgWindow.focus();
  return msgWindow;
}

/**
 * 
 * Converts feature array to feature string for window.open.
 * 
 * @param {Object} obj Feature array
 */
Emerald.Popup.featureStringFromObject = function(obj) {
	
	var features = [ ];
	var featureStr = '';
	$.each(obj, function(key, value) {
		features.push(key + '=' + value);
	});
	return features.join(',');	
		
}

/**
 * Listener for all popup clicks ('popup(_*)'). 
 * 
 * @param {Object} myEvent Click event
 */
Emerald.Popup.listener = function(myEvent) {
	
	var elm = $(this);
	var features = { };
	
	if(elm.hasClass('popup-small')) {
		features.width = 400;
		features.height = 400;
	} else if(elm.hasClass('popup-large')) {
		features.width = 800;
		features.height = 600;
	} else if(elm.hasClass('popup-medium')) {
		features.width = 500;
		features.height = 500;
	}
	
	features.resizable = (elm.hasClass('popup-resizable')) ? 'yes' : 'no';
	features.scrollbars = (elm.hasClass('popup-scrollbars')) ? 'yes' : 'no';

	Emerald.Popup.open(elm.attr('href'), elm.attr('id'), Emerald.Popup.featureStringFromObject(features)); 
	return false;
}


Emerald.TinyMCE = {
		
		options: function(options)
		{
			var defaultOptions = {
				script_url : Emerald.baseUrl + '/lib/tinymce/jscripts/tiny_mce/tiny_mce.js',
				width: "100%",
				theme : "advanced",
				file_browser_callback : Emerald.FileManager.open,
				convert_urls: true,
				relative_urls: false,
				content_css: "/data/editor.css",
				external_link_list_url : Emerald.baseUrl + "/admin/sitemap/link-list/format/js",
				language: Emerald.Localization.getLanguage(),
				plugins: "table",
				theme_advanced_buttons2_add : "tablecontrols"
			};
			
			var combinedOptions = $.extend(defaultOptions, options);
			return combinedOptions;
			
		}
		
		
	};


/*
 * TinyMCE Filemanager 
 */
Emerald.FileManager = {

	open: function(field_name, url, type, win)
	{
		tinyMCE.activeEditor.windowManager.open({
        file : '/admin/filelib/select/type/image',
        width : 800,  // Your dimensions may differ - toy around with them!
        height : 600,
        resizable : "no",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "no"
	    }, {
	        window : win,
	        input : field_name
	    });
	    return false;
		
	},

    init : function () {
        
		// Remove tinymces own stylez.
		$('link:last').remove();					
		
		// Associate clicks to all filelib files and push em back to the tinymce dialog.		
		$('.file').click(function() {
			
			var href= $(this).attr('href');
			

			
		    var win = tinyMCEPopup.getWindowArg("window");
    		win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = href;
        	
			

    		
    		// for image browsers: update image dimensions
        	if (win.getImageData) win.getImageData();
        	// close popup window
        	tinyMCEPopup.close();
			
                	
        	return false;
		});
		
    }
	
}

/**
 * Localization class
 */
Emerald.Localization = 
{
	_localizations: {},
	_language: null,
	_locale: null,
	
	init: function(locale, language, data)
	{
		Emerald.Localization._language = language;
		Emerald.Localization._localizations = data;
	},
	
	/**
	 * Returns the language the localization was initialized with.
	 */
	getLanguage: function()
	{
		console.debug(Emerald.Localization._language);
		return Emerald.Localization._language;
	},
	
	
	/**
	 * translate
	 * 
	 * @param {String} tstr String to translate
	 * @param {Array} params Parameters to inject to the path
	 */
	translate: function(tstr, params)
	{
		if(Emerald.Localization._localizations[tstr]) 
		{
			return Emerald.Localization._localizations[tstr];			
		}	<commit_msg>Emerald JS translation gets better.<commit_after>Emerald = { };

Emerald.baseUrl = '';

/**
 * Emerald.Popup handles all things popup-related.
 * 
 */
Emerald.Popup = { };

/**
 * 
 * Opens a popup window.
 * 
 * @param {String} theurl
 * @param {String} winname
 * @param {String} features
 */
Emerald.Popup.open = function(theurl,winname,features) {
  msgWindow = window.open(theurl,winname,features);
  if (msgWindow != null && msgWindow.opener != null) msgWindow.opener=window;
  msgWindow.focus();
  return msgWindow;
}

/**
 * 
 * Converts feature array to feature string for window.open.
 * 
 * @param {Object} obj Feature array
 */
Emerald.Popup.featureStringFromObject = function(obj) {
	
	var features = [ ];
	var featureStr = '';
	$.each(obj, function(key, value) {
		features.push(key + '=' + value);
	});
	return features.join(',');	
		
}

/**
 * Listener for all popup clicks ('popup(_*)'). 
 * 
 * @param {Object} myEvent Click event
 */
Emerald.Popup.listener = function(myEvent) {
	
	var elm = $(this);
	var features = { };
	
	if(elm.hasClass('popup-small')) {
		features.width = 400;
		features.height = 400;
	} else if(elm.hasClass('popup-large')) {
		features.width = 800;
		features.height = 600;
	} else if(elm.hasClass('popup-medium')) {
		features.width = 500;
		features.height = 500;
	}
	
	features.resizable = (elm.hasClass('popup-resizable')) ? 'yes' : 'no';
	features.scrollbars = (elm.hasClass('popup-scrollbars')) ? 'yes' : 'no';

	Emerald.Popup.open(elm.attr('href'), elm.attr('id'), Emerald.Popup.featureStringFromObject(features)); 
	return false;
}


Emerald.TinyMCE = {
		
		options: function(options)
		{
			var defaultOptions = {
				script_url : Emerald.baseUrl + '/lib/tinymce/jscripts/tiny_mce/tiny_mce.js',
				width: "100%",
				theme : "advanced",
				file_browser_callback : Emerald.FileManager.open,
				convert_urls: true,
				relative_urls: false,
				content_css: "/data/editor.css",
				external_link_list_url : Emerald.baseUrl + "/admin/sitemap/link-list/format/js",
				language: Emerald.Localization.getLanguage(),
				plugins: "table",
				theme_advanced_buttons2_add : "tablecontrols"
			};
			
			var combinedOptions = $.extend(defaultOptions, options);
			return combinedOptions;
			
		}
		
		
	};


/*
 * TinyMCE Filemanager 
 */
Emerald.FileManager = {

	open: function(field_name, url, type, win)
	{
		tinyMCE.activeEditor.windowManager.open({
        file : '/admin/filelib/select/type/image',
        width : 800,  // Your dimensions may differ - toy around with them!
        height : 600,
        resizable : "no",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "no"
	    }, {
	        window : win,
	        input : field_name
	    });
	    return false;
		
	},

    init : function () {
        
		// Remove tinymces own stylez.
		$('link:last').remove();					
		
		// Associate clicks to all filelib files and push em back to the tinymce dialog.		
		$('.file').click(function() {
			
			var href= $(this).attr('href');
			
		    var win = tinyMCEPopup.getWindowArg("window");
    		win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = href;
        	
			

    		
    		// for image browsers: update image dimensions
        	if (win.getImageData) win.getImageData();
        	// close popup window
        	tinyMCEPopup.close();
			
                	
        	return false;
		});
		
    }
	
}

/**
 * Localization class
 */
Emerald.Localization = 
{
	_localizations: {},
	_language: null,
	_locale: null,
	
	init: function(locale, language, data)
	{
		Emerald.Localization._language = language;
		Emerald.Localization._localizations = data;
	},
	
	/**
	 * Returns the language the localization was initialized with.
	 */
	getLanguage: function()
	{
		return Emerald.Localization._language;
	},
	
	
	/**
	 * translate
	 * 
	 * @param {String} tstr String to translate
	 * @param {Array} params Parameters to inject to the path
	 */
	translate: function(tstr, params)
	{
		if(Emerald.Localization._localizations[tstr]) 
		{
			tstr = Emerald.Localization._localizations[tstr];
		}
		
		if(params) {
			$.each(params, function(key, value) {
				tstr = tstr.replace("%" + (key + 1) + "$s", value);
			})
		}
{'fraction_non_alphanumeric': 0.14346641393199858, 'fraction_numerical': 0.006752754412984244, 'mean_word_length': 2.961520412951666, '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': '3190049', 'n_tokens_mistral': 3141, 'n_tokens_neox': 2730, 'n_words': 585}