Permalink
Browse files

refactor 6.2: fix jshint issues related to objects on the global scope

  • Loading branch information...
bbraithwaite committed Apr 9, 2015
1 parent 4de8706 commit 8707f31babcc168843e35b1647cb7cfbd45ab4fa
Showing with 40 additions and 39 deletions.
  1. +7 −5 app/app.js
  2. +3 −3 app/home-control.js
  3. +1 −2 app/index.html
  4. +10 −10 app/location-control.js
  5. +14 −14 app/movie-control.js
  6. +5 −5 app/search-control.js
@@ -1,20 +1,22 @@
'use strict';
function initialize() {
var map;
window.initialize = function() {
var mapDiv = document.getElementById('map-canvas');
map = new MapService(window.google, mapDiv);
map = new window.MapService(window.google, mapDiv);
var searchControlDiv = document.createElement('div');
searchControlDiv.id = 'top';
searchControlDiv.className = 'top';
new SearchControl(searchControlDiv);
new window.SearchControl(searchControlDiv);
map.addView(searchControlDiv, 'TOP_LEFT');
var homeControlDiv = document.createElement('div');
homeControlDiv.id = 'bottom_panel';
homeControlDiv.className = 'bottom_panel';
new HomeControl(homeControlDiv);
new window.HomeControl(homeControlDiv);
map.addView(homeControlDiv, 'BOTTOM_CENTER');
}
};
@@ -1,9 +1,9 @@
'use strict';
function HomeControl(controlDiv, map) {
window.HomeControl = function(controlDiv) {
var dashBoard = document.createElement('div');
dashBoard.innerHTML = templates.home();
dashBoard.innerHTML = window.templates.home();
dashBoard.id = 'dashboard';
dashBoard.className = 'dashboard';
controlDiv.appendChild(dashBoard);
}
};
@@ -18,8 +18,7 @@
<body>
<div id="map-canvas"></div>
<script type="text/javascript">
var map;
google.maps.event.addDomListener(window, 'load', initialize);
window.google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>
@@ -1,20 +1,20 @@
'use strict';
function showLocation(detail, location) {
window.showLocation = function(detail, location) {
return function() {
map.zoomView(location.geo.lat, location.geo.lng);
window.map.zoomView(location.geo.lat, location.geo.lng);
var locationDiv = document.getElementById('location_detail');
if (!locationDiv) {
locationDiv = document.createElement('div');
document.getElementById('bottom_panel').appendChild(locationDiv);
document.getElementById('bottom_panel').appendChild(locationDiv);
}
locationDiv.id = 'location_detail';
locationDiv.className = 'location_detail';
locationDiv.style.display = '';
locationDiv.innerHTML = templates.location(location);
locationDiv.innerHTML = window.templates.location(location);
var sateliteViewButton = document.createElement('input');
sateliteViewButton.type = 'button';
@@ -23,10 +23,10 @@ function showLocation(detail, location) {
sateliteViewButton.addEventListener('click', function() {
if (this.value === 'Satelite View') {
map.sateliteView(location.geo.lat, location.geo.lng);
window.map.sateliteView(location.geo.lat, location.geo.lng);
this.value = 'Back to Roadmap';
} else {
map.roadmapView(location.geo.lat, location.geo.lng);
window.map.roadmapView(location.geo.lat, location.geo.lng);
this.value = 'Satelite View';
}
@@ -39,7 +39,7 @@ function showLocation(detail, location) {
streetViewButton.value = 'Street View';
streetViewButton.addEventListener('click', function() {
map.streetView(location.geo.lat, location.geo.lng);
window.map.streetView(location.geo.lat, location.geo.lng);
});
locationDiv.appendChild(streetViewButton);
@@ -49,7 +49,7 @@ function showLocation(detail, location) {
backToFilm.value = 'Back to Film';
backToFilm.addEventListener('click', function() {
map.reset();
window.map.reset();
var locationDetail = document.getElementById('location_detail');
if (locationDetail) {
locationDetail.style.display = 'none';
@@ -59,10 +59,10 @@ function showLocation(detail, location) {
if (filmDetail) {
filmDetail.style.display = '';
}
});
});
locationDiv.appendChild(backToFilm);
document.getElementById('film_detail').style.display = 'none';
};
}
};
@@ -1,14 +1,14 @@
'use strict';
function plotLocations(item) {
var plotLocations = function(item) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var response = this.response;
for (var i = 0; i < response.locations.length; i++) {
map.plotLocation(
window.map.plotLocation(
response.locations[i].geo.lat,
response.locations[i].geo.lng,
showLocation(response, response.locations[i]));
window.showLocation(response, response.locations[i]));
}
};
xhr.open('GET', '/movies/locations?title=' +
@@ -17,9 +17,9 @@ function plotLocations(item) {
encodeURIComponent(item.director));
xhr.responseType = 'json';
xhr.send();
}
};
function displayLoadingPanel(response) {
var displayLoadingPanel = function(response) {
var locationDiv = document.getElementById('location_detail');
if (locationDiv) {
locationDiv.style.display = 'none';
@@ -37,36 +37,36 @@ function displayLoadingPanel(response) {
controlText = document.createElement('div');
controlText.id = 'film_detail';
controlText.className = 'film_detail';
controlText.innerHTML = templates.loading(response);
controlText.innerHTML = window.templates.loading(response);
document.getElementById('bottom_panel').appendChild(controlText);
} else {
controlText = document.getElementById('film_detail');
controlText.innerHTML = templates.loading(response);
controlText.innerHTML = window.templates.loading(response);
controlText.style.display = '';
}
}
};
function getMoveDetail(title, director) {
var getMoveDetail = function(title, director) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var detail = this.response;
document.getElementById('film_detail').innerHTML = templates.movie(detail);
var template = window.templates.movie(detail);
document.getElementById('film_detail').innerHTML = template;
};
xhr.open('GET', '/movies/content?title=' +
encodeURIComponent(title) +
'&director=' +
encodeURIComponent(director));
xhr.responseType = 'json';
xhr.send();
}
};
function showMovieDetail(item, map) {
window.showMovieDetail = function(item, map) {
displayLoadingPanel(item.title);
getMoveDetail(item.title, item.director);
plotLocations(item, map);
}
};
@@ -1,12 +1,12 @@
'use strict';
function SearchControl(controlDiv) {
window.SearchControl = function(controlDiv) {
var movieClicked = function(item) {
map.clearMarkers();
map.setOptions({ streetViewControl: false, zoomControl: true });
window.map.clearMarkers();
window.map.setOptions({ streetViewControl: false, zoomControl: true });
document.getElementById('films_results').innerHTML = '';
document.getElementById('q').value = item.title;
showMovieDetail(item);
window.showMovieDetail(item);
};
var searchInput = document.createElement('input');
@@ -29,4 +29,4 @@ function SearchControl(controlDiv) {
var resultsUI = document.createElement('div');
resultsUI.id = 'films_results';
controlDiv.appendChild(resultsUI);
}
};

0 comments on commit 8707f31

Please sign in to comment.