This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*globals define*/ | ||
define([ | ||
'./controllers/Controller', | ||
'./controllers/MovieController' | ||
], function( | ||
Controller, | ||
MovieController | ||
) { | ||
'use strict'; | ||
return { | ||
Controller: Controller, | ||
MovieController: MovieController | ||
}; | ||
}); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*globals define*/ | ||
|
||
define(['controllers/Controller', | ||
'text!controllers/html/movie.html', | ||
'lodash'], function(Controller, | ||
movieHtml, | ||
_) { | ||
'use strict'; | ||
|
||
var movieTemplate = _.template(movieHtml); | ||
var MovieController = function() { | ||
Controller.apply(this, arguments); | ||
}; | ||
|
||
_.extend(MovieController.prototype, Controller.prototype); | ||
|
||
// Override methods as needed | ||
MovieController.prototype.renderOption = function(option) { | ||
console.log('Movie option is', option); | ||
// Add the rating | ||
|
||
// Show the basic movie info | ||
this.container.html(movieTemplate(option)); | ||
this._updateView(option); // Using OMDB API | ||
}; | ||
|
||
/** | ||
* Get the movie info from OMDB | ||
* | ||
* @param {String} movie | ||
* @return {undefined} | ||
*/ | ||
MovieController.prototype._getMovieInfo = function(movie, cb) { | ||
$.get('http://www.omdbapi.com/?t='+encodeURI(movie)+ | ||
'&y=&plot=short&r=json', cb); | ||
}; | ||
|
||
MovieController.prototype._updateView = function(option) { | ||
// Update the html with the new content | ||
this._getMovieInfo(option.title, function(movie) { | ||
if (movie.Poster && movie.Poster.indexOf('http') === 0) { | ||
document.getElementById('poster').innerHTML = '<img src='+ | ||
movie.Poster+' class="img-responsive"/>'; | ||
} | ||
|
||
if (movie.imdbRating && parseInt(movie.imdbRating)) { | ||
document.getElementById('rating').innerHTML = this._createRatingText(movie.imdbRating/2); | ||
} | ||
}.bind(this)); | ||
}; | ||
|
||
return MovieController; | ||
}); |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<div class="jumbotron result"> | ||
<div class="row"> | ||
<div class="result__primary col-xs-8"> | ||
<div class="result__name"><%= title %></div> | ||
<div class="result__type_and_price"> | ||
<span class="result__type"><%= theater %></span> | ||
<span class="result__price"></span> | ||
</div> | ||
<div class="result__distance"></div> | ||
<div class="result__vicinity"><%= vicinity %></div> | ||
</div> | ||
<div class="col-xs-4"> | ||
<div id="poster" class="result__photo"></div> | ||
<div class="result__ratings" id="rating"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-xs-4"> | ||
</div> | ||
<div class="col-xs-4"> | ||
<img src="button_four.png" class="result__retry"></img> | ||
</div> | ||
<div class="col-xs-4"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains 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