-
Notifications
You must be signed in to change notification settings - Fork 1
/
Movies.js
68 lines (56 loc) · 1.53 KB
/
Movies.js
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
function initMovies() {
for (i = 0; i < letters.length; ++i)
{
movies[letters[i]] = [];
}
}
function RefreshMovies(){
$.ajax({
url: "/JSONInputFolder?folder=" + moviesRoot + "&pattern=" + pattern,
cache: true
}).done(function(response){
var suggestions = jQuery.parseJSON(response);
var moviefolders = suggestions[0];
var exception = suggestions[1];
if(exception.length == 0)
msg = "";
else
msg = "An error happened: " + exception;
initMovies();
document.getElementById("exception").innerHTML = msg;
jQuery.each(moviefolders, function(i, movieFolder) {
var letter = undefined;
var upperMovieFolder = movieFolder.toUpperCase();
for(i = 0; i < upperMovieFolder.length; ++i)
{
if(upperMovieFolder[i].match(/[A-Z]/))
{
letter = upperMovieFolder[i];
break;
}
else if(upperMovieFolder[i].match(/[0-9]/))
{
letter = "num";
break;
}
}
if (letter == undefined)
{
letter = "num";
}
movies[letter].push(movieFolder);
movies["All"].push(movieFolder);
});
for(i = 0; i < letters.length; ++i)
{
//$("div#movies-" + letters).text =
var letter = letters[i];
var id = "movies-" + letter;
var moviesList = "";
jQuery.each(movies[letter], function(i, movie) {
moviesList = moviesList + "<br/>" + movie;
})
document.getElementById(id).innerHTML = moviesList;
}
});
}