var test_show_loading = 0;
var test_ajax_url = "/wp-content/plugins/presence/test-ajax.php";
var test = new sack(test_ajax_url);
function finito() {
document.location.href = '';
}
function reload_user_presences(action,post_id,blog_id,user_id) {
/*if(test_show_loading) {
if(document.getElementById('presence-loading') != '')
document.getElementById('presence-loading').style.display = 'block';
}*/
test.reset();
test.setVar("action", action);
test.setVar("pid", post_id);
test.setVar("uid", user_id);
test.setVar("bid", blog_id);
test.method = 'GET';
test.element = "partecipanti";
test.onCompletion = function() {
/*if(test_show_loading) {
if(document.getElementById('presence-loading') != '')
document.getElementById('presence-loading').style.display = 'none';
}*/
}
test.runAJAX();
}
function presence(action,post_id,blog_id,user_id,count){
/* if(test_show_loading) {
if(document.getElementById('presence-' + post_id + '-loading') != '')
document.getElementById('presence-' + post_id + '-loading').style.display = 'block';
}*/
test.reset();
test.setVar("action", action);
test.setVar("pid", post_id);
test.setVar("uid", user_id);
test.setVar("bid", blog_id);
test.method = 'GET';
//test.element = "test_ajax_result";
test.onCompletion = function() {
if(action == 'add') {
count++;
//alert('ADD : '+count+'utenti');
if(document.getElementById('infopresence_'+ post_id))
document.getElementById('infopresence_'+ post_id).innerHTML = ''+count+'
persone presenti';
document.getElementById('presencelink-'+ post_id).innerHTML = 'rimuovi la tua presenza da questo evento';
//location.hash = '#top';
showmessage(test.response);
} else {
count--;
//alert('REM : '+count+'utenti');
if(document.getElementById('infopresence_'+ post_id))
document.getElementById('infopresence_'+ post_id).innerHTML = ''+count+'
persone presenti';
document.getElementById('presencelink-'+ post_id).innerHTML = 'aggiungi la tua presenza a questo evento';
//location.hash = '#top';
showmessage(test.response);
}
if(document.getElementById('partecipanti') != '') {
reload_user_presences('reload_presences',post_id,blog_id,user_id);
}
/*if(test_show_loading) {
if(document.getElementById('presence-' + post_id + '-loading') != '')
document.getElementById('presence-' + post_id + '-loading').style.display = 'none';
}*/
};
//test.onCompletion = finito;
test.runAJAX();
}