Skip to content

Instantly share code, notes, and snippets.

Created March 24, 2012 23:37
Show Gist options
  • Save anonymous/2189103 to your computer and use it in GitHub Desktop.
Save anonymous/2189103 to your computer and use it in GitHub Desktop.
a guest on Mar 24th, 2012 - pastebin.com/BJMXR0wM
function fill_stars(rating)
{
switch(rating)
{
case 1:
document.getElementById("one").src = "res/star_full.gif";
break;
case 1.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_half.gif";
break;
case 2:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
break;
case 2.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_half.gif";
break;
case 3:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
break;
case 3.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_half.gif";
break;
case 4:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_full.gif";
break;
case 4.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_full.gif";
document.getElementById("five").src = "res/star_half.gif";
break;
case 5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_full.gif";
document.getElementById("five").src = "res/star_full.gif";
break;
}
}
function hover_stars(rating)
{
switch(rating)
{
case "1":
document.getElementById("one").src = "res/star_hover.gif";
break;
case "2":
document.getElementById("one").src = "res/star_hover.gif";
document.getElementById("two").src = "res/star_hover.gif";
break;
case "3":
document.getElementById("one").src = "res/star_hover.gif";
document.getElementById("two").src = "res/star_hover.gif";
document.getElementById("three").src = "res/star_hover.gif";
break;
case "4":
document.getElementById("one").src = "res/star_hover.gif";
document.getElementById("two").src = "res/star_hover.gif";
document.getElementById("three").src = "res/star_hover.gif";
document.getElementById("four").src = "res/star_hover.gif";
break;
case "5":
document.getElementById("one").src = "res/star_hover.gif";
document.getElementById("two").src = "res/star_hover.gif";
document.getElementById("three").src = "res/star_hover.gif";
document.getElementById("four").src = "res/star_hover.gif";
document.getElementById("five").src = "res/star_hover.gif";
break;
}
}
function remove_stars(rating,result)
{
switch(rating)
{
case "1":
document.getElementById("one").src = "res/star_empty.gif";
break;
case "2":
document.getElementById("one").src = "res/star_empty.gif";
document.getElementById("two").src = "res/star_empty.gif";
break;
case "3":
document.getElementById("one").src = "res/star_empty.gif";
document.getElementById("two").src = "res/star_empty.gif";
document.getElementById("three").src = "res/star_empty.gif";
break;
case "4":
document.getElementById("one").src = "res/star_empty.gif";
document.getElementById("two").src = "res/star_empty.gif";
document.getElementById("three").src = "res/star_empty.gif";
document.getElementById("four").src = "res/star_empty.gif";
break;
case "5":
document.getElementById("one").src = "res/star_empty.gif";
document.getElementById("two").src = "res/star_empty.gif";
document.getElementById("three").src = "res/star_empty.gif";
document.getElementById("four").src = "res/star_empty.gif";
document.getElementById("five").src = "res/star_empty.gif";
break;
}
switch(result)
{
case 1:
document.getElementById("one").src = "res/star_full.gif";
break;
case 1.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_half.gif";
break;
case 2:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
break;
case 2.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_half.gif";
break;
case 3:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
break;
case 3.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_half.gif";
break;
case 4:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_full.gif";
break;
case 4.5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_full.gif";
document.getElementById("five").src = "res/star_half.gif";
break;
case 5:
document.getElementById("one").src = "res/star_full.gif";
document.getElementById("two").src = "res/star_full.gif";
document.getElementById("three").src = "res/star_full.gif";
document.getElementById("four").src = "res/star_full.gif";
document.getElementById("five").src = "res/star_full.gif";
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment