1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| $('button[name="action"]').on('click', function(event){
var button = $(this);
var action = $(this).attr('action');
var id = $(this).attr('id');
switch(action){
case 'off':
$('button[name="action"]#'+id+' span').attr('class', 'fa fa-play');
$(this).attr('action', 'on');
$("button").remove("[name='view']#"+id);
$('#online').text(Number($('#online').text()) - 1);
$('#offline').text(Number($('#offline').text()) + 1);
break;
case 'on':
$('button[name="action"]#'+id+' span').attr('class', 'fa fa-stop');
$(this).attr('action', 'off');
$("#"+id).append('<button name="view" id="' + id + '" class="btn btn-default btn-xs" title="Voir en ligne" onClick="window.location.href=\'' + Routing.generate('geograph_progasso_fiche',{'id': id}) + '\'"><span name="view" id="' + id + '" class="fa fa-eye"></span></button>')
$('#online').text(Number($('#online').text()) + 1);
$('#offline').text(Number($('#offline').text()) - 1);
break;
}
$.ajax({
type: 'get',
url: Routing.generate('putOnline', {'id': id}),
beforeSend: function(){
},
success: function(){
},
});
}) |
Partager