Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
var app = angular.module('movieApp', []);
app.controller('MovieCtrl', ['$scope', function($scope) {
$scope.moviesToWatch = [
{
title: "The Revenant",
year: 2016,
picture: "https://fanart.tv/fanart/movies/281957/moviebackground/the-revenant-56696620a2821.jpg"
},
{
title: "Ant Man",
year: 2015,
picture: "https://events.ucsb.edu/wp-content/uploads/2015/09/Marvel-Ant-Man-Banner-Poster.jpg"
},
{
title: "Avengers: Age of Utron",
year: 2015,
picture: "http://oi57.tinypic.com/28bfu3a.jpg"
},
{
title: "Agent 47",
year: 2015,
picture: "http://images8.alphacoders.com/614/614163.jpg"
},
{
title: "The Martian",
year: 2015,
picture: "http://s3.foxfilm.com/foxmovies/production/films/104/images/gallery/martian-gallery3-gallery-image.jpg"
},
{
title: "Creed",
year: 2015,
picture: "http://totalrocky.com/films/creed-2015/ucwzuno3i1xbdo3dkucv.jpg"
}
];
$scope.addMovie = function() {
if (!$scope.newMovie.picture) {
$scope.newMovie.picture = "http://gujaratprachar.com/img/placeholder_noImage_bw.png";
}
$scope.moviesToWatch.push($scope.newMovie);
$scope.newMovie = {};
$scope.newMovieForm = false;
};
$scope.movieLimitFive = true;
$scope.toggleMovieLimit = function() {
if ($scope.movieLimitFive) {
$scope.movieLimitFive = false;
} else {
$scope.movieLimitFive = true;
}
};
$scope.deleteMovie = function(movie) {
movieToBeDeleteIndex = $scope.moviesToWatch.indexOf(movie);
$scope.moviesToWatch.splice(movieToBeDeleteIndex, 1);
};
$scope.watchedMovie = function(movie) {
movie.watched = movie.watched ? false : true;
if (movie.watched) {
movie.watchedTime = (new Date()).toLocaleDateString();
}
movie.watched ? movie.style = {"text-decoration" : "line-through"} : movie.style = {"text-decoration" : "none"};
};
$scope.changeBackground = function() {
randomNum = Math.floor(Math.random() * $scope.moviesToWatch.length);
randomPicture = $scope.moviesToWatch[randomNum].picture;
$scope.background = {'background-image': 'url(' + randomPicture + ')'};
};
}]);
71 changes: 71 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en" ng-app="movieApp">
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- custom css -->
<link type="text/css" rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body ng-controller="MovieCtrl" ng-style="background">
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1 holder">
<div class="text-center header">
<h1>
<ng-pluralize count="moviesToWatch.length"
when="{'0': 'No Movies to Watch',
'1': '1 Movie to Watch',
'other': '{} Movies to Watch'}">
</ng-pluralize>
</h1>
<button class="btn btn-default" ng-click="changeBackground()">Try Me</button>
<br>
<br>
<a href="javascript:void(0)" ng-click="newMovieForm=true" ng-hide="newMovieForm">Add Movie to Watchlist</a>
</div>
<div ng-show="newMovieForm">
<form ng-submit="addMovie()">
<div class="form-group">
<label for="title">Title</label>
<input type="text" ng-model="newMovie.title" class="form-control" id="title" autofocus required>
</div>
<div class="form-group">
<label for="year">Year</label>
<input type="number" ng-model="newMovie.year" class="form-control" id="year" required>
</div>
<div class="form-group">
<label for="picture">Picture Url</label>
<input type="text" ng-model="newMovie.picture" class="form-control" id="picture">
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary form-control" value="Add">
</div>
</form>
</div>
<hr>
<div ng-repeat="movie in moviesToWatch | orderBy: ['-title'] | limitTo: movieLimitFive ? 5 : false" class="row movie">
<div class="col-md-5 pic-holder">
<a href="javascript:void(0)" ng-click="deleteMovie(movie)" class="delete"><i class="fa fa-trash"></i></a>
<a href="javascript:void(0)" ng-click="watchedMovie(movie)" class="watched"><i class="fa" ng-class="{'fa-check-circle-o': movie.watched, 'fa-circle-o': !movie.watched}"></i></a>
<img src="{{ movie.picture }}" class="img-reponsive">
</div>
<div class="col-md-7">
<h2 ng-style="movie.style">{{ movie.title }}</h2>
<h4 ng-style="movie.style">{{ movie.year }}</h4>
<h4>{{movie.watched ? "Marked as watched: " + movie.watchedTime : ""}}</h4>
</div>
</div>
<a href="#" ng-click="toggleMovieLimit()" class="pull-right">
Show {{movieLimitFive ? "All" : "Less"}}
</a>
</div>
</div>
</div>
<!-- angular -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<!-- custom js -->
<script type="text/javascript" src="app.js"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.body {
height: 100%;
width: 100%;
background-size: cover;
background-repeat: repeat-x;
background-position: right top;
background-attachment: fixed;
}
.holder {
padding-bottom: 50px;
}
.header {
padding: 10px;
background-color: rgba(255,255,255,0.9);
}
.movie, form {
background-color: rgba(255,255,255,0.9);
box-shadow: 0 0 10px 1px rgba(0,0,0,0.25);
margin-bottom: 1em;
padding: 10px;
}
img {
width: 250px;
}
.pic-holder {
position: relative;
}
.delete {
position: absolute;
top: 5px;
left: 280px;
}
.watched{
position: absolute;
top: 25px;
left: 280px;
}
.un-watched{
position: absolute;
top: 45px;
left: 280px;
}