Permalink
Browse files

refactor 6: use jshint and fix violations

  • Loading branch information...
bbraithwaite committed Apr 9, 2015
1 parent 0dbec4e commit 4de8706d244e960da54a447bdc534f6a1065d0c7
Showing with 62 additions and 26 deletions.
  1. +1 −1 app/app.js
  2. +3 −1 app/home-control.js
  3. +1 −0 app/index.html
  4. +10 −8 app/location-control.js
  5. +20 −11 app/movie-control.js
  6. +2 −0 app/search-control.js
  7. +10 −0 app/style.css
  8. +15 −5 app/templates.js
@@ -1,4 +1,4 @@
var map;
'use strict';
function initialize() {
var mapDiv = document.getElementById('map-canvas');
@@ -1,7 +1,9 @@
'use strict';
function HomeControl(controlDiv, map) {
var dashBoard = document.createElement('div');
dashBoard.innerHTML = templates.home();
dashBoard.id = 'dashboard';
dashBoard.className = 'dashboard';
controlDiv.appendChild(dashBoard);
};
}
@@ -18,6 +18,7 @@
<body>
<div id="map-canvas"></div>
<script type="text/javascript">
var map;
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
@@ -1,3 +1,5 @@
'use strict';
function showLocation(detail, location) {
return function() {
map.zoomView(location.geo.lat, location.geo.lng);
@@ -22,10 +24,10 @@ function showLocation(detail, location) {
if (this.value === 'Satelite View') {
map.sateliteView(location.geo.lat, location.geo.lng);
this.value = 'Back to Roadmap'
this.value = 'Back to Roadmap';
} else {
map.roadmapView(location.geo.lat, location.geo.lng);
this.value = 'Satelite View'
this.value = 'Satelite View';
}
});
@@ -48,14 +50,14 @@ function showLocation(detail, location) {
backToFilm.addEventListener('click', function() {
map.reset();
var location_detail = document.getElementById('location_detail');
if (location_detail) {
location_detail.style.display = 'none';
var locationDetail = document.getElementById('location_detail');
if (locationDetail) {
locationDetail.style.display = 'none';
}
var film_detail = document.getElementById('film_detail');
if (film_detail) {
film_detail.style.display = '';
var filmDetail = document.getElementById('film_detail');
if (filmDetail) {
filmDetail.style.display = '';
}
});
@@ -1,3 +1,5 @@
'use strict';
function plotLocations(item) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
@@ -7,10 +9,13 @@ function plotLocations(item) {
response.locations[i].geo.lat,
response.locations[i].geo.lng,
showLocation(response, response.locations[i]));
};
}
xhr.open("GET", "/movies/locations?title=" + encodeURIComponent(item.title) + '&director=' + encodeURIComponent(item.director));
xhr.responseType = "json";
}
};
xhr.open('GET', '/movies/locations?title=' +
encodeURIComponent(item.title) +
'&director=' +
encodeURIComponent(item.director));
xhr.responseType = 'json';
xhr.send();
}
@@ -24,11 +29,12 @@ function displayLoadingPanel(response) {
if (dashboard) {
dashboard.style.display = 'none';
}
var controlText;
if (!document.getElementById('film_detail')) {
// Set CSS for the control interior.
var controlText = document.createElement('div');
controlText = document.createElement('div');
controlText.id = 'film_detail';
controlText.className = 'film_detail';
controlText.innerHTML = templates.loading(response);
@@ -37,8 +43,8 @@ function displayLoadingPanel(response) {
} else {
var controlText = document.getElementById('film_detail');
controlText.innerHTML = templates.loading(response);;
controlText = document.getElementById('film_detail');
controlText.innerHTML = templates.loading(response);
controlText.style.display = '';
}
@@ -50,9 +56,12 @@ function getMoveDetail(title, director) {
var detail = this.response;
document.getElementById('film_detail').innerHTML = templates.movie(detail);
}
xhr.open("GET", "/movies/content?title=" + encodeURIComponent(title) + '&director=' + encodeURIComponent(director));
xhr.responseType = "json";
};
xhr.open('GET', '/movies/content?title=' +
encodeURIComponent(title) +
'&director=' +
encodeURIComponent(director));
xhr.responseType = 'json';
xhr.send();
}
@@ -1,3 +1,5 @@
'use strict';
function SearchControl(controlDiv) {
var movieClicked = function(item) {
map.clearMarkers();
@@ -28,6 +28,16 @@ html, body, #map-canvas {
z-index: 1;
}
.movie_detail {
overflow: scroll;
height: 135px;
margin-top: 5px;
}
.movie_detail img {
padding-left: 5px;
}
input[type=button] {
background: #999;
background-image: -webkit-linear-gradient(top, #999, #333);
@@ -1,3 +1,5 @@
'use strict';
var templates = {};
templates.mapCanvas = function mapCanvasTemplate() {
@@ -6,8 +8,15 @@ templates.mapCanvas = function mapCanvasTemplate() {
templates.home = function homeTemplate() {
var buf = [];
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>');
buf.push('<p>This is a sample project from <a href="http://www.bradoncode.com">Bradley Braithwaite</a>.</p>');
buf.push('<h2>SF Movies</h2>');
buf.push('<div>See film locations for all movies filmed in San Fransisco.');
buf.push('<strong>');
buf.push('Click on a marker to see more information about a location.');
buf.push('</strong>');
buf.push('</div>');
buf.push('<p>This is a sample project from' );
buf.push('<a href="http://www.bradoncode.com">Bradley Braithwaite</a>');
buf.push('</p>');
return buf.join('');
};
@@ -23,8 +32,8 @@ templates.movie = function movieTemplate(detail) {
var buf = [];
buf.push('<img src="');
buf.push(detail.poster);
buf.push('" alt="poster" align="right" width="80" height="119" style="padding-left:5px;" />');
buf.push('<div id="plot" style="overflow: scroll; height:135px;margin-top:5px;">');
buf.push('" alt="poster" align="right" width="80" height="119" />');
buf.push('<div class="movie_detail">');
buf.push('<h2>');
buf.push(detail.title);
buf.push('</h2>');
@@ -52,7 +61,8 @@ templates.location = function locationTemplate(location) {
var buf = [];
buf.push('<h2>');
buf.push(location.location);
buf.push('</h2><img src="https://maps.googleapis.com/maps/api/streetview?size=120x120&location=');
buf.push('</h2>');
buf.push('<img src="https://maps.googleapis.com/maps/api/streetview?size=120x120&location='); // jshint ignore:line
buf.push(location.geo.lat);
buf.push(',');
buf.push(location.geo.lng);

0 comments on commit 4de8706

Please sign in to comment.