Browse files

refactored code

  • Loading branch information...
1 parent 8a3e573 commit eb665ef0b1022bbe2c81f2e28540856d26c3ac29 @aakashrathi aakashrathi committed Oct 11, 2012
Showing with 451 additions and 462 deletions.
  1. +110 −111 javascript/script.js
  2. +59 −61 javascript/script_animated.js
  3. +63 −65 javascript/script_comedy.js
  4. +57 −59 javascript/script_horror.js
  5. +101 −103 javascript/script_romance.js
  6. +61 −63 javascript/script_scifi.js
View
221 javascript/script.js
@@ -3,90 +3,89 @@ var x = 0;
var bestMovie;
var simMoviesArray = new Array(4);
var movies = {};
-var actionMovies =
- [
- "Braveheart",
- "Kill Bill",
- "Saving Private Ryan",
- "Rocky",
- "The Town",
- "Ocean's Eleven",
- "Troy",
- "Alien",
- "Inglorious Basterds",
- "The Lord of the Rings The Return of the King",
- "Pulp Fiction",
- "Kick-Ass",
- "Gladiator",
- "Fight Club",
- "The Bourne Identity",
- "Seven Samurai",
- "Point Break",
- "Speed",
- "Looper",
- "Taken",
- "300",
- "V for Vendetta",
- "Sherlock Holmes",
- "X-Men",
- "Indiana Jones",
- "The Expendables",
- "Lethal Weapon",
- "Enter the Dragon"
+var actionMovies = [
+ "Braveheart",
+ "Kill Bill",
+ "Saving Private Ryan",
+ "Rocky",
+ "The Town",
+ "Ocean's Eleven",
+ "Troy",
+ "Alien",
+ "Inglorious Basterds",
+ "The Lord of the Rings The Return of the King",
+ "Pulp Fiction",
+ "Kick-Ass",
+ "Gladiator",
+ "Fight Club",
+ "The Bourne Identity",
+ "Seven Samurai",
+ "Point Break",
+ "Speed",
+ "Looper",
+ "Taken",
+ "300",
+ "V for Vendetta",
+ "Sherlock Holmes",
+ "X-Men",
+ "Indiana Jones",
+ "The Expendables",
+ "Lethal Weapon",
+ "Enter the Dragon"
]
- var dic = {
- 'Braveheart': '12866',
- 'The Green Mile': '12939',
- 'Star Wars Episode IV - A New Hope':'11292',
- 'Inglorious Basterds': '770671947',
- 'The Silence of the Lambs': '16286',
- 'Jurassic Park': '10983',
- 'The Lord of the Rings The Return of the King': '10156',
- 'Crash': '12',
- 'The Terminator': '770676948',
- 'The Dark Knight': '769959054',
- 'I, Robot': '10040',
- 'The Shining': '14884',
- 'The Town': '770814363',
- 'The Shawshank Redemption': '12989',
- 'Kill Bill': '12865',
- 'Forrest Gump':'10036',
- 'Saving Private Ryan': '13217',
- 'Rocky': '11405',
- 'Pulp Fiction': '13863',
- 'Fight Club': '13153',
- 'Back to the Future':'23532',
- 'Million Dollar Baby': '10026',
- 'The Longest Yard': '669',
- 'American History X':'12900',
- 'Dawn of the Dead': '17051',
- 'Paranormal Activity':'770728015',
- 'Jerry Maguire': '13109',
- 'Eternal Sunshine Of The Spotless Mind': '12860',
- 'The Departed': '314387087',
- 'Alien': '13492',
- 'Ocean\'s Eleven': '10182',
- 'Troy': '12890',
- 'Old School': '16825',
- 'Gladiator': '13065',
- 'The Bourne Identity': '11357',
- 'Die Hard': '16351',
- 'Seven Samurai': '16992',
- 'Point Break': '13320',
- 'Casino Royale': '358179513',
- 'Speed': '14748',
- 'Looper': '771186945',
- 'Taken': '770680780',
- 'Kick-Ass': '770786150',
- '300': '344023668',
- 'V for Vendetta': '112770454',
- 'Sherlock Holmes': '770796118',
- 'X-Men': '771041145',
- 'Indiana Jones': '23530',
- 'The Expendables': '770802244',
- 'Lethal Weapon': '17397',
- 'Enter the Dragon': '13174'
+var dic = {
+ 'Braveheart': '12866',
+ 'The Green Mile': '12939',
+ 'Star Wars Episode IV - A New Hope': '11292',
+ 'Inglorious Basterds': '770671947',
+ 'The Silence of the Lambs': '16286',
+ 'Jurassic Park': '10983',
+ 'The Lord of the Rings The Return of the King': '10156',
+ 'Crash': '12',
+ 'The Terminator': '770676948',
+ 'The Dark Knight': '769959054',
+ 'I, Robot': '10040',
+ 'The Shining': '14884',
+ 'The Town': '770814363',
+ 'The Shawshank Redemption': '12989',
+ 'Kill Bill': '12865',
+ 'Forrest Gump': '10036',
+ 'Saving Private Ryan': '13217',
+ 'Rocky': '11405',
+ 'Pulp Fiction': '13863',
+ 'Fight Club': '13153',
+ 'Back to the Future': '23532',
+ 'Million Dollar Baby': '10026',
+ 'The Longest Yard': '669',
+ 'American History X': '12900',
+ 'Dawn of the Dead': '17051',
+ 'Paranormal Activity': '770728015',
+ 'Jerry Maguire': '13109',
+ 'Eternal Sunshine Of The Spotless Mind': '12860',
+ 'The Departed': '314387087',
+ 'Alien': '13492',
+ 'Ocean\'s Eleven': '10182',
+ 'Troy': '12890',
+ 'Old School': '16825',
+ 'Gladiator': '13065',
+ 'The Bourne Identity': '11357',
+ 'Die Hard': '16351',
+ 'Seven Samurai': '16992',
+ 'Point Break': '13320',
+ 'Casino Royale': '358179513',
+ 'Speed': '14748',
+ 'Looper': '771186945',
+ 'Taken': '770680780',
+ 'Kick-Ass': '770786150',
+ '300': '344023668',
+ 'V for Vendetta': '112770454',
+ 'Sherlock Holmes': '770796118',
+ 'X-Men': '771041145',
+ 'Indiana Jones': '23530',
+ 'The Expendables': '770802244',
+ 'Lethal Weapon': '17397',
+ 'Enter the Dragon': '13174'
};
@@ -99,51 +98,51 @@ function simMovies(movie) {
var Url1 = "http://api.rottentomatoes.com/api/public/v1.0/movies/";
var Url2 = "/similar.json?apikey=" + apikey + "&limit=5";
var query = dic[movie];
- $(document).ready(function () {
- $.ajax({
- url: Url1 + query + Url2,
- dataType: "jsonp",
- success: searchCallback
- });
+ $(document).ready(function() {
+ $.ajax({
+ url: Url1 + query + Url2,
+ dataType: "jsonp",
+ success: searchCallback
+ });
});
}
function addMoviesToHtml() {
$.each(simMoviesArray, function(index, movie) {
- if (movie != undefined) {
- var title = movie.title;
- if ((movie.ratings.critics_rating == "Certified Fresh") && (movies[title] == null) && x < 18) {
- movies[title] = 1;
- var link = movie.links.alternate;
- var movieLink = '<a href="' + link + '">';
- var endTag = ' </a>';
- movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
- document.getElementById('movie'+x).innerHTML += movieName;
- x++;
- }
- }
- });
+ if (movie != undefined) {
+ var title = movie.title;
+ if ((movie.ratings.critics_rating == "Certified Fresh") && (movies[title] == null) && x < 18) {
+ movies[title] = 1;
+ var link = movie.links.alternate;
+ var movieLink = '<a href="' + link + '">';
+ var endTag = ' </a>';
+ movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
+ document.getElementById('movie' + x).innerHTML += movieName;
+ x++;
+ }
+ }
+ });
}
function searchCallback(data) {
var i = 0;
- for(i = 0; i < 5; i++) {
- if (data.movies != undefined) {
- simMoviesArray[i] = data.movies[i];
- }
+ for (i = 0; i < 5; i++) {
+ if (data.movies != undefined) {
+ simMoviesArray[i] = data.movies[i];
+ }
}
addMoviesToHtml();
}
function toggle() {
- var i = Math.floor((Math.random()*22)+1);
+ var i = Math.floor((Math.random() * 22) + 1);
var check = 0;
while (check < 9) {
- simMovies(actionMovies[i]);
- i++;
- check++;
+ simMovies(actionMovies[i]);
+ i++;
+ check++;
}
-}
+}
-window.onload = toggle();
+window.onload = toggle();
View
120 javascript/script_animated.js
@@ -3,37 +3,36 @@ var x = 0;
var bestMovie;
var simMoviesArray = new Array(4);
var movies = {};
-var animatedMovies =
- [
- "Toy Story",
- "Lion King",
- "Finding Nemo",
- "Up",
- "Kung Fu Panda",
- "Shrek",
- "Tangled",
- "Mulan",
- "The Incredibles",
- "Beauty and the Beast",
- "How to Train Your Dragon",
- "Aladdin",
- "Spirited Away"
+var animatedMovies = [
+ "Toy Story",
+ "Lion King",
+ "Finding Nemo",
+ "Up",
+ "Kung Fu Panda",
+ "Shrek",
+ "Tangled",
+ "Mulan",
+ "The Incredibles",
+ "Beauty and the Beast",
+ "How to Train Your Dragon",
+ "Aladdin",
+ "Spirited Away"
]
- var dic = {
- 'Toy Story': '9559',
- 'Lion King':'9385',
- 'Finding Nemo': '9377',
- 'Up': '770671912',
- 'Kung Fu Panda': '770672401',
- 'Shrek': '10166',
- 'Tangled':'770678818',
- 'Mulan': '9714',
- 'The Incredibles': '10011',
- 'Beauty and the Beast': '9980',
- 'How to Train Your Dragon': '770782733',
- 'Aladdin': '9383',
- 'Spirited Away': '10065'
+var dic = {
+ 'Toy Story': '9559',
+ 'Lion King': '9385',
+ 'Finding Nemo': '9377',
+ 'Up': '770671912',
+ 'Kung Fu Panda': '770672401',
+ 'Shrek': '10166',
+ 'Tangled': '770678818',
+ 'Mulan': '9714',
+ 'The Incredibles': '10011',
+ 'Beauty and the Beast': '9980',
+ 'How to Train Your Dragon': '770782733',
+ 'Aladdin': '9383',
+ 'Spirited Away': '10065'
};
@@ -46,55 +45,54 @@ function simMovies(movie) {
var Url1 = "http://api.rottentomatoes.com/api/public/v1.0/movies/";
var Url2 = "/similar.json?apikey=" + apikey + "&limit=5";
var query = dic[movie];
- $(document).ready(function () {
- $.ajax({
- url: Url1 + query + Url2,
- dataType: "jsonp",
- success: searchCallback
- });
+ $(document).ready(function() {
+ $.ajax({
+ url: Url1 + query + Url2,
+ dataType: "jsonp",
+ success: searchCallback
+ });
});
}
function addMoviesToHtml() {
$.each(simMoviesArray, function(index, movie) {
- if (movie != undefined) {
- var title = movie.title;
- if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950 &&
- x < 18) {
- movies[title] = 1;
- console.log(movies);
- var link = movie.links.alternate;
- var movieLink = '<a href="' + link + '">';
- var endTag = ' </a>';
- movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
- document.getElementById('movie'+x).innerHTML += movieName;
- x++;
- }
- }
- });
+ if (movie != undefined) {
+ var title = movie.title;
+ if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950 && x < 18) {
+ movies[title] = 1;
+ console.log(movies);
+ var link = movie.links.alternate;
+ var movieLink = '<a href="' + link + '">';
+ var endTag = ' </a>';
+ movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
+ document.getElementById('movie' + x).innerHTML += movieName;
+ x++;
+ }
+ }
+ });
}
function searchCallback(data) {
var i = 0;
- for(i = 0; i < 5; i++) {
- if (data.movies != undefined) {
- simMoviesArray[i] = data.movies[i];
- }
+ for (i = 0; i < 5; i++) {
+ if (data.movies != undefined) {
+ simMoviesArray[i] = data.movies[i];
+ }
}
addMoviesToHtml();
}
function toggle() {
var len = animatedMovies.length;
- var i = Math.floor((Math.random()*len)+1);
+ var i = Math.floor((Math.random() * len) + 1);
var check = 0;
while (check < 9) {
- console.log(x);
- simMovies(animatedMovies[i]);
- i=Math.floor((Math.random()*len)+1);
- check++;
+ console.log(x);
+ simMovies(animatedMovies[i]);
+ i = Math.floor((Math.random() * len) + 1);
+ check++;
}
-}
+}
-window.onload = toggle();
+window.onload = toggle();
View
128 javascript/script_comedy.js
@@ -3,42 +3,41 @@ var x = 0;
var bestMovie;
var simMoviesArray = new Array(4);
var movies = {};
-var comedyMovies =
- [
- "Hitch",
- "Theres Something About Mary",
- "Knocked Up",
- "Forgetting Sarah Marshall",
- "40 Year Old Virgin",
- "The Hangover",
- "Airplane!",
- "Annie Hall",
- "Ferris Buellers Day Off",
- "Little Miss Sunshine",
- "Mrs. Doubtfire",
- "Zoolander",
- "Bridesmaids",
- "Four Weddings and a Funeral",
- "Monty Python and the Holy Grail"
+var comedyMovies = [
+ "Hitch",
+ "Theres Something About Mary",
+ "Knocked Up",
+ "Forgetting Sarah Marshall",
+ "40 Year Old Virgin",
+ "The Hangover",
+ "Airplane!",
+ "Annie Hall",
+ "Ferris Buellers Day Off",
+ "Little Miss Sunshine",
+ "Mrs. Doubtfire",
+ "Zoolander",
+ "Bridesmaids",
+ "Four Weddings and a Funeral",
+ "Monty Python and the Holy Grail"
]
- var dic = {
- 'Hitch': '11616',
- 'Theres Something About Mary': '17462',
- 'Knocked Up': '460328477',
- 'Monty Python and the Holy Grail': '11450',
- 'Forgetting Sarah Marshall': '770675807',
- '40 Year Old Virgin': '5077',
- 'The Hangover': '770801897',
- 'Airplane!': '10421',
- 'Annie Hall': '10183',
- 'Ferris Buellers Day Off': '12224',
- 'Little Miss Sunshine': '190816246',
- 'Mrs. Doubtfire': '10997',
- 'Zoolander': '10109',
- 'Bridesmaids': '771039065',
- 'Four Weddings and a Funeral': '15959',
- 'The Pink Panther': '19049948'
+var dic = {
+ 'Hitch': '11616',
+ 'Theres Something About Mary': '17462',
+ 'Knocked Up': '460328477',
+ 'Monty Python and the Holy Grail': '11450',
+ 'Forgetting Sarah Marshall': '770675807',
+ '40 Year Old Virgin': '5077',
+ 'The Hangover': '770801897',
+ 'Airplane!': '10421',
+ 'Annie Hall': '10183',
+ 'Ferris Buellers Day Off': '12224',
+ 'Little Miss Sunshine': '190816246',
+ 'Mrs. Doubtfire': '10997',
+ 'Zoolander': '10109',
+ 'Bridesmaids': '771039065',
+ 'Four Weddings and a Funeral': '15959',
+ 'The Pink Panther': '19049948'
};
@@ -51,54 +50,53 @@ function simMovies(movie) {
var Url1 = "http://api.rottentomatoes.com/api/public/v1.0/movies/";
var Url2 = "/similar.json?apikey=" + apikey + "&limit=5";
var query = dic[movie];
- $(document).ready(function () {
- $.ajax({
- url: Url1 + query + Url2,
- dataType: "jsonp",
- success: searchCallback
- });
+ $(document).ready(function() {
+ $.ajax({
+ url: Url1 + query + Url2,
+ dataType: "jsonp",
+ success: searchCallback
+ });
});
}
function addMoviesToHtml() {
$.each(simMoviesArray, function(index, movie) {
- if (movie != undefined) {
- var title = movie.title;
- if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950
- && x < 18) {
- movies[title] = 1;
- console.log(movies);
- var link = movie.links.alternate;
- var movieLink = '<a href="' + link + '">';
- var endTag = ' </a>';
- movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
- document.getElementById('movie'+x).innerHTML += movieName;
- x++;
- }
- }
- });
+ if (movie != undefined) {
+ var title = movie.title;
+ if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950 && x < 18) {
+ movies[title] = 1;
+ console.log(movies);
+ var link = movie.links.alternate;
+ var movieLink = '<a href="' + link + '">';
+ var endTag = ' </a>';
+ movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
+ document.getElementById('movie' + x).innerHTML += movieName;
+ x++;
+ }
+ }
+ });
}
function searchCallback(data) {
var i = 0;
- for(i = 0; i < 5; i++) {
- if (data.movies != undefined) {
- simMoviesArray[i] = data.movies[i];
- }
+ for (i = 0; i < 5; i++) {
+ if (data.movies != undefined) {
+ simMoviesArray[i] = data.movies[i];
+ }
}
addMoviesToHtml();
}
function toggle() {
var len = comedyMovies.length;
- var i = Math.floor((Math.random()*len)+1);
+ var i = Math.floor((Math.random() * len) + 1);
var check = 0;
while (check < 9) {
- simMovies(comedyMovies[i]);
- i=Math.floor((Math.random()*len)+1);
- check++;
+ simMovies(comedyMovies[i]);
+ i = Math.floor((Math.random() * len) + 1);
+ check++;
}
-}
+}
-window.onload = toggle();
+window.onload = toggle();
View
116 javascript/script_horror.js
@@ -3,37 +3,36 @@ var x = 0;
var bestMovie;
var simMoviesArray = new Array(4);
var movies = {};
-var horrorMovies =
- [
- "Psycho",
- "Night of the Living Dead",
- "The Exorcist",
- "The Shining",
- "Scream",
- "The Blair Witch Project",
- "Nightmare on Elm Street",
- "Poltergeist",
- "The Ring",
- "Texas Chainsaw Massacre",
- "Rosemarys Baby",
- "Silence of the Lambs",
- "The Omen"
+var horrorMovies = [
+ "Psycho",
+ "Night of the Living Dead",
+ "The Exorcist",
+ "The Shining",
+ "Scream",
+ "The Blair Witch Project",
+ "Nightmare on Elm Street",
+ "Poltergeist",
+ "The Ring",
+ "Texas Chainsaw Massacre",
+ "Rosemarys Baby",
+ "Silence of the Lambs",
+ "The Omen"
]
- var dic = {
- 'Psycho': '12879',
- 'Night of the Living Dead': '50375489',
- 'The Exorcist': '15615',
- 'The Shining': '14884',
- 'Scream': '17135',
- 'The Blair Witch Project': '13062',
- 'Nightmare on Elm Street': '13117',
- 'Poltergeist': '10145',
- 'The Ring': '10437',
- 'Texas Chainsaw Massacre': '14466',
- 'Rosemarys Baby': '13060',
- 'Silence of the Lambs': '16286',
- 'The Omen': '13666'
+var dic = {
+ 'Psycho': '12879',
+ 'Night of the Living Dead': '50375489',
+ 'The Exorcist': '15615',
+ 'The Shining': '14884',
+ 'Scream': '17135',
+ 'The Blair Witch Project': '13062',
+ 'Nightmare on Elm Street': '13117',
+ 'Poltergeist': '10145',
+ 'The Ring': '10437',
+ 'Texas Chainsaw Massacre': '14466',
+ 'Rosemarys Baby': '13060',
+ 'Silence of the Lambs': '16286',
+ 'The Omen': '13666'
};
@@ -46,53 +45,52 @@ function simMovies(movie) {
var Url1 = "http://api.rottentomatoes.com/api/public/v1.0/movies/";
var Url2 = "/similar.json?apikey=" + apikey + "&limit=5";
var query = dic[movie];
- $(document).ready(function () {
- $.ajax({
- url: Url1 + query + Url2,
- dataType: "jsonp",
- success: searchCallback
- });
+ $(document).ready(function() {
+ $.ajax({
+ url: Url1 + query + Url2,
+ dataType: "jsonp",
+ success: searchCallback
+ });
});
}
function addMoviesToHtml() {
$.each(simMoviesArray, function(index, movie) {
- if (movie != undefined) {
- var title = movie.title;
- if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950
- && x < 18) {
- movies[title] = 1;
- var link = movie.links.alternate;
- var movieLink = '<a href="' + link + '">';
- var endTag = ' </a>';
- movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
- document.getElementById('movie'+x).innerHTML += movieName;
- x++;
- }
- }
- });
+ if (movie != undefined) {
+ var title = movie.title;
+ if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950 && x < 18) {
+ movies[title] = 1;
+ var link = movie.links.alternate;
+ var movieLink = '<a href="' + link + '">';
+ var endTag = ' </a>';
+ movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
+ document.getElementById('movie' + x).innerHTML += movieName;
+ x++;
+ }
+ }
+ });
}
function searchCallback(data) {
var i = 0;
- for(i = 0; i < 5; i++) {
- if (data.movies != undefined) {
- simMoviesArray[i] = data.movies[i];
- }
+ for (i = 0; i < 5; i++) {
+ if (data.movies != undefined) {
+ simMoviesArray[i] = data.movies[i];
+ }
}
addMoviesToHtml();
}
function toggle() {
var len = horrorMovies.length;
- var i = Math.floor((Math.random()*len)+1);
+ var i = Math.floor((Math.random() * len) + 1);
var check = 0;
while (check < 9) {
- simMovies(horrorMovies[i]);
- i=Math.floor((Math.random()*len)+1);
- check++;
+ simMovies(horrorMovies[i]);
+ i = Math.floor((Math.random() * len) + 1);
+ check++;
}
-}
+}
-window.onload = toggle();
+window.onload = toggle();
View
204 javascript/script_romance.js
@@ -3,81 +3,80 @@ var x = 0;
var bestMovie;
var simMoviesArray = new Array(4);
var movies = {};
-var romanceMovies =
- [
- "Life is Beautiful",
- "Gone with the Wind",
- "Jerry Maguire",
- "Eternal Sunshine Of The Spotless Mind",
- "The Notebook",
- "Pride and Prejudice",
- "Hitch",
- "Love Actually",
- "Titanic",
- "When Harry Met Sally",
- "Youve Got Mail",
- "Pretty Woman",
- "Sleepless in Seattle",
- "Dirty Dancing",
- "The Illusionist",
- "Moulin Rouge",
- "Enchanted",
- "My Fair Lady",
- "The English Patient",
- "The Artist",
- "The Princess Bride",
- "Groundhog Day",
- "Notting Hill",
- "Theres Something About Mary",
- "Knocked Up",
- "While You Were Sleeping",
- "Stardust",
- "Forgetting Sarah Marshall",
- "Garden State",
- "500 Days of Summer",
- "10 Things I Hate About You",
- "Amelie",
- "Crazy, Stupid, Love",
- "Pitch Perfect",
- "Emma"
+var romanceMovies = [
+ "Life is Beautiful",
+ "Gone with the Wind",
+ "Jerry Maguire",
+ "Eternal Sunshine Of The Spotless Mind",
+ "The Notebook",
+ "Pride and Prejudice",
+ "Hitch",
+ "Love Actually",
+ "Titanic",
+ "When Harry Met Sally",
+ "Youve Got Mail",
+ "Pretty Woman",
+ "Sleepless in Seattle",
+ "Dirty Dancing",
+ "The Illusionist",
+ "Moulin Rouge",
+ "Enchanted",
+ "My Fair Lady",
+ "The English Patient",
+ "The Artist",
+ "The Princess Bride",
+ "Groundhog Day",
+ "Notting Hill",
+ "Theres Something About Mary",
+ "Knocked Up",
+ "While You Were Sleeping",
+ "Stardust",
+ "Forgetting Sarah Marshall",
+ "Garden State",
+ "500 Days of Summer",
+ "10 Things I Hate About You",
+ "Amelie",
+ "Crazy, Stupid, Love",
+ "Pitch Perfect",
+ "Emma"
]
- var dic = {
- 'Life is Beautiful': '10097',
- 'Gone with the Wind':'9818',
- 'Jerry Maguire': '13109',
- 'Eternal Sunshine Of The Spotless Mind': '12860',
- 'The Notebook': '10015',
- 'Pride and Prejudice': '9185',
- 'Hitch': '11616',
- 'Love Actually': '12852',
- 'Titanic': '22494',
- 'When Harry Met Sally': '16317',
- 'Youve Got Mail': '10050',
- 'Pretty Woman': '13006',
- 'Sleepless in Seattle': '12631',
- 'Dirty Dancing': '12228',
- 'The Illusionist': '268342306',
- 'Moulin Rouge': '12846',
- 'Enchanted': '770670631',
- 'My Fair Lady': '9386',
- 'The English Patient': '14840',
- 'The Artist': '771241143',
- 'The Princess Bride': '12686',
- 'Groundhog Day': '11770',
- 'Notting Hill': '10110',
- 'Theres Something About Mary': '17462',
- 'Knocked Up': '460328477',
- 'While You Were Sleeping': '10076',
- 'Stardust': '392799904',
- 'Forgetting Sarah Marshall': '770675807',
- 'Garden State': '12850',
- '500 Days of Summer': '770801801',
- '10 Things I Hate About You': '10180',
- 'Amelie': '12875',
- 'Crazy, Stupid, Love': '771203531',
- 'Pitch Perfect': '771308226',
- 'Emma': '10090'
+var dic = {
+ 'Life is Beautiful': '10097',
+ 'Gone with the Wind': '9818',
+ 'Jerry Maguire': '13109',
+ 'Eternal Sunshine Of The Spotless Mind': '12860',
+ 'The Notebook': '10015',
+ 'Pride and Prejudice': '9185',
+ 'Hitch': '11616',
+ 'Love Actually': '12852',
+ 'Titanic': '22494',
+ 'When Harry Met Sally': '16317',
+ 'Youve Got Mail': '10050',
+ 'Pretty Woman': '13006',
+ 'Sleepless in Seattle': '12631',
+ 'Dirty Dancing': '12228',
+ 'The Illusionist': '268342306',
+ 'Moulin Rouge': '12846',
+ 'Enchanted': '770670631',
+ 'My Fair Lady': '9386',
+ 'The English Patient': '14840',
+ 'The Artist': '771241143',
+ 'The Princess Bride': '12686',
+ 'Groundhog Day': '11770',
+ 'Notting Hill': '10110',
+ 'Theres Something About Mary': '17462',
+ 'Knocked Up': '460328477',
+ 'While You Were Sleeping': '10076',
+ 'Stardust': '392799904',
+ 'Forgetting Sarah Marshall': '770675807',
+ 'Garden State': '12850',
+ '500 Days of Summer': '770801801',
+ '10 Things I Hate About You': '10180',
+ 'Amelie': '12875',
+ 'Crazy, Stupid, Love': '771203531',
+ 'Pitch Perfect': '771308226',
+ 'Emma': '10090'
};
@@ -91,53 +90,52 @@ function simMovies(movie) {
var Url1 = "http://api.rottentomatoes.com/api/public/v1.0/movies/";
var Url2 = "/similar.json?apikey=" + apikey + "&limit=5";
var query = dic[movie];
- $(document).ready(function () {
- $.ajax({
- url: Url1 + query + Url2,
- dataType: "jsonp",
- success: searchCallback
- });
+ $(document).ready(function() {
+ $.ajax({
+ url: Url1 + query + Url2,
+ dataType: "jsonp",
+ success: searchCallback
+ });
});
}
function addMoviesToHtml() {
$.each(simMoviesArray, function(index, movie) {
- if (movie != undefined) {
- var title = movie.title;
- if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950
- && x < 18) {
- movies[title] = 1;
- var link = movie.links.alternate;
- var movieLink = '<a href="' + link + '">';
- var endTag = ' </a>';
- movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
- document.getElementById('movie'+x).innerHTML += movieName;
- x++;
- }
- }
- });
+ if (movie != undefined) {
+ var title = movie.title;
+ if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950 && x < 18) {
+ movies[title] = 1;
+ var link = movie.links.alternate;
+ var movieLink = '<a href="' + link + '">';
+ var endTag = ' </a>';
+ movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
+ document.getElementById('movie' + x).innerHTML += movieName;
+ x++;
+ }
+ }
+ });
}
function searchCallback(data) {
var i = 0;
- for(i = 0; i < 5; i++) {
- if (data.movies != undefined) {
- simMoviesArray[i] = data.movies[i];
- }
+ for (i = 0; i < 5; i++) {
+ if (data.movies != undefined) {
+ simMoviesArray[i] = data.movies[i];
+ }
}
addMoviesToHtml();
}
function toggle() {
var len = romanceMovies.length;
- var i = Math.floor((Math.random()*len)+1);
+ var i = Math.floor((Math.random() * len) + 1);
var check = 0;
while (check < 9) {
- simMovies(romanceMovies[i]);
- i=Math.floor((Math.random()*len)+1);
- check++;
+ simMovies(romanceMovies[i]);
+ i = Math.floor((Math.random() * len) + 1);
+ check++;
}
-}
+}
-window.onload = toggle();
+window.onload = toggle();
View
124 javascript/script_scifi.js
@@ -3,39 +3,38 @@ var x = 0;
var bestMovie;
var simMoviesArray = new Array(4);
var movies = {};
-var scifiMovies =
- [
- "Star Wars",
- "Hitchhikers Guide to the Galaxy",
- "Jurassic Park",
- "The Matrix",
- "The Terminator",
- "Blade Runner",
- "Close Encounters of the Third Kind",
- "Inception",
- "Avatar",
- "I Am Legend",
- "District 9",
- "War of the Worlds",
- "28 Weeks Later",
- "Back to the Future"
+var scifiMovies = [
+ "Star Wars",
+ "Hitchhikers Guide to the Galaxy",
+ "Jurassic Park",
+ "The Matrix",
+ "The Terminator",
+ "Blade Runner",
+ "Close Encounters of the Third Kind",
+ "Inception",
+ "Avatar",
+ "I Am Legend",
+ "District 9",
+ "War of the Worlds",
+ "28 Weeks Later",
+ "Back to the Future"
]
- var dic = {
- 'Star Wars': '9',
- 'Hitchhikers Guide to the Galaxy': '17',
- 'Jurassic Park': '10983',
- 'The Matrix': '12897',
- 'The Terminator': '16340',
- 'Blade Runner': '12886',
- 'Close Encounters of the Third Kind': '10443',
- 'Inception': '770805418',
- 'Avatar': '665118753',
- 'I Am Legend': '770669778',
- 'District 9': '770805203',
- 'Back to the Future':'23532',
- 'War of the Worlds': '1789',
- '28 Weeks Later': '660304807'
+var dic = {
+ 'Star Wars': '9',
+ 'Hitchhikers Guide to the Galaxy': '17',
+ 'Jurassic Park': '10983',
+ 'The Matrix': '12897',
+ 'The Terminator': '16340',
+ 'Blade Runner': '12886',
+ 'Close Encounters of the Third Kind': '10443',
+ 'Inception': '770805418',
+ 'Avatar': '665118753',
+ 'I Am Legend': '770669778',
+ 'District 9': '770805203',
+ 'Back to the Future': '23532',
+ 'War of the Worlds': '1789',
+ '28 Weeks Later': '660304807'
};
@@ -48,56 +47,55 @@ function simMovies(movie) {
var Url1 = "http://api.rottentomatoes.com/api/public/v1.0/movies/";
var Url2 = "/similar.json?apikey=" + apikey + "&limit=5";
var query = dic[movie];
- $(document).ready(function () {
- $.ajax({
- url: Url1 + query + Url2,
- dataType: "jsonp",
- success: searchCallback
- });
+ $(document).ready(function() {
+ $.ajax({
+ url: Url1 + query + Url2,
+ dataType: "jsonp",
+ success: searchCallback
+ });
});
}
function addMoviesToHtml() {
$.each(simMoviesArray, function(index, movie) {
- if (movie != undefined) {
+ if (movie != undefined) {
- var title = movie.title;
- if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950
- && x < 18) {
- movies[title] = 1;
- console.log(movies);
- var link = movie.links.alternate;
- var movieLink = '<a href="' + link + '">';
- var endTag = ' </a>';
- movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
- document.getElementById('movie'+x).innerHTML += movieName;
- x++;
- }
- }
- });
+ var title = movie.title;
+ if ((movie.ratings.critics_rating == "Certified Fresh" || movie.ratings.critics_rating == "Fresh") && (movies[title] == null) && movie.year > 1950 && x < 18) {
+ movies[title] = 1;
+ console.log(movies);
+ var link = movie.links.alternate;
+ var movieLink = '<a href="' + link + '">';
+ var endTag = ' </a>';
+ movieName = ('<a href="' + link + '"> ' + '<img src="' + movie.posters.original + '" />' + ' </a>');
+ document.getElementById('movie' + x).innerHTML += movieName;
+ x++;
+ }
+ }
+ });
}
function searchCallback(data) {
var i = 0;
- for(i = 0; i < 5; i++) {
- if (data.movies != undefined) {
- simMoviesArray[i] = data.movies[i];
- }
+ for (i = 0; i < 5; i++) {
+ if (data.movies != undefined) {
+ simMoviesArray[i] = data.movies[i];
+ }
}
addMoviesToHtml();
}
function toggle() {
var len = scifiMovies.length;
- var i = Math.floor((Math.random()*len)+1);
+ var i = Math.floor((Math.random() * len) + 1);
var check = 0;
while (check < 9) {
- console.log(scifiMovies[i]);
- simMovies(scifiMovies[i]);
- i=Math.floor((Math.random()*len)+1);
- check++;
+ console.log(scifiMovies[i]);
+ simMovies(scifiMovies[i]);
+ i = Math.floor((Math.random() * len) + 1);
+ check++;
}
-}
+}
-window.onload = toggle();
+window.onload = toggle();

0 comments on commit eb665ef

Please sign in to comment.