function GetElement( idElement ) { if( document.all ) return document.all( idElement ); return document.getElementById( idElement ); } function generateRatings(rating, nb_votes) { new Starbox('ratingDiv', rating, { rerate: false, indicator: '#{total} votes', total: nb_votes }); } function starClicked(event) { var xmlHttpReq=getXmlHttpRequest(); if(!xmlHttpReq) return; xmlHttpReq.open("POST","/videos/noter.htm",true); xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xmlHttpReq.send('&video_id='+video_id+'&rating='+event.memo.rated.toFixed(2)); } document.observe('dom:loaded', function() { document.observe('starbox:rated', starClicked); }); function starboxChangedText(event) { var indicator = this.down('.indicator'), pick = (event.memo.rating || 0).round() - 1, indicator = this.down('.indicator'); this.starboxResetText = this.starboxResetText || indicator.innerHTML; this.down('.indicator').update([ 'Nulle', 'Pas terrible', 'Déjà vu pire', 'Pas mal', 'Géniale !' ][pick]); } function starboxRatedText() { var indicator = this.down('.indicator'); this.starboxResetText = indicator.innerHTML; } function starboxLeftText() { this.down('.indicator').update(this.starboxResetText || ''); } document.observe('dom:loaded', function() { GetElement('ratingDiv').observe('starbox:changed', starboxChangedText); GetElement('ratingDiv').observe('starbox:rated', starboxRatedText); GetElement('ratingDiv').observe('starbox:left', starboxLeftText); }); function starboxThankYou(event) { var indicator = event.findElement('.starbox').down('.indicator'), restore = indicator.innerHTML; indicator.update('Merci d\'avoir noté cette vidéo'); } document.observe('dom:loaded', function() { GetElement('ratingDiv').observe('starbox:rated', starboxThankYou); });