<commit_before>jQuery(document).ready(function($) {

	// Listen for Credly Badge Builder events
	window.addEventListener( 'message', function(e) {
		// Only continue if data is from credly.com
		if ( "https://credly.com" === e.origin && "object" === typeof( data = e.data ) ) {
			var win = window.dialogArguments || opener || parent || top;

			// Remove the badge builder thickbox
			tb_remove();

			win.WPSetThumbnailHTML('<p>Updating featured image, please wait...</p>');

			// Send the badge data along for uploading
			$.ajax({
				url: ajaxurl,
				data: {
					'action':     'badge-builder-save-badge',
					'post_id':    $('#post_ID').val(),
					'image':      e.data.image,
					'icon_meta':  e.data.iconMetadata,
					'badge_meta': e.data.packagedData,
					'all_data':   e.data
				},
				dataType: 'json',
				success: function( response ) {
					// Update the featured image metabox
					win.WPSetThumbnailHTML(response.data.metabox_html);
				}
			});
		}
	});

	// Resize ThickBox when a badge builder link is clicked
	$('body').on( 'click', '.badge-builder-link', function(e) {
		e.preventDefault();
		badge_builder_setup_thickbox( $(this) );
		badge_builder_regenerate_link();
	});

	// Resize badge builder thickbox on window resize
	$(window).resize(function() {
		badge_builder_resize_tb( $('.badge-builder-link') );
	});

	// Add a custom class to our badge builder thickbox, then resize
	function badge_builder_setup_thickbox( link ) {
		setTimeout( function() {
			$('#TB_window').addClass('badge-builder-thickbox');
			badge_builder_resize_tb( link );
		}, 0 );
	}

	// Force badge builder thickboxes to our specified width/height
	function badge_builder_resize_tb( link ) {
		setTimeout( function() {

			var width  = link.attr('data-width');
			var height = link.attr('data-height');

			$('.badge-builder-thickbox').css({ 'marginLeft': -(width / 2) });
			$('.badge-builder-thickbox, .badge-builder-thickbox #TB_iframeContent').width(width).height(height);
			$('.badge-builder-thickbox, .badge-builder-thickbox #TB_ajaxContent').width(width).height(height).css({'padding':'0px'});

		}, 0 );
	}

	// Fetch a new badge builder link
	function badge_builder_regenerate_link() {<commit_msg>Rename JS function since its purpose is to generate, not regenerate<commit_after>jQuery(document).ready(function($) {

	// Listen for Credly Badge Builder events
	window.addEventListener( 'message', function(e) {
		// Only continue if data is from credly.com
		if ( "https://credly.com" === e.origin && "object" === typeof( data = e.data ) ) {
			var win = window.dialogArguments || opener || parent || top;

			// Remove the badge builder thickbox
			tb_remove();

			win.WPSetThumbnailHTML('<p>Updating featured image, please wait...</p>');

			// Send the badge data along for uploading
			$.ajax({
				url: ajaxurl,
				data: {
					'action':     'badge-builder-save-badge',
					'post_id':    $('#post_ID').val(),
					'image':      e.data.image,
					'icon_meta':  e.data.iconMetadata,
					'badge_meta': e.data.packagedData,
					'all_data':   e.data
				},
				dataType: 'json',
				success: function( response ) {
					// Update the featured image metabox
					win.WPSetThumbnailHTML(response.data.metabox_html);
				}
			});
		}
	});

	// Resize ThickBox when a badge builder link is clicked
	$('body').on( 'click', '.badge-builder-link', function(e) {
		e.preventDefault();
		badge_builder_setup_thickbox( $(this) );
		badge_builder_generate_link();
	});

	// Resize badge builder thickbox on window resize
	$(window).resize(function() {
		badge_builder_resize_tb( $('.badge-builder-link') );
	});

	// Add a custom class to our badge builder thickbox, then resize
	function badge_builder_setup_thickbox( link ) {
		setTimeout( function() {
			$('#TB_window').addClass('badge-builder-thickbox');
			badge_builder_resize_tb( link );
		}, 0 );
	}

	// Force badge builder thickboxes to our specified width/height
	function badge_builder_resize_tb( link ) {
		setTimeout( function() {

			var width  = link.attr('data-width');
			var height = link.attr('data-height');

			$('.badge-builder-thickbox').css({ 'marginLeft': -(width / 2) });
			$('.badge-builder-thickbox, .badge-builder-thickbox #TB_iframeContent').width(width).height(height);
			$('.badge-builder-thickbox, .badge-builder-thickbox #TB_ajaxContent').width(width).height(height).css({'padding':'0px'});

		}, 0 );
	}

	// Fetch a new badge builder link
	function badge_builder_generate_link() {
{'fraction_non_alphanumeric': 0.15945584299732382, 'fraction_numerical': 0.001784121320249777, 'mean_word_length': 3.6476683937823835, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '5364922', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1443, 'n_words': 330}