-
Notifications
You must be signed in to change notification settings - Fork 114
Show the Local Weather example broken #133
Comments
There was a recent commit on the non-beta version of FCC that made changes to the Local Weather App challenge : Add glitch API to Front-End weather project This repo testable-projects-fcc doesn't cover the Local Weather App challenge as it's not part of the beta version of FCC. |
I forked and updated the codepen. It can be found here. The only thing that needs to be updated in the freeCodeCamp pen is the javascript. It would be great if the freeCodeCamp pen could be updated @QuincyLarson. Here is the updated javascript: var app = angular.module('Weather', []);
app.factory('WeatherApi', function($http) {
var obj = {};
obj.getLoc = function() {
return $http.jsonp("https://ipinfo.io/json?callback=JSON_CALLBACK");
};
obj.getCurrent = function(loc) {
var api = "https://fcc-weather-api.glitch.me/api/current?";
loc = loc.split(",");
var lat = "lat=" + loc[0];
var lon = "&lon=" + loc[1];
var cb = "&callback=JSON_CALLBACK";
return $http.jsonp(api + lat + lon + cb);
};
return obj
});
app.controller('MainCtrl', function($scope, WeatherApi) {
$scope.Data = {};
$scope.Data.unit ='C';
$scope.Data.sysChange = false;
WeatherApi.getLoc().success(function(data) {
var city = data.loc + ',' + data.country;
$scope.Data.city = data.city;
$scope.Data.country = data.country;
WeatherApi.getCurrent(data.loc).success(function(data) {
CurrentWeather(data)
});
});
function CurrentWeather(data) {
$scope.Data.temp = Math.round(data.main.temp);
$scope.Data.Cel = Math.round(data.main.temp);
$scope.Data.des = data.weather[0].main;
$scope.Data.Fah = Math.round( ($scope.Data.temp * 9)/5 + 32 );
return IconGen($scope.Data.des);
}
function IconGen(city) {
var city = city.toLowerCase()
switch (city) {
case 'drizzle':
addIcon(city)
break;
case 'clouds':
addIcon(city)
break;
case 'rain':
addIcon(city)
break;
case 'snow':
addIcon(city)
break;
case 'clear':
addIcon(city)
break;
case 'thunderstom':
addIcon(city)
break;
default:
$('div.clouds').removeClass('hide');
}
}
function addIcon(city) {
$('div.' + city).removeClass('hide');
}
$scope.Data.sys= function(){
if($scope.Data.sysChange){
$scope.Data.unit ='C';
$scope.Data.temp = $scope.Data.Cel;
return $scope.Data.sysChange = false;
}
$scope.Data.unit ='F';
$scope.Data.temp = $scope.Data.Fah;
return $scope.Data.sysChange = true;
}
}); |
@marigerr would you like me close this issue and ask that freeCodeCamp/freeCodeCamp#15598 be reopened? |
Will do. |
Issue Description
When you open the codepen the example looks broken.
Browser Information
I am running the latest verions of Windows 10 and Chrome
Your Code / Link to Your Pen
https://codepen.io/freeCodeCamp/full/bELRjV
Screenshot
The text was updated successfully, but these errors were encountered: