Skip to content

Commit 40ed99d

Browse files
committed
Merge branch 'master' of github.com:talkpython/100daysofweb-with-python-course
2 parents 0eeff03 + ee7bb45 commit 40ed99d

File tree

5 files changed

+111
-205
lines changed

5 files changed

+111
-205
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,5 @@ vcs.xml
154154
days/093-096-vuejs/movie_exploder/.idea/encodings.xml
155155
days/093-096-vuejs/movie_exploder/.idea/movie_exploder.iml
156156
days/093-096-vuejs/movie_exploder/node_modules
157+
days/093-096-vuejs/movie_exploder/.idea/jsLibraryMappings.xml
158+
days/093-096-vuejs/movie_exploder/.idea/dictionaries/mkennedy.xml

days/093-096-vuejs/movie_exploder/js/dropdown.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
let el = {};
44

55
$('.placeholder').on('click', function (ev) {
6-
$('.placeholder').css('opacity', '0');
7-
$('.list__ul').toggle();
6+
$('.placeholder').css('opacity', '0');
7+
$('.list__ul').toggle();
88
});
99

10-
$('.list__ul a').on('click', function (ev) {
11-
ev.preventDefault();
12-
var index = $(this).parent().index();
10+
$('.list__ul a').on('click', function (ev) {
11+
ev.preventDefault();
12+
var index = $(this).parent().index();
1313

14-
$('.placeholder').text( $(this).text() ).css('opacity', '1');
14+
$('.placeholder').text($(this).text()).css('opacity', '1');
1515

16-
console.log($('.list__ul').find('li').eq(index).html());
16+
console.log($('.list__ul').find('li').eq(index).html());
1717

18-
$('.list__ul').find('li').eq(index).prependTo('.list__ul');
19-
$('.list__ul').toggle();
18+
$('.list__ul').find('li').eq(index).prependTo('.list__ul');
19+
$('.list__ul').toggle();
2020

21-
});
21+
});
2222

2323

2424
$('select').on('change', function (e) {
2525

26-
// Set text on placeholder hidden element
27-
$('.placeholder').text(this.value);
26+
// Set text on placeholder hidden element
27+
$('.placeholder').text(this.value);
2828

29-
// Animate select width as placeholder
30-
$(this).animate({width: $('.placeholder').width() + 'px' });
29+
// Animate select width as placeholder
30+
$(this).animate({width: $('.placeholder').width() + 'px'});
3131

3232
});
Lines changed: 1 addition & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
movies_temp = {
22
"keyword": "top_10",
33
"hits": [
4-
{
5-
"imdb_code": "tt0691996",
6-
"title": "Towering Inferno",
7-
"director": "John Blanchard",
8-
"keywords": [],
9-
"duration": 65,
10-
"genres": [
11-
"comedy"
12-
],
13-
"rating": "",
14-
"year": 0,
15-
"imdb_score": 9.5
16-
},
174
{
185
"imdb_code": "tt0111161",
196
"title": "The Shawshank Redemption",
@@ -73,154 +60,16 @@ movies_temp = {
7360
"year": 0,
7461
"imdb_score": 9.1
7562
},
76-
{
77-
"imdb_code": "tt3082898",
78-
"title": "Kickboxer: Vengeance",
79-
"director": "John Stockwell",
80-
"keywords": [],
81-
"duration": 90,
82-
"genres": [
83-
"action"
84-
],
85-
"rating": "",
86-
"year": 2016,
87-
"imdb_score": 9.1
88-
},
89-
{
90-
"imdb_code": "tt0468569",
91-
"title": "The Dark Knight",
92-
"director": "Christopher Nolan",
93-
"keywords": [
94-
"psychopath",
95-
"urban setting",
96-
"based on comic book",
97-
"star died before release",
98-
"dc comics"
99-
],
100-
"duration": 152,
101-
"genres": [
102-
"drama",
103-
"thriller",
104-
"action",
105-
"crime"
106-
],
107-
"rating": "PG-13",
108-
"year": 2008,
109-
"imdb_score": 9.0
110-
},
111-
{
112-
"imdb_code": "tt0071562",
113-
"title": "The Godfather: Part II",
114-
"director": "Francis Ford Coppola",
115-
"keywords": [
116-
"corrupt politician",
117-
"revenge",
118-
"lake tahoe nevada",
119-
"1950s",
120-
"melancholy"
121-
],
122-
"duration": 220,
123-
"genres": [
124-
"drama",
125-
"crime"
126-
],
127-
"rating": "R",
128-
"year": 1974,
129-
"imdb_score": 9.0
130-
},
131-
{
132-
"imdb_code": "tt2802850",
133-
"title": "Fargo",
134-
"director": "",
135-
"keywords": [
136-
"anthology",
137-
"minnesota",
138-
"insurance salesman",
139-
"police officer",
140-
"death"
141-
],
142-
"duration": 53,
143-
"genres": [
144-
"drama",
145-
"thriller",
146-
"crime"
147-
],
148-
"rating": "TV-MA",
149-
"year": 0,
150-
"imdb_score": 9.0
151-
},
152-
{
153-
"imdb_code": "tt0167260",
154-
"title": "The Lord of the Rings: The Return of the King",
155-
"director": "Peter Jackson",
156-
"keywords": [
157-
"epic",
158-
"battle",
159-
"king",
160-
"orc",
161-
"ring"
162-
],
163-
"duration": 192,
164-
"genres": [
165-
"drama",
166-
"action",
167-
"adventure",
168-
"fantasy"
169-
],
170-
"rating": "PG-13",
171-
"year": 2003,
172-
"imdb_score": 8.9
173-
},
174-
{
175-
"imdb_code": "tt0108052",
176-
"title": "Schindler's List",
177-
"director": "Steven Spielberg",
178-
"keywords": [
179-
"nazi",
180-
"german soldier",
181-
"jew",
182-
"german",
183-
"jewish"
184-
],
185-
"duration": 185,
186-
"genres": [
187-
"drama",
188-
"history",
189-
"biography"
190-
],
191-
"rating": "R",
192-
"year": 1993,
193-
"imdb_score": 8.9
194-
}
19563
],
19664
"truncated_results": true
19765
}
19866

19967
genres_temp = [
68+
"Top movies by genre",
20069
"action",
20170
"adventure",
20271
"animation",
20372
"biography",
20473
"comedy",
20574
"crime",
206-
"documentary",
207-
"drama",
208-
"family",
209-
"fantasy",
210-
"film-noir",
211-
"game-show",
212-
"history",
213-
"horror",
214-
"music",
215-
"musical",
216-
"mystery",
217-
"news",
218-
"reality-tv",
219-
"romance",
220-
"sci-fi",
221-
"short",
222-
"sport",
223-
"thriller",
224-
"war",
225-
"western"
22675
]
Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,65 @@
1-
// noinspection ES6ModulesDependencies
1+
const base_url = "http://movie_service.talkpython.fm/api/"
22

3+
// noinspection ES6ModulesDependencies
34
app = new Vue({
45
el: '#app',
56
data: {
67
search_text: null,
7-
movies: movies_temp.hits,
8-
genres: genres_temp,
9-
selected_genre: null
8+
movies: [],
9+
genres: [],
10+
selected_genre: null,
11+
no_genre: "Top movies by genre",
1012
},
1113
methods: {
12-
search: function() {
14+
search: function () {
1315
let text = this.search_text
14-
console.log("Would have searched for " + text)
16+
// noinspection JSUnusedGlobalSymbols
17+
this.selected_genre = this.no_genre
18+
this.load_movies(base_url + "search/" + text)
19+
},
20+
top_10: function () {
21+
// noinspection JSUnusedGlobalSymbols
22+
this.selected_genre = this.no_genre
23+
this.search_text = null
24+
this.load_movies(base_url + "movie/top")
25+
},
26+
load_genre: function (genre) {
27+
let url = base_url + "movie/genre/" + genre
28+
this.search_text = null
29+
// noinspection JSUnusedGlobalSymbols
30+
this.selected_genre = genre
31+
this.load_movies(url)
1532
},
16-
top_10: function() {
17-
console.log("Would have loaded top 10")
33+
load_movies: function (url) {
34+
let that = this
35+
// noinspection ES6ModulesDependencies, JSUnresolvedVariable
36+
axios.get(url)
37+
.then(function (response) { // handle success
38+
that.movies = response.data.hits
39+
})
40+
.catch(function (error) { // handle error
41+
console.log("ERROR! " + error)
42+
})
43+
},
44+
load_all_genres: function () {
45+
let that = this
46+
// noinspection ES6ModulesDependencies, JSUnresolvedVariable
47+
axios.get(base_url + 'movie/genre/all')
48+
.then(function (response) { // handle success
49+
let genres = response.data
50+
genres.unshift(that.no_genre)
51+
that.genres = genres
52+
that.selected_genre = that.no_genre
53+
})
54+
.catch(function (error) { // handle error
55+
console.log("ERROR! " + error)
56+
})
57+
},
58+
init: function () {
59+
this.load_all_genres()
60+
this.top_10()
1861
}
1962
}
2063
})
64+
65+
app.init()

0 commit comments

Comments
 (0)