<commit_before>var pusher;
var channel;
var roomMembers = ['12345678'];
$(function(){

	// var pusher = new Pusher('<PASSWORD>');
 //    var channel = pusher.subscribe('testtable_channel');
 //    channel.bind('debug_event', function(data) {
 //        alert(data.message);
 //    });

 //    channel.bind('userJoined', function(data) {
 //        addUserImage(data);
 //    });

    

});

function loadPusherMessaging(user)
{
    pusher = new Pusher('<PASSWORD>', { authEndpoint: 'http://testtable.mykebates.com/push/auth?username='+user.username+'&name='+user.name+'&image='+user.image });
	channel = pusher.subscribe('presence-testtable');

	// Enable pusher logging - don't include this in production
    // Pusher.log = function(message) {
    //   if (window.console && window.console.log) {
    //     window.console.log(message);
    //   }
    // };

    channel.bind('pusher:subscription_succeeded', function(members) {
        addUserImage(members.me.info);

        _.each(members, function(member){
            if(member.info){
                addMemberToRoom(member);
            }
        });
        var data = {
            'members': encodeURIComponent(roomMembers)
        }
        ajaxCall('http://testtable.dev/room/setdjs', data);
    });

    pusher.connection.bind('connected', function() { //bind a function after we've connected to Pusher
        //console.log('connected');
    });

    channel.bind('debug_event', function(data) {
        alert(data.message);
    });

    channel.bind('pusher:member_added', function(member) {
        addUserImage(member.info);
    });

   channel.bind('pusher:member_removed', function(member) {
        removeUserImage(member.info);
    });


}

function addUserImage(data){
	var userImage = '<li data-username="user_'+data.username+'" class="animated fadeIn"><img src="'+data.image+'" /></li>';
	$('#user_list').append(userImage);
}

function removeUserImage(data){
	$('#user_list li[data-username="user_'+data.username+'"]').fadeOut();
}

function addMemberToRoom(member){
    // have access to the member details here but just pusing the memberid for now
    roomMembers.push(member.id);
}


function ajaxCall(ajax_url, ajax_data, successCallback)
{
    $.ajax({
        type : "GET",
        url : ajax_url,
        dataType : "json",
        data: ajax_data,
        time : 10,
        success : function(msg) {
            if( msg.success ) {
                console.log('sdfsd');
            }else{
                alert(msg.errormsg);
            }
        },
        error: function(msg) {
            // log something
        }
    });
}<commit_msg>updates<commit_after>var pusher;
var channel;
var roomMembers = [];
$(function(){

	// var pusher = new Pusher('<PASSWORD>');
 //    var channel = pusher.subscribe('testtable_channel');
 //    channel.bind('debug_event', function(data) {
 //        alert(data.message);
 //    });

 //    channel.bind('userJoined', function(data) {
 //        addUserImage(data);
 //    });

    

});

function loadPusherMessaging(user)
{
    pusher = new Pusher('<PASSWORD>', { authEndpoint: 'http://testtable.mykebates.com/push/auth?username='+user.username+'&name='+user.name+'&image='+user.image });
	channel = pusher.subscribe('presence-testtable');

	// Enable pusher logging - don't include this in production
    // Pusher.log = function(message) {
    //   if (window.console && window.console.log) {
    //     window.console.log(message);
    //   }
    // };

    channel.bind('pusher:subscription_succeeded', function(members) {
        addUserImage(members.me);
        var userCount = 0;
        
        _.each(members, function(member){
            if(member.info){
                userCount ++;
                addToDJList(member);
            }
        });

        // This should fire for the first person in the room
        if(userCount == 1){
            var data = {
                'member': members.me.id,
                'isFirstDJ': true
            }
            ajaxCall('http://testtable.dev/room/djadd', data);
        }
    });

    pusher.connection.bind('connected', function() { //bind a function after we've connected to Pusher
        //console.log('connected');
    });

    channel.bind('debug_event', function(data) {
        alert(data.message);
    });

    channel.bind('pusher:member_added', function(member) {
        addUserImage(member);
    });

   channel.bind('pusher:member_removed', function(member) {
        removeUserImage(member.info);
    });


}

function addUserImage(data){
	var userImage = '<li data-userid="'+data.id+'" class="animated fadeIn"><img src="'+data.info.image+'" /></li>';
	$('#user_list').append(userImage);
}

function removeUserImage(data){
	$('#user_list li[data-userid="'+data.id+'"]').fadeOut();
}

function addToDJList(member){
    // have access to the member details here but just pusing the memberid for now
    roomMembers.push(member.id);
}

function reportAddedMember(member){
    var data = {
        'member': member.id
    }
    ajaxCall('http://testtable.dev/room/djadd', data);
}


function ajaxCall(ajax_url, ajax_data, successCallback)
{
    $.ajax({
        type : "GET",
        url : ajax_url,
        dataType : "json",
        data: ajax_data,
        time : 10,
        success : function(msg) {
            
        },
        error: function(msg) {
            // log something
        }
    });
}
{'fraction_non_alphanumeric': 0.16189244132323047, 'fraction_numerical': 0.00258732212160414, 'mean_word_length': 2.4759152215799616, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5646502', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1651, 'n_words': 290}