function callHandlerAjaxVote( postObj, handlercall ) { new Ajax.Request( "https://www.presenca.pt/js/../ajax/handler_ajax.php?uid=&uoid=&un=d41d8cd98f00b204e9800998ecf8427e&ue=d41d8cd98f00b204e9800998ecf8427e", { method: "post", postBody: 'data=' + Object.toJSON(postObj), onSuccess: function(t) { eval(handlercall+"(t);"); },on404: function(t) { return -1 }, onFailure: function(t) { return -1 } } ); } function observeAddRatingVote( obj ) { var tmp = obj.responseText.evalJSON(); if( tmp.message == 'notident' ) { document.location='https://www.presenca.pt/js/../account.ud121?target_script=catalogue.ud121&referer_attributes=%26oid%3D' + oid; return; } else { $('voteStatus').innerHTML = tmp.message; $('voteStatus').style.display = 'block'; $('vote_td_title').innerHTML = "Classificação dada:"; setTimeout("$('voteStatus').style.display = 'none';", 3000 ); } // global vote var a = 0; for( var i = 1; i <= tmp.ra_stars_num; i++ ) { a++; $('stars_media_' + a ).src = 'https://www.presenca.pt/images//'+img_prefix+'-stars.gif'; } for( var i = 1; i <= tmp.ra_stars_num_half; i++ ) { a++; $('stars_media_' + a ).src = 'https://www.presenca.pt/images//'+img_prefix+'-star-mid.gif'; } for( var i = 1; i <= (5-(tmp.ra_stars_num_half+tmp.ra_stars_num)); i++ ) { a++; $('stars_media_' + a ).src = 'https://www.presenca.pt/images//'+img_prefix+'-stars-off.gif'; } $('num_votacoes').innerHTML = tmp.num_votes; if( tmp.num_votes == 1 ) $('num_votacoes_info').innerHTML = 'Votação'; else $('num_votacoes_info').innerHTML = 'Votações'; var msg; switch( tmp.voto ) { case 1: msg = 'Mau'; break; case 2: msg = 'Fraco'; break; case 3: msg = 'Razoável'; break; case 4: msg = 'Bom'; break; case 5: msg = 'Muito Bom'; break; } document.getElementById('vote_info').innerHTML = '' + msg + ''; document.getElementById('vote_info_bk').innerHTML = msg; // user vote var a = 0; for( var i = 1; i <= tmp.voto; i++ ) { a++; $('star_rating_' + a ).src = 'https://www.presenca.pt/images//'+img_prefix+'-stars.gif'; $('star_rating_' + a + 'bk' ).innerHTML = 'https://www.presenca.pt/images//'+img_prefix+'-stars.gif'; } for( var i = tmp.voto; i <= 5; i++ ) { a++; $('star_rating_' + a ).src = 'https://www.presenca.pt/images//'+img_prefix+'-stars-off.gif'; $('star_rating_' + a + 'bk' ).innerHTML = 'https://www.presenca.pt/images//'+img_prefix+'-stars-off.gif'; } // SubFunction function notifyPageMessage( rstatus, message ) { if( message == 'notident' ) { showIdentificationBox( ); } } } function observeRatingVote( vote ){ $('voteStatus').innerHTML = 'Loading...'; $('voteStatus').style.display = 'block'; callHandlerAjaxVote( { 'action': 'votecontent', 'oid': oid, 'vote': vote }, 'observeAddRatingVote' ); return; } function observeRatingChangeOn( numStars ) { for( i=1; i<=5; i++ ){ document.getElementById('star_rating_' + i).src = 'https://www.presenca.pt/images//'+img_prefix+'-stars-off.gif'; } for( i=1; i<=numStars; i++ ){ document.getElementById('star_rating_' + i).src = 'https://www.presenca.pt/images//'+img_prefix+'-stars.gif'; } var msg; switch( numStars ) { case 1: msg = 'Mau'; break; case 2: msg = 'Fraco'; break; case 3: msg = 'Razoável'; break; case 4: msg = 'Bom'; break; case 5: msg = 'Muito Bom'; break; } document.getElementById('vote_info').innerHTML = msg; } function observeRatingChangeOff( ) { for( i=1; i<=5; i++ ){ document.getElementById('star_rating_' + i).src = document.getElementById('star_rating_'+i+'bk').innerHTML; } //document.getElementById('vote_info').innerHTML = '<< Seleccionar votação'; document.getElementById('vote_info').innerHTML = document.getElementById('vote_info_bk').innerHTML; } function ratecontent( kindvote, oid, votecase, cnt_oid ){ postObj = { 'action': 'ratecontent', 'vote': kindvote, 'oid': oid, 'votecase': votecase}; new Ajax.Request( "https://www.presenca.pt/js/../ajax/handler_ajax.php?uid=&uoid=&un=d41d8cd98f00b204e9800998ecf8427e&ue=d41d8cd98f00b204e9800998ecf8427e", { method: "post", postBody: 'data=' + Object.toJSON(postObj), onSuccess: function(t) { var tmp = t.responseText.evalJSON(); if( tmp.info_status == 1 ) { $('alert-message'+oid).style.display = ''; $('alert-message'+oid).innerHTML = "
"+tmp.message+"
"; $('vote_yes').onclick= function( ) { return false; }; $('vote_no').onclick=function( ) { return false; }; } else { if( tmp.message == 'notident' ) { $('alert-message'+oid).innerHTML = 'Precisa de estar identificado. A redireccionar...'; if (votecase == 'listmanias') { //para ser utilizado nas votações aos conteúdos document.location='https://www.presenca.pt/js/../account.ud121?target_script=catalogue.ud121&referer_attributes=%26oid%3D' + oid; } else { //para ser utilzado nas votações aos multivaleres e etc. document.location='https://www.presenca.pt/js/../account.ud121?target_script=catalogue.ud121&referer_attributes=%26oid%3D' + cnt_oid; } //referer_attributes=target_script%3Dcatalogue.ud121%2526oid%253D21319&from_zone=Link+no+Formulario+Geral+de+Login // } else { $('alert-message'+oid).innerHTML = "
"+tmp.message+"
"; } } }, on404: function(t) { return -1 }, onFailure: function(t) { alert( 'Não é possível votar. Verifique a sua ligação à internet e tente novamente.' ); } } ); } /* function checkAutenticatedUser( obj ) { if( obj == null ) { callhandlerAjax( { 'action': 'checkautenticateduser' }, 'checkAutenticatedUser' ); return; } var tmp = obj.responseText.evalJSON(); return tmp.info_status; }*/