<commit_before>$(function () {

	Lentil = {
		// For any event that will load a new page use this pause to allow the event time to
		// be tracked before going to new page.
		tracking_pause: function(wait_time){
		    var date = new Date();
			var curDate = null;
			do {
				curDate = new Date();
			} while(curDate-date < wait_time);
		},
		// In production it tracks the event to Google. It expects an array of everything that
		// should be sent to Google.
		ga_track: function(values){

			<% if Rails.env == 'production' %>
                if (typeof ga !== "undefined") {
                    window.ga.apply('window', ['send'].concat(values));
                }
			<% else %>
				console.log(values);
			<% end %>
		}
	}

    // FIXME: All of these event handlers could probably be DRY'd up at some point, but doing it this way
    // makes it easier to see the patterns first.

	// click on image
    $(document.body).on('click', '.images .fancybox', function(){
		var image_id = $(this).parent().attr('id');
		Lentil.ga_track(['event', 'image', 'click', image_id]);
	});

	// share button
    $(document.body).on('click', '.share', function(){
		var image_id = $(this).data('imageId');
		Lentil.ga_track(['event', 'image_view', 'share', image_id]);
	});
    // facebook
    $(document.body).on('click', '.facebook', function(){
        var image_id = $(this).data('imageId');
        Lentil.ga_track(['event', 'image_view', 'facebook', image_id]);
    });
    // twitter
    $(document.body).on('click', '.twitter', function(){
        var image_id = $(this).data('imageId');
        Lentil.ga_track(['event', 'image_view', 'twitter', image_id]);
    });
    // email
    $(document.body).on('click', '.email', function(){
        var image_id = $(this).data('imageId');
        Lentil.ga_track(['event', 'image_view', 'email', image_id]);
    });

    // like
    $(document.body).on('click', '.like-btn', function(){
        var image_id = $(this).data('imageId');
        var like_state;
        if ($(this).hasClass('already-clicked')) {
            like_state = 'unlike';
        } else {
            like_state = 'like';
        }

        Lentil.ga_track(['event', 'image_view', like_state, image_id]);
    });

    // flag
    $(document.body).on('click', '.flag-btn', function(){
        var image_id = $(this).data('imageId');
        Lentil.ga_track(['event', 'image_view', 'flag', image_id]);
    });

    // picking a battle image
    $(document.body).on('click', '.battle-form', function(){
        var image_id = $(this).attr('value');
        Lentil.ga_track(['event', 'battle_view', 'pick', image_id]);
    });
});<commit_msg>Fix image ID number casting for GA<commit_after>$(function () {

	Lentil = {
		// For any event that will load a new page use this pause to allow the event time to
		// be tracked before going to new page.
		tracking_pause: function(wait_time){
		    var date = new Date();
			var curDate = null;
			do {
				curDate = new Date();
			} while(curDate-date < wait_time);
		},
		// In production it tracks the event to Google. It expects an array of everything that
		// should be sent to Google.
		ga_track: function(values){

			<% if Rails.env == 'production' %>
                if (typeof ga !== "undefined") {
                    window.ga.apply('window', ['send'].concat(values));
                }
			<% else %>
				console.log(values);
			<% end %>
		}
	}

    // FIXME: All of these event handlers could probably be DRY'd up at some point, but doing it this way
    // makes it easier to see the patterns first.

	// click on image
    $(document.body).on('click', '.images .fancybox', function(){
		var image_id = $(this).parent().attr('id');
		Lentil.ga_track(['event', 'image', 'click', image_id]);
	});

	// share button
    $(document.body).on('click', '.share', function(){
		var image_id = $(this).attr('data-image-id');
		Lentil.ga_track(['event', 'image_view', 'share', image_id]);
	});
    // facebook
    $(document.body).on('click', '.facebook', function(){
        var image_id = $(this).attr('data-image-id');
        Lentil.ga_track(['event', 'image_view', 'facebook', image_id]);
    });
    // twitter
    $(document.body).on('click', '.twitter', function(){
        var image_id = $(this).attr('data-image-id');
        Lentil.ga_track(['event', 'image_view', 'twitter', image_id]);
    });
    // email
    $(document.body).on('click', '.email', function(){
        var image_id = $(this).attr('data-image-id');
        Lentil.ga_track(['event', 'image_view', 'email', image_id]);
    });

    // like
    $(document.body).on('click', '.like-btn', function(){
        var image_id = $(this).attr('data-image-id');
        var like_state;
        if ($(this).hasClass('already-clicked')) {
            like_state = 'unlike';
        } else {
            like_state = 'like';
        }

        Lentil.ga_track(['event', 'image_view', like_state, image_id]);
    });

    // flag
    $(document.body).on('click', '.flag-btn', function(){
        var image_id = $(this).attr('data-image-id');
        Lentil.ga_track(['event', 'image_view', 'flag', image_id]);
    });

    // picking a battle image
    $(document.body).on('click', '.battle-form', function(){
        var image_id = $(this).attr('value');
        Lentil.ga_track(['event', 'battle_view', 'pick', image_id]);
    });
});
{'fraction_non_alphanumeric': 0.18988994590561462, 'fraction_numerical': 0.0, 'mean_word_length': 2.705597788527989, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '3133031', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1656, 'n_words': 420}