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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| function note(id, note)
{
var i;
var star = '';
if (note === 0)
{
star = '<img src="img/stars/croix.gif" onclick="del(' + id + ',0);note(' + id + ',0)"><img src="img/stars/vide-left.png" onmouseover="note(' + id + ',1)"><img src="img/stars/vide-right.png" onmouseover="note(' + id + ',2)"> <img src="img/stars/vide-left.png" onmouseover="note(' + id + ',3)"><img src="img/stars/vide-right.png" onmouseover="note(' + id + ',4)"> <img src="img/stars/vide-left.png" onmouseover="note(' + id + ',6)"><img src="img/stars/vide-right.png" onmouseover="note(' + id + ',5)"> <img src="img/stars/vide-left.png" onmouseover="note(' + id + ',7)"><img src="img/stars/vide-right.png" onmouseover="note(' + id + ',8)"> <img src="img/stars/vide-left.png" onmouseover="note(' + id + ',9)"><img src="img/stars/vide-right.png" onmouseover="note(' + id + ',10)">';
}
else
{
star = '<img src="img/stars/croix.gif" onclick="del(' + id + ',0);note(' + id + ',0)">';
for (i = 1; i <= note; i++)
{
if (i % 2 == 1)
{
star = star + '<img src="img/stars/pleine-left.png" onmouseover="note(' + escape(id) + ',' + escape(i) + ')" onclick="valide('+ escape(id) + ','+escape(i)/2+')">';
}
if (i % 2 == 0)
{
star = star + '<img src="img/stars/pleine-right.png" onmouseover="note(' + escape(id) + ',' + escape(i) + ')" onclick="valide('+ escape(id) + ','+escape(i)/2+')">';
}
}
for (i = (note + 1); i <= 10; i++)
{
if (i % 2 == 1)
{
star = star + '<img src="img/stars/vide-left.png" onmouseover="note(' + escape(id) + ',' + escape(i) + ')" onclick="valide('+ escape(id) + ','+escape(i)/2+')">';
}
if (i % 2 == 0)
{
star = star + '<img src="img/stars/vide-right.png" onmouseover="note(' + escape(id) + ',' + escape(i) + ')" onclick="valide('+ escape(id) + ','+escape(i)/2+')">';
}
}
}
note = note / 2;
document.getElementById('note-' + id).innerHTML = star;
}
function valide(id,note)
{
var saved=newtotalnote=file('../addnote.php?program_id=' + escape(id)+'¬e=' + escape(note));
if(saved==1)
{
var newtotalnote=file('../totalnote.php?program_id=' + escape(id));
var newtotalnotant=file('../totalnotant.php?program_id=' + escape(id));
document.getElementById('visuelnote-' + id).innerHTML = '';
document.getElementById('rate-' + id).innerHTML = newtotalnote+'( '+newtotalnotant+ ')<img src="img/stars/pleine-full.png">';
generate('Votre note: <b>'+note+'</b> a bien était enleve');
}
}
function del(id)
{
var saved=newtotalnote=file('../delnote.php?program_id=' + escape(id));
if(saved==1)
{
var newtotalnote=file('../totalnote.php?program_id=' + escape(id));
var newtotalnotant=file('../totalnotant.php?program_id=' + escape(id));
document.getElementById('visuelnote-' + id).innerHTML = '';
document.getElementById('rate-' + id).innerHTML = newtotalnote+'( '+newtotalnotant+ ')<img src="img/stars/pleine-full.png">';
generate('Votre note pour le programme : <b>'+id+'</b> a bien était enleve');
}
}
function generate(text) {
var n = noty({
text: text,
type: 'warning',
timeout:2000,
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme'
});
console.log('html: '+n.options.id);
}
function file(fichier)
{
if (window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if (window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
return(false);
xhr_object.open("GET", fichier, false);
xhr_object.send(null);
if (xhr_object.readyState == 4)
return(xhr_object.responseText);
else
return(false);
} |
Partager