Skip to content

Commit 4de8706

Browse files
committed
refactor 6: use jshint and fix violations
1 parent 0dbec4e commit 4de8706

8 files changed

+62
-26
lines changed

app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var map;
1+
'use strict';
22

33
function initialize() {
44
var mapDiv = document.getElementById('map-canvas');

app/home-control.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
'use strict';
2+
13
function HomeControl(controlDiv, map) {
24
var dashBoard = document.createElement('div');
35
dashBoard.innerHTML = templates.home();
46
dashBoard.id = 'dashboard';
57
dashBoard.className = 'dashboard';
68
controlDiv.appendChild(dashBoard);
7-
};
9+
}

app/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<body>
1919
<div id="map-canvas"></div>
2020
<script type="text/javascript">
21+
var map;
2122
google.maps.event.addDomListener(window, 'load', initialize);
2223
</script>
2324
</body>

app/location-control.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
function showLocation(detail, location) {
24
return function() {
35
map.zoomView(location.geo.lat, location.geo.lng);
@@ -22,10 +24,10 @@ function showLocation(detail, location) {
2224

2325
if (this.value === 'Satelite View') {
2426
map.sateliteView(location.geo.lat, location.geo.lng);
25-
this.value = 'Back to Roadmap'
27+
this.value = 'Back to Roadmap';
2628
} else {
2729
map.roadmapView(location.geo.lat, location.geo.lng);
28-
this.value = 'Satelite View'
30+
this.value = 'Satelite View';
2931
}
3032

3133
});
@@ -48,14 +50,14 @@ function showLocation(detail, location) {
4850

4951
backToFilm.addEventListener('click', function() {
5052
map.reset();
51-
var location_detail = document.getElementById('location_detail');
52-
if (location_detail) {
53-
location_detail.style.display = 'none';
53+
var locationDetail = document.getElementById('location_detail');
54+
if (locationDetail) {
55+
locationDetail.style.display = 'none';
5456
}
5557

56-
var film_detail = document.getElementById('film_detail');
57-
if (film_detail) {
58-
film_detail.style.display = '';
58+
var filmDetail = document.getElementById('film_detail');
59+
if (filmDetail) {
60+
filmDetail.style.display = '';
5961
}
6062
});
6163

app/movie-control.js

+20-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
function plotLocations(item) {
24
var xhr = new XMLHttpRequest();
35
xhr.onload = function() {
@@ -7,10 +9,13 @@ function plotLocations(item) {
79
response.locations[i].geo.lat,
810
response.locations[i].geo.lng,
911
showLocation(response, response.locations[i]));
10-
};
11-
}
12-
xhr.open("GET", "/movies/locations?title=" + encodeURIComponent(item.title) + '&director=' + encodeURIComponent(item.director));
13-
xhr.responseType = "json";
12+
}
13+
};
14+
xhr.open('GET', '/movies/locations?title=' +
15+
encodeURIComponent(item.title) +
16+
'&director=' +
17+
encodeURIComponent(item.director));
18+
xhr.responseType = 'json';
1419
xhr.send();
1520
}
1621

@@ -24,11 +29,12 @@ function displayLoadingPanel(response) {
2429
if (dashboard) {
2530
dashboard.style.display = 'none';
2631
}
32+
33+
var controlText;
2734

2835
if (!document.getElementById('film_detail')) {
2936

30-
// Set CSS for the control interior.
31-
var controlText = document.createElement('div');
37+
controlText = document.createElement('div');
3238
controlText.id = 'film_detail';
3339
controlText.className = 'film_detail';
3440
controlText.innerHTML = templates.loading(response);
@@ -37,8 +43,8 @@ function displayLoadingPanel(response) {
3743

3844
} else {
3945

40-
var controlText = document.getElementById('film_detail');
41-
controlText.innerHTML = templates.loading(response);;
46+
controlText = document.getElementById('film_detail');
47+
controlText.innerHTML = templates.loading(response);
4248
controlText.style.display = '';
4349

4450
}
@@ -50,9 +56,12 @@ function getMoveDetail(title, director) {
5056
var detail = this.response;
5157

5258
document.getElementById('film_detail').innerHTML = templates.movie(detail);
53-
}
54-
xhr.open("GET", "/movies/content?title=" + encodeURIComponent(title) + '&director=' + encodeURIComponent(director));
55-
xhr.responseType = "json";
59+
};
60+
xhr.open('GET', '/movies/content?title=' +
61+
encodeURIComponent(title) +
62+
'&director=' +
63+
encodeURIComponent(director));
64+
xhr.responseType = 'json';
5665
xhr.send();
5766
}
5867

app/search-control.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
function SearchControl(controlDiv) {
24
var movieClicked = function(item) {
35
map.clearMarkers();

app/style.css

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ html, body, #map-canvas {
2828
z-index: 1;
2929
}
3030

31+
.movie_detail {
32+
overflow: scroll;
33+
height: 135px;
34+
margin-top: 5px;
35+
}
36+
37+
.movie_detail img {
38+
padding-left: 5px;
39+
}
40+
3141
input[type=button] {
3242
background: #999;
3343
background-image: -webkit-linear-gradient(top, #999, #333);

app/templates.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var templates = {};
24

35
templates.mapCanvas = function mapCanvasTemplate() {
@@ -6,8 +8,15 @@ templates.mapCanvas = function mapCanvasTemplate() {
68

79
templates.home = function homeTemplate() {
810
var buf = [];
9-
buf.push('<h2>SF Movies</h2><div>See film locations for all movies filmed in San Fransisco. <strong>Click on a marker to see more information about a location.</strong>.</div>');
10-
buf.push('<p>This is a sample project from <a href="http://www.bradoncode.com">Bradley Braithwaite</a>.</p>');
11+
buf.push('<h2>SF Movies</h2>');
12+
buf.push('<div>See film locations for all movies filmed in San Fransisco.');
13+
buf.push('<strong>');
14+
buf.push('Click on a marker to see more information about a location.');
15+
buf.push('</strong>');
16+
buf.push('</div>');
17+
buf.push('<p>This is a sample project from' );
18+
buf.push('<a href="http://www.bradoncode.com">Bradley Braithwaite</a>');
19+
buf.push('</p>');
1120
return buf.join('');
1221
};
1322

@@ -23,8 +32,8 @@ templates.movie = function movieTemplate(detail) {
2332
var buf = [];
2433
buf.push('<img src="');
2534
buf.push(detail.poster);
26-
buf.push('" alt="poster" align="right" width="80" height="119" style="padding-left:5px;" />');
27-
buf.push('<div id="plot" style="overflow: scroll; height:135px;margin-top:5px;">');
35+
buf.push('" alt="poster" align="right" width="80" height="119" />');
36+
buf.push('<div class="movie_detail">');
2837
buf.push('<h2>');
2938
buf.push(detail.title);
3039
buf.push('</h2>');
@@ -52,7 +61,8 @@ templates.location = function locationTemplate(location) {
5261
var buf = [];
5362
buf.push('<h2>');
5463
buf.push(location.location);
55-
buf.push('</h2><img src="https://maps.googleapis.com/maps/api/streetview?size=120x120&location=');
64+
buf.push('</h2>');
65+
buf.push('<img src="https://maps.googleapis.com/maps/api/streetview?size=120x120&location='); // jshint ignore:line
5666
buf.push(location.geo.lat);
5767
buf.push(',');
5868
buf.push(location.geo.lng);

0 commit comments

Comments
 (0)