How to implement Netflix like rating using jQuery
There are quit a few jQuery plugins for star rating, but I have not found one that allows me to implement a Netflix like star rating widget. Specifically, I would like to have following features:
- if the user has rated the movie, then show his rating with one color (say yellow)
- if the user has not rated the movie, then show the average rating of others with anot开发者_如何学Cher color (say red)
- in the above two cases, use can submit his rating (create/update)
- user's rating can only be integer between 1 and 5, while all user's average rating can be non-integer from 1 to 5 with step 0.1
The key challenges here are:
- use different colors of the stars to indicate a user if he has rated the movie or not
- when displaying average rating non-integer is allowed but when user rates only integer rating is allowed
Can anyone give me some hints?
I think you're looking in completely the wrong place when you talk about this as a jQuery issue. It doesn't seem to be jQuery, nor JavaScript. The issues you describe have to do with pulling data from a database and outputting them to the page.
Some thoughts on the key challenges you list:
1) The core of this will be the code you write that pulls data from your DB and outputs it to the page (such as PHP). I'd just have that code add a certain class depending on whether the user has rated it or not (and that class would do the work of setting the appropriate color).
2) Again, this is a server-side issue. You're pulling data from a database. I assume if the user has given their rating, then the number stored in the DB for that rating will already be an integer since that's all that is accepted. If the user hasn't given a rating, then you'll be averaging the ratings of other users.
精彩评论