<commit_before>/* Javascript for AnimationXBlock. */
function AnimationXBlock(runtime, element) {
    $(function ($) {
	// Grab XBlocks data. 
	handlerUrl = runtime.handlerUrl(element, 'update_position');
	var data = JSON.parse($(".animation_source", element).text())
	var animation = data['animation'];

	var position = data['position'];
	var max_position = data['max_position'];

	// Set the correct image and text when the slider moves. Also, 
	// make an AJAX call to the server to save position and
	// maximum position. 
	// 
	// TODO: Should we do this less often for lower load? 
	// (It's okay right now, but less would be cleaner) 
	function update_animation() {
	    position = $(".animation_slider").slider("value")
	    $(".animation_image").attr("src", animation[position].src);
	    $(".animation_text").html(animation[position].desc);
	    if (position > max_position) { max_position = position; }
	    console.log("Update");
	    if (max_position == animation.length-1) {
		console.log("Done");
		$('.animation_wrapper', element).addClass("animation_done");
	    }
	    $.ajax({
		type: "POST",
		url: handlerUrl,
		data: JSON.stringify({"position" : position, 
				      "max_position" : max_position}),
	    });
	}

	// Initialize slider. On any change, update the state
	$( ".animation_slider", element ).slider({
	    value: position, 
	    min: 0, 
	    max: animation.length-1, 
	    step: 1, 
	    stop: function( event, ui) { update_animation(); },
	    slide: function( event, ui) { update_animation(); },
	    change: function( event, ui) { update_animation(); }
	});

	// Go to current position in animation<commit_msg>Removed console.log<commit_after>/* Javascript for AnimationXBlock. */
function AnimationXBlock(runtime, element) {
    $(function ($) {
	// Grab XBlocks data. 
	handlerUrl = runtime.handlerUrl(element, 'update_position');
	var data = JSON.parse($(".animation_source", element).text())
	var animation = data['animation'];

	var position = data['position'];
	var max_position = data['max_position'];

	// Set the correct image and text when the slider moves. Also, 
	// make an AJAX call to the server to save position and
	// maximum position. 
	// 
	// TODO: Should we do this less often for lower load? 
	// (It's okay right now, but less would be cleaner) 
	function update_animation() {
	    position = $(".animation_slider").slider("value")
	    $(".animation_image").attr("src", animation[position].src);
	    $(".animation_text").html(animation[position].desc);
	    if (position > max_position) { max_position = position; }
	    if (max_position == animation.length-1) {
		$('.animation_wrapper', element).addClass("animation_done");
	    }
	    $.ajax({
		type: "POST",
		url: handlerUrl,
		data: JSON.stringify({"position" : position, 
				      "max_position" : max_position}),
	    });
	}

	// Initialize slider. On any change, update the state
	$( ".animation_slider", element ).slider({
	    value: position, 
	    min: 0, 
	    max: animation.length-1, 
	    step: 1, 
	    stop: function( event, ui) { update_animation(); },
	    slide: function( event, ui) { update_animation(); },
	    change: function( event, ui) { update_animation(); }
	});

	// Go to current position in animation
{'fraction_non_alphanumeric': 0.15173899661434287, 'fraction_numerical': 0.0024622960911049553, 'mean_word_length': 3.5264623955431755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6628746', 'n_tokens_mistral': 1023, 'n_tokens_neox': 924, 'n_words': 276}