<commit_before>(function($) {
	// Expose globally to allow widgets to use the same jQuery object
	// in order to share the same `data` objects containing id and name.
	// This fix the issue arising when another jQuery version is loaded between
	// this script and the plugin_editor mechanism in the `PlaceholderPluginEditorWidget`
	// see 'templates/admin/cms/page/widgets/plugin_editor.html'
	cms_plugin_editor_jQuery = $;
	$(document).ready(function() {
		// Add Plugin Handler
		$('span.add-plugin').click(function(){
		 var select = $(this).parent().children("select[name=plugins]");
			var pluginvalue = select.attr('value');
			var placeholder_id = $(this).parent().parent().data('id');
			//var splits = window.location.href.split("/");

			var language = $('input.language_button.selected').attr('name');

			if (!language) {
				language = $('input[name=language]').attr("value");
			}
			// The new placeholder branch allows adding non-language plugins!
			if (!language) {
				//alert("Unable to determine the correct language for this plugin! Please report the bug!");
			}

			var target_div = $(this).parent().parent().parent().children('div.plugin-editor');
			if (pluginvalue) {
				var pluginname = select.children('[selected]').text();
				var ul_list = $(this).parent().parent().children("ul.plugin-list");
				$.ajax({
					url: "add-plugin/", dataType: "html", type: "POST",
					data: ({ placeholder:placeholder_id, plugin_type:pluginvalue, language:language }),
					success: function(data) {
						loadPluginForm(target_div, data);
						ul_list.append('<li id="plugin_' + data + '" class="' + pluginvalue + ' active"><span class="drag"></span><span class="text">' + pluginname + '</span><span class="delete"></span></li>');
						setclickfunctions();
					},
					error: function(xhr) {
						if (xhr.status < 500) {
							alert(xhr.responseText);
						}
					}
				});
			}
		});

		// Copy Plugins Handler
		$('span.copy-plugins').click(function(){
			var copy_from_language = $(this).parent().children("select[name=copy-plugins]").attr("value");
			var placeholder = $(this).parent().parent().data('id');
			var splits = window.location.href.split("/");
			var page_id = splits[splits.length-2];

			var to_language = $('input.language_button.selected').attr('name');

			if (!to_language) {
				to_language = $('input[name=language]').attr("value");
			}

			if (!to_language) {
				//alert("Unable to determine the correct language for this plugin! Please report the bug!");
			}

			//var target_div = $(this).parent().parent().parent().children('div.plugin-editor');
			if ((copy_from_language) && (copy_from_language != "")) {
			 var ul_list = $(this).parent().parent().children("ul.plugin-list");
				$.ajax({
					url: "copy-plugins/", dataType: "html", type: "POST",
					data: { page_id: page_id, placeholder: placeholder, copy_from: copy_from_language, language: to_language },
					success: function(data) {
						ul_list.empty().append(data);
						setclickfunctions();
					},
					error: function(xhr) {
						if (xhr.status < 500) {<commit_msg>Fix copy-plugins operation<commit_after>(function($) {
	// Expose globally to allow widgets to use the same jQuery object
	// in order to share the same `data` objects containing id and name.
	// This fix the issue arising when another jQuery version is loaded between
	// this script and the plugin_editor mechanism in the `PlaceholderPluginEditorWidget`
	// see 'templates/admin/cms/page/widgets/plugin_editor.html'
	cms_plugin_editor_jQuery = $;
	$(document).ready(function() {
		// Add Plugin Handler
		$('span.add-plugin').click(function(){
		 var select = $(this).parent().children("select[name=plugins]");
			var pluginvalue = select.attr('value');
			var placeholder_id = $(this).parent().parent().data('id');
			//var splits = window.location.href.split("/");

			var language = $('input.language_button.selected').attr('name');

			if (!language) {
				language = $('input[name=language]').attr("value");
			}
			// The new placeholder branch allows adding non-language plugins!
			if (!language) {
				//alert("Unable to determine the correct language for this plugin! Please report the bug!");
			}

			var target_div = $(this).parent().parent().parent().children('div.plugin-editor');
			if (pluginvalue) {
				var pluginname = select.children('[selected]').text();
				var ul_list = $(this).parent().parent().children("ul.plugin-list");
				$.ajax({
					url: "add-plugin/", dataType: "html", type: "POST",
					data: ({ placeholder:placeholder_id, plugin_type:pluginvalue, language:language }),
					success: function(data) {
						loadPluginForm(target_div, data);
						ul_list.append('<li id="plugin_' + data + '" class="' + pluginvalue + ' active"><span class="drag"></span><span class="text">' + pluginname + '</span><span class="delete"></span></li>');
						setclickfunctions();
					},
					error: function(xhr) {
						if (xhr.status < 500) {
							alert(xhr.responseText);
						}
					}
				});
			}
		});

		// Copy Plugins Handler
		$('span.copy-plugins').click(function(){
			var select = $(this).parent().children("select[name=plugins]");
			var copy_from_language = $(this).parent().children("select[name=copy-plugins]").attr("value");
			var placeholder = $(this).parent().parent().data('id');
			var splits = window.location.href.split("/");
			var page_id = splits[splits.length-2];

			var to_language = $('input.language_button.selected').attr('name');

			if (!to_language) {
				to_language = $('input[name=language]').attr("value");
			}

			if (!to_language) {
				//alert("Unable to determine the correct language for this plugin! Please report the bug!");
			}

			//var target_div = $(this).parent().parent().parent().children('div.plugin-editor');
			if ((copy_from_language) && (copy_from_language != "")) {
			 var ul_list = $(this).parent().parent().children("ul.plugin-list");
				$.ajax({
					url: "copy-plugins/", dataType: "html", type: "POST",
					data: { page_id: page_id, placeholder: placeholder, copy_from: copy_from_language, language: to_language },
					success: function(data) {
						ul_list.empty().append(data);
						setclickfunctions();
					},
					error: function(xhr) {
						if (xhr.status < 500) {
{'fraction_non_alphanumeric': 0.17971246006389777, 'fraction_numerical': 0.0022364217252396168, 'mean_word_length': 3.872373540856031, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, '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': '5266817', 'n_tokens_mistral': 2238, 'n_tokens_neox': 1831, 'n_words': 427}