<commit_before>var scoreSnd = new Audio("static/sounds/score.wav");

function flash(msg) {
    $('#flash').text(msg);
    $('#flash').fadeIn('slow');
    $('#flash').click(function(){
        $('#flash').fadeOut('slow');
    });

    window.setTimeout(function(){
        $('#flash').fadeOut('slow');
        $('#flash').unbind();
    }, 5000);
}

function loadScores(scoreurl, breakdownurl, highlights) {
    $.ajax({
        'url': scoreurl,
        'dataType': 'json',
        'beakdownurl': breakdownurl,
        'highlights': highlights,
    }).done(function(data){
        var scores = [];

        // hack to sort scores
        for(k in data['scores'])
        {
            scores.push(data['scores'][k]);
        }
        scores.sort(function(a, b){return a[2] < b[2]});

        $('#scoreboard tr').remove();
        for(i in scores)
        {
            tr = document.createElement('tr');
            $(tr).attr('id', 'scoreboard_handle_' + scores[i][0]);

            handle = document.createElement('a');
            $(handle).attr('href', breakdownurl + scores[i][0]);
            $(handle).text(scores[i][1]);

            td = document.createElement('td');
            $(td).append(handle);
            $(tr).append(td);

            td = document.createElement('td');
            $(td).text(scores[i][2]);
            $(tr).append(td);

            $('#scoreboard').append(tr);
        }

        $('#scoreboard_total').text("Total points: " + data['total_points']);

        for(h in highlights) {
            $('#scoreboard_handle_' + highlights[h]).addClass('recent');
        }
    });
}

function loadMachines(scoreurl) {
    $.ajax({
        'url': scoreurl,
        'dataType': 'json',
    }).done(function(data){
        var machines = data['machines'];

        $('#machine_list tr').remove();
        for(i in machines)
        {
            tr = document.createElement('tr');

            td = document.createElement('td');
            $(td).text(machines[i]['hostname']);
            $(tr).append(td);

            td = document.createElement('td');

            if(machines[i]['dirty'] == true) {
                $(tr).addClass('dirty');
                $(td).text("Needs reset");
            }
            else {
                $(td).text("Clean");
            }
            $(tr).append(td);

            $('#machine_list').append(tr);
        }
    });
}

function liveScoreboard(liveurl, scoreurl, breakdownurl) {
    var source = new EventSource(liveurl);
    source.onmessage = function(ev) {
        msg = ev.data.split(': ');
        if(msg[0] == 'score') {
            scoreSnd.play();
            scoreSnd.currentTime = 0;

            loadScores(scoreurl, breakdownurl, [msg[1]]);
        }
        else if(msg[0] == 'flash') {
            flash(msg[1]);
        }
    };
}

function liveDashboard(liveurl, scoreurl, breakdownurl) {
    var source = new EventSource(liveurl);
    source.onmessage = function(ev) {
        msg = ev.data.split(': ');
        if(msg[0] == 'score') {
            scoreSnd.play();
            scoreSnd.currentTime = 0;

            loadScores(scoreurl, breakdownurl, [msg[1]]);
        }
        else if(msg[0] == 'flash') {
            flash(msg[1]);
        }

        if(msg[2] == 'flag') {
            loadMachines(scoreurl);
        }
    };
}
<commit_msg>fix score sort in V8 (chrome, etc.)<commit_after>var scoreSnd = new Audio("static/sounds/score.wav");

function flash(msg) {
    $('#flash').text(msg);
    $('#flash').fadeIn('slow');
    $('#flash').click(function(){
        $('#flash').fadeOut('slow');
    });

    window.setTimeout(function(){
        $('#flash').fadeOut('slow');
        $('#flash').unbind();
    }, 5000);
}

function loadScores(scoreurl, breakdownurl, highlights) {
    $.ajax({
        'url': scoreurl,
        'dataType': 'json',
        'beakdownurl': breakdownurl,
        'highlights': highlights,
    }).done(function(data){
        var scores = [];

        // hack to sort scores
        for(k in data['scores'])
        {
            scores.push(data['scores'][k]);
        }
        scores.sort(function(a, b){
            return a[2] < b[2] ? 1 : -1;
        });

        $('#scoreboard tr').remove();
        for(i in scores)
        {
            tr = document.createElement('tr');
            $(tr).attr('id', 'scoreboard_handle_' + scores[i][0]);

            handle = document.createElement('a');
            $(handle).attr('href', breakdownurl + scores[i][0]);
            $(handle).text(scores[i][1]);

            td = document.createElement('td');
            $(td).append(handle);
            $(tr).append(td);

            td = document.createElement('td');
            $(td).text(scores[i][2]);
            $(tr).append(td);

            $('#scoreboard').append(tr);
        }

        $('#scoreboard_total').text("Total points: " + data['total_points']);

        for(h in highlights) {
            $('#scoreboard_handle_' + highlights[h]).addClass('recent');
        }
    });
}

function loadMachines(scoreurl) {
    $.ajax({
        'url': scoreurl,
        'dataType': 'json',
    }).done(function(data){
        var machines = data['machines'];

        $('#machine_list tr').remove();
        for(i in machines)
        {
            tr = document.createElement('tr');

            td = document.createElement('td');
            $(td).text(machines[i]['hostname']);
            $(tr).append(td);

            td = document.createElement('td');

            if(machines[i]['dirty'] == true) {
                $(tr).addClass('dirty');
                $(td).text("Needs reset");
            }
            else {
                $(td).text("Clean");
            }
            $(tr).append(td);

            $('#machine_list').append(tr);
        }
    });
}

function liveScoreboard(liveurl, scoreurl, breakdownurl) {
    var source = new EventSource(liveurl);
    source.onmessage = function(ev) {
        msg = ev.data.split(': ');
        if(msg[0] == 'score') {
            scoreSnd.play();
            scoreSnd.currentTime = 0;

            loadScores(scoreurl, breakdownurl, [msg[1]]);
        }
        else if(msg[0] == 'flash') {
            flash(msg[1]);
        }
    };
}

function liveDashboard(liveurl, scoreurl, breakdownurl) {
    var source = new EventSource(liveurl);
    source.onmessage = function(ev) {
        msg = ev.data.split(': ');
        if(msg[0] == 'score') {
            scoreSnd.play();
            scoreSnd.currentTime = 0;

            loadScores(scoreurl, breakdownurl, [msg[1]]);
        }
        else if(msg[0] == 'flash') {
            flash(msg[1]);
        }

        if(msg[2] == 'flag') {
            loadMachines(scoreurl);
        }
    };
}

{'fraction_non_alphanumeric': 0.18828078524687686, 'fraction_numerical': 0.00669244497323022, 'mean_word_length': 1.8825546506643807, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5608200', 'n_tokens_mistral': 2052, 'n_tokens_neox': 1990, 'n_words': 327}