
"use strict";

angular.module('myapp')
  .controller("WeatherController", function($scope, $http){
  
    $scope.loading = true;
    if (navigator.geolocation) navigator.geolocation.getCurrentPosition(onPositionUpdate);
 
    function onPositionUpdate(position) {
      var lati = position.coords.latitude;
      var longi = position.coords.longitude;
      /*var url = 'https://api.wunderground.com/api/4a82154c39d11213/conditions/geolocation/q/' + lati + ',' + longi + '.json';*/
      var url = 'https://api.wunderground.com/api/4a82154c39d11213/forecast/geolocation/q/' + lati + ',' + longi + '.json';
      $http.get(url)
        .then(function(info) {
        console.log(info);
            
          $scope.weatherNow = {
            city: info.data.current_observation.display_location.city,
            description: info.data.current_observation.weather,
            temp_f: Math.round(info.data.current_observation.temp_f),
            temp_c: Math.round(info.data.current_observation.temp_c),
            temp: null,
            humidity: info.data.current_observation.relative_humidity,
            wind_mph: Math.round(info.data.current_observation.wind_mph) + "mph",
            wind_kph: Math.round(info.data.current_observation.wind_kph) + "kph",
            wind: null,
            imageSrc: info.data.current_observation.icon_url
          };
        
          var currentTime = new Date();
          var hours = currentTime.getHours();
          var minutes = currentTime.getMinutes();
          var ending = "AM";

          if (minutes < 10) {
            minutes = "0" + minutes;
          }
          if (hours >= 12) {
            hours = hours - 12;
            ending = "PM";
          }

          if (hours === 0) {
            hours = 12;
          }
          var currentDate = new Date();
          var timeNow = hours + ":" + minutes + " " + ending;
          $scope.weatherNow.timeDate = timeNow + " " + currentDate.toDateString();
          console.log($scope.weatherNow);
      
          $scope.imperial = true;
          document.getElementById("fahrenheit").style.backgroundColor = "#99e6ff";
          document.getElementById("celsius").style.backgroundColor = "#f2f2f2";
          $scope.weatherNow.temp = $scope.weatherNow.temp_f;
          $scope.weatherNow.wind = $scope.weatherNow.wind_mph;
      
          $scope.unitChange = function(elem){
            $scope.imperial = elem;
            console.log(Boolean($scope.imperial));
            if($scope.imperial === true){
            document.getElementById("fahrenheit").style.backgroundColor = "#99e6ff";
            document.getElementById("celsius").style.backgroundColor = "#f2f2f2";
            $scope.weatherNow.temp = $scope.weatherNow.temp_f;
            $scope.weatherNow.wind = $scope.weatherNow.wind_mph;
          } else if($scope.imperial === false) {
            document.getElementById("fahrenheit").style.backgroundColor = "#f2f2f2";
            document.getElementById("celsius").style.backgroundColor = "#99e6ff";
            $scope.weatherNow.temp = $scope.weatherNow.temp_c;
            $scope.weatherNow.wind = $scope.weatherNow.wind_kph;
          }
        };
       
      
      });
    }
  });
  

@@ -100,35 +100,8 @@
 %0A  %0A
-    $scope.loading = true;%0A
     
@@ -713,614 +713,8 @@
     
-city: info.data.current_observation.display_location.city,%0A            description: info.data.current_observation.weather,%0A            temp_f: Math.round(info.data.current_observation.temp_f),%0A            temp_c: Math.round(info.data.current_observation.temp_c),%0A            temp: null,%0A            humidity: info.data.current_observation.relative_humidity,%0A            wind_mph: Math.round(info.data.current_observation.wind_mph) + %22mph%22,%0A            wind_kph: Math.round(info.data.current_observation.wind_kph) + %22kph%22,%0A            wind: null,%0A            imageSrc: info.data.current_observation.icon_url
 %0A   
@@ -742,1828 +742,9 @@
     
- 
-   var currentTime = new Date();%0A          var hours = currentTime.getHours();%0A          var minutes = currentTime.getMinutes();%0A          var ending = %22AM%22;%0A%0A          if (minutes %3C 10) %7B%0A            minutes = %220%22 + minutes;%0A          %7D%0A          if (hours %3E= 12) %7B%0A            hours = hours - 12;%0A            ending = %22PM%22;%0A          %7D%0A%0A          if (hours === 0) %7B%0A            hours = 12;%0A          %7D%0A          var currentDate = new Date();%0A          var timeNow = hours + %22:%22 + minutes + %22 %22 + ending;%0A          $scope.weatherNow.timeDate = timeNow + %22 %22 + currentDate.toDateString();%0A          console.log($scope.weatherNow);%0A      %0A          $scope.imperial = true;%0A          document.getElementById(%22fahrenheit%22).style.backgroundColor = %22#99e6ff%22;%0A          document.getElementById(%22celsius%22).style.backgroundColor = %22#f2f2f2%22;%0A          $scope.weatherNow.temp = $scope.weatherNow.temp_f;%0A          $scope.weatherNow.wind = $scope.weatherNow.wind_mph;%0A      %0A          $scope.unitChange = function(elem)%7B%0A            $scope.imperial = elem;%0A            console.log(Boolean($scope.imperial));%0A            if($scope.imperial === true)%7B%0A            document.getElementById(%22fahrenheit%22).style.backgroundColor = %22#99e6ff%22;%0A            document.getElementById(%22celsius%22).style.backgroundColor = %22#f2f2f2%22;%0A            $scope.weatherNow.temp = $scope.weatherNow.temp_f;%0A            $scope.weatherNow.wind = $scope.weatherNow.wind_mph;%0A          %7D else if($scope.imperial === false) %7B%0A            document.getElementById(%22fahrenheit%22).style.backgroundColor = %22#f2f2f2%22;%0A            document.getElementById(%22celsius%22).style.backgroundColor = %22#99e6ff%22;%0A            $scope.weatherNow.temp = $scope.weatherNow.temp_c;%0A            $scope.weatherNow.wind = $scope.weatherNow.wind_kph;%0A          %7D%0A        %7D;%0A       %0A      %0A 
+%0A
     

Update controller1.js