<commit_before>/**
 * Created by Matt on 3/31/2016.
 */
$(function(){
    var challenges = [];
    var wordAt = [];
    var socket = io();

    $('span').on("keyup",function(){
        var boxID = this.className;
        var boxID = $(this).parent().attr('id');
        var boxValue = $('#'+boxID).html();
        console.log(boxID);
        socket.emit('text_change',[boxID,boxValue]);
    });

    socket.on('text_change', function(msg){
        var id = msg[0];
        var text = msg[1];
        console.log('Recipient = ' + id);
        console.log('    Text: ' + text);
        $('#'+id).html(text);
        cursorManager.setEndOfContenteditable($('#'+id)[0]);
    });

    socket.on('identify',function(){
        var userName = $('#userName').html();
        console.log("Setting self as: ", userName);
        $("body").data("playerName",userName);
        console.log("body.data('playerName') set as: ",$("body").data("playerName"));
        socket.emit('identity',userName);
    });

    socket.on('challenge_set',function(orig_challenges){
        console.log("setting challenges...");
        var num = orig_challenges.length;
        for(var i = 1;i<num+1;i++){
            words = orig_challenges[i-1].split(' ');
            var toReplace = [];
            $.each(words,function(index,value){
                toReplace [index] = "<span class='hidden'>"+value+"</span>";
            });
            challenges[i-1] = orig_challenges[i-1];
            wordAt[i-1] = 0;
            $('#challenge-'+i).html(toReplace.join(' '));
            updateChallenge(i)<commit_msg>Changed websockets.js to use persistant storage<commit_after>/**
 * Created by Matt on 3/31/2016.
 */
$(function(){
    var challenges = [];
    var wordAt = [];
    var socket = io();

    $('span').on("keyup",function(){
        var boxID = this.className;
        var boxID = $(this).parent().attr('id');
        var boxValue = $('#'+boxID).html();
        console.log(boxID);
        socket.emit('text_change',[boxID,boxValue]);
    });

    socket.on('text_change', function(msg){
        var id = msg[0];
        var text = msg[1];
        console.log('Recipient = ' + id);
        console.log('    Text: ' + text);
        $('#'+id).html(text);
        cursorManager.setEndOfContenteditable($('#'+id)[0]);
    });

    socket.on('identify',function(){
        var userName = localStorage.username;
        console.log("Setting self as: ", userName);
        $("body").data("playerName",userName);
        console.log("body.data('playerName') set as: ",$("body").data("playerName"));
        socket.emit('identity',userName);
    });

    socket.on('challenge_set',function(orig_challenges){
        console.log("setting challenges...");
        var num = orig_challenges.length;
        for(var i = 1;i<num+1;i++){
            words = orig_challenges[i-1].split(' ');
            var toReplace = [];
            $.each(words,function(index,value){
                toReplace [index] = "<span class='hidden'>"+value+"</span>";
            });
            challenges[i-1] = orig_challenges[i-1];
            wordAt[i-1] = 0;
            $('#challenge-'+i).html(toReplace.join(' '));
            updateChallenge(i)
{'fraction_non_alphanumeric': 0.1996875, 'fraction_numerical': 0.010625, 'mean_word_length': 2.416221985058698, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3200778', 'n_tokens_mistral': 1019, 'n_tokens_neox': 969, 'n_words': 162}