<commit_before>var selection;
var image_scale = 0;

$(document).ready(function () {
    var image = $('img#picture');
    while(!image.width > 0) {
        image = $('img#picture');
    }
    image.on('load', function() {
        image_scale =  image.get(0).naturalWidth / image.width();
        selection = image.imgAreaSelect({
            instance: true,
            handles: false,
            minHeight: 10,
            minWidth: 10,
            onSelectChange: function (img, selection) {
                $('#x1Field').val(Math.ceil(selection.x1 * image_scale));
                $('#y1Field').val(Math.ceil(selection.y1 * image_scale));
                $('#x2Field').val(Math.floor(selection.x2 * image_scale));
                $('#y2Field').val(Math.floor(selection.y2 * image_scale));
            }
        })

    });

    $('#x1Field')[0].oninput = function () {
        reload_selection();
    };
    $('#y1Field')[0].oninput = function () {
        reload_selection();
    };
    $('#x2Field')[0].oninput = function () {
        reload_selection();
    };
    $('#y2Field')[0].oninput = function () {
        reload_selection();
    };

    //$('#reset_button').click(reset_selection());

    $(this).on('mousemove touchmove', function(e) {
        var cH = $('#crosshair-h'), cV = $('#crosshair-v');
        image = $('img#picture');
        var position = image.offset();
        if((e.pageX > position.left && e.pageX < (position.left + image.width())) && (e.pageY > position.top && e.pageY < (position.top + image.height()))){
            cH.show();
            cV.show();
            $('#mousepos').show();

            cH.css('top', e.pageY +1);
            cV.css('left', e.pageX +1);
            cV.css("height", image.height() -1);
            cV.css("margin-top", position.top);
            cH.css("width", image.width() -1);
            cH.css("margin-left", position.left);

            $('#mousepos').css({
                top: (e.pageY) + 'px',
                left: (e.pageX)  + 'px'
            }, 800);
            $('#mousepos').text( "(" + Math.round((e.pageX - position.left)*image_scale) + ", " + Math.round((e.pageY - position.top)*image_scale) + ")");
            e.stopPropagation();
        }
        else{
            cH.hide();
            cV.hide();
            $('#mousepos').hide();
        }
    });

    $('#mousepos').hide();

		if (typeof init_navigationbuttons === "function") { //tagview
    	init_navigationbuttons();

      $(document).keyup(function(event){<commit_msg>another try to fix JS issues<commit_after>var selection;
var image_scale = 0;

$(document).ready(function () {
    var image = $('img#picture');
    while(!image.width > 0) {
        image = $('img#picture');
    }
    image.on('load', function() {
        while(!image_scale > 0) {
            image_scale =  image.get(0).naturalWidth / image.width();
        }
        selection = image.imgAreaSelect({
            instance: true,
            handles: false,
            minHeight: 10,
            minWidth: 10,
            onSelectChange: function (img, selection) {
                $('#x1Field').val(Math.ceil(selection.x1 * image_scale));
                $('#y1Field').val(Math.ceil(selection.y1 * image_scale));
                $('#x2Field').val(Math.floor(selection.x2 * image_scale));
                $('#y2Field').val(Math.floor(selection.y2 * image_scale));
            }
        })

    });

    $('#x1Field')[0].oninput = function () {
        reload_selection();
    };
    $('#y1Field')[0].oninput = function () {
        reload_selection();
    };
    $('#x2Field')[0].oninput = function () {
        reload_selection();
    };
    $('#y2Field')[0].oninput = function () {
        reload_selection();
    };

    //$('#reset_button').click(reset_selection());

    $(this).on('mousemove touchmove', function(e) {
        var cH = $('#crosshair-h'), cV = $('#crosshair-v');
        image = $('img#picture');
        var position = image.offset();
        if((e.pageX > position.left && e.pageX < (position.left + image.width())) && (e.pageY > position.top && e.pageY < (position.top + image.height()))){
            cH.show();
            cV.show();
            $('#mousepos').show();

            cH.css('top', e.pageY +1);
            cV.css('left', e.pageX +1);
            cV.css("height", image.height() -1);
            cV.css("margin-top", position.top);
            cH.css("width", image.width() -1);
            cH.css("margin-left", position.left);
            while(!image_scale > 0) {
                image_scale =  image.get(0).naturalWidth / image.width();
            }

            $('#mousepos').css({
                top: (e.pageY) + 'px',
                left: (e.pageX)  + 'px'
            }, 800);
            $('#mousepos').text( "(" + Math.round((e.pageX - position.left)*image_scale) + ", " + Math.round((e.pageY - position.top)*image_scale) + ")");
            e.stopPropagation();
        }
        else{
            cH.hide();
            cV.hide();
            $('#mousepos').hide();
        }
    });

    $('#mousepos').hide();

		if (typeof init_navigationbuttons === "function") { //tagview
    	init_navigationbuttons();

      $(document).keyup(function(event){
{'fraction_non_alphanumeric': 0.19812583668005354, 'fraction_numerical': 0.012048192771084338, 'mean_word_length': 1.9581447963800904, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6644696', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1605, 'n_words': 253}