Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<html lang="en"  ng-app="WeatherApp"  ng-controller="slideShowController">
  <head>
    <meta charset="utf-8">
    <title>Free Code Camp:Local Weather</title>
  </head>
  <body ng-class="{'night-mode': isNight()}">
   
    <div class="container-fluid" > 
    <div class="row">
     
         <div class="col-md-12 text-center" style="margin-top:30px;">
          
             
           <div >
          <div ng-animate-swap="number" class="cell swap-animation">
   
            <h1> <i ng-class="iconClass(number)"></i></h1>
  </div>
</div>
           <h1>Loca<i class="wi wi-thermometer"></i> Weather             </h1>
           <h5>Free Code Camp Challenge</h5>
         </div>
    </div>
      <div class="row">
         <div class="col-md-12 text-center infoweather" >
            {{items.name}}
           {{items.sys.country}}
        </div>
      </div>
      <div class="row">
        <div class="col-md-12 text-center" >
          <h2> <span class="degreeCls">{{degree}}</span><span style="padding-left:5px;"><i ng-click="toggle()" ng-class="tempUnits === 'wi wi-celsius' ? 'wi wi-celsius' : 'wi wi-fahrenheit'"></i></span></h2>
        </div>
      </div>
      <div class="row">
         <div class="col-md-12 text-center" >
          
        <div class="panel panel-default">
  <div class="panel-body">
           <img  ng-src="{{iconWeather}}"></img> 
        <h4>{{description}}</h4>
          </div>
</div>
         </div>
      </div>
      <div class="row">
        <div class="col-md-12 text-center">
          <p class="text-center" style="font-weight:normal; font-family:arial; color:pink;">Inspired By <u><a href="https://codepen.io/bigberm/" target="_blank">Berm M</a></u></p>
        </div>
      </div>

    <p></p>
    </div>

  </body>
</html>
              
            
!

CSS

              
                
body{
   background: url(
http://res.cloudinary.com/bermcloudinary/image/upload/v1510107040/Thailandbangkok_f7ztdd.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  font-family: 'Shrikhand', cursive;
  color: #2E2E2E;
}

body.night-mode {
   background: url(
http://res.cloudinary.com/bermcloudinary/image/upload/v1510190697/bangkokNight.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  font-family: 'Shrikhand', cursive;
  color: #2E2E2E;
}
h1 {
     text-shadow: 2px 2px #fff;
    color: #2E2E2E;
} 
.swap-animation.ng-enter, .swap-animation.ng-leave {
  transition:0.5s linear all;
}
.swap-animation.ng-enter {
  top:-250px;
}
.swap-animation.ng-enter-active {
  top:0px;
}
.swap-animation.ng-leave {
  top:0px;
}
.swap-animation.ng-leave-active {
  top:250px;
}

h2
{ 
  color:#E74C3C;
  text-shadow: 1px 1px #F1948A;
}
.degreeCls{
   color:#5B2C6F ;
  font-family:tahoma;
  font-weight:bold;
  text-shadow: 1px 1px #D7BDE2;
}
.infoweather{
   color:#F7120B;
  font-family:tahoma;
  font-weight:bold;
  text-shadow: 1px 1px #fff;
  font-size:18pt;
  
}
.panelIcon{
  
   border: 1px solid #8a4419;
  

}
h4{
  color:#E91E63;
  text-shadow: 1px 1px #F1948A;
  font-family: sans-serif;
}
              
            
!

JS

              
                

// Define the  module
var WeatherApp = angular.module('WeatherApp', ['ngAnimate']);

// Define the `Controller` controller on the  module
WeatherApp.controller('slideShowController',['$scope', '$interval', function($scope, $interval,$http) {
  var api = "https://fcc-weather-api.glitch.me/api/current?";
  $scope.number = 0;
  $scope.degree=0;
  $scope.position="";
  $scope.tempUnits='wi wi-celsius';
  $scope.iconWeather="";
  $scope.items = [];
  $scope.description="";
  $scope.isNight=false;
  var lat, lon;
    if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position){
      
        lat = "lat=" + position.coords.latitude;
        lon = "lon=" + position.coords.longitude;
       getWeather('celsius',lat,lon);
       
    });
    }
  var icons = ['wi wi-day-sunny','wi wi-day-cloudy','wi wi-hail','wi wi-thunderstorm']; 
  $interval(function() {
    $scope.number++;
    }, 1000);

  
  $scope.iconClass = function(number) {
    return icons[number% icons.length];
  };
  
  $scope.toggle = function() {
    if ($scope.tempUnits === "wi wi-celsius"){
        $scope.tempUnits = "wi wi-fahrenheit";
        getWeather('fahrenheit',lat,lon);
    }else{
        $scope.tempUnits = "wi wi-celsius";
        getWeather('celsius',lat,lon);
    }

  };
  var getWeather=function(unitVal,lat,lon){
    var urlString = api + lat + "&" + lon;
        
       $.ajax({
    url: urlString, success: function (result) {
       $scope.items=result;
      if(unitVal=='celsius')
       $scope.degree= Math.round(result.main.temp * 10) / 10+'';
      if(unitVal=='fahrenheit'){
        var cels=Math.round(result.main.temp * 10) / 10;
        $scope.degree=  Math.round(cels * 9 / 5 + 32)+'';
      }
      $scope.iconWeather=result.weather[0].icon;
      $scope.description=result.weather[0].description;
    }
  });
  /*$http.jsonp(urlString)
    .success(function(data) {
      var results = data;
   
        $scope.items.push(results);*/
      
     /* if(unitVal=='celsius')
       $scope.degree= Math.round(result.main.temp * 10) / 10+'';
      if(unitVal=='fahrenheit'){
        var cels=Math.round(result.main.temp * 10) / 10;
        $scope.degree=  Math.round(cels * 9 / 5 + 32)+'';
      }
      $scope.iconWeather=result.weather[0].icon;
      $scope.description=result.weather[0].description;*/
   
  //  });
    
    $scope.isNight = function() {
        var hours = new Date().getHours();
        return hours > 19 || hours < 8;
    };    

  };
}]);


              
            
!
999px

Console