App.order = App.cable.subscriptions.create('OrderChannel', {
  connected: function() {},

  disconnected: function() {},

  received: function(data) {         
  var hostname = location.hostname.trim();
  // console.log(hostname)
  // console.log(data.from)
    if(data.from == "" || hostname == data.from)
    {  
     if (data.type == 'order') {
     	$('.table_'+data.table.id).removeClass('green');
	    $('.table_'+data.table.id).addClass('blue');
	    $('.new_text_'+data.table.id).removeClass('hide')
     }else if(data.type == 'move'){
        $('.table_'+data.table).removeClass('blue');
        $('.table_'+data.table).addClass('green');
        $('.table_'+data.change_to).addClass('blue');
    }else{
     	$('.table_'+data.table.id).removeClass('red');
	    $('.table_'+data.table.id).addClass('green');
	    $('.new_text_'+data.table.id).html('');
	    $('.new_text_'+data.table.id).removeClass('hide')
     }
   }
 }
});

