Created
April 14, 2013 19:08
-
-
Save dinnouti/5383815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mediaType = "ED"; // ED for streaming; 1 for DVD | |
var lxMovies = new Array(); | |
function lxMovie(title, starRating, id) { | |
this.title = title; | |
this.starRating = starRating; | |
this.id = id; | |
} | |
// sorting helper | |
function lxSortByStarRating(a, b) { | |
var x = b.starRating; | |
var y = a.starRating; | |
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); | |
} | |
// get all movies | |
i = 0; | |
jQuery('tr[data-mediatype="'+ mediaType +'"]').each(function(){ | |
i++; | |
starRating = jQuery(this).find("span.stbrMaskFg").attr("class").substring(23); | |
title = jQuery(this).find("span.title").text(); | |
id = jQuery(this).attr("data-mid"); | |
lxMovies[lxMovies.length++] = new lxMovie(title, starRating, id); | |
}); | |
lxMovies.sort(lxSortByStarRating); | |
// set the value of the list order | |
for (var i=0; i<lxMovies.length; i++) | |
{ | |
selector = 'input[name="OR'+ lxMovies[i].id +'"]'; | |
jQuery(selector).val(i + 1); | |
console.log(i+1, lxMovies[i].title, lxMovies[i].starRating) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment