Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <div ng-app="weatherApp" ng-controller="WeatherAppCtrl">
  <div id="page-preloader" ng-hide='weatherData'>
    <h2>Hold still! The page will soon be loaded!</h2>
  </div>

  <div class="wrapper" ng-show='weatherData'>
    <section>
      <h2>{{ weatherData.cityName }}, {{ weatherData.country }}</h2>

      <div class="temperature">
        <img ng-src='{{ weatherData.icon }}' alt="weather-icon" />
        <h2>{{ weatherData.temp.value }}<span class="degree-symbol">°</span>{{ weatherData.temp.unit1 }}<span class="alt-deg"> | <a href id="secondary-deg" ng-click='changeDeg()'>{{ weatherData.temp.unit2 }}</a></span></h2>
      </div>
      <ul>
        <li class="fontawesome-leaf">
          <span>{{ weatherData.wind }} m/s</span>
        </li>
        <li class="fontawesome-tint">
          <span>{{ weatherData.humidity }} %</span>
        </li>
      </ul> 
    </section>
    <footer>
      <p>Made by <a href="https://saintgeo23.github.io/">saintgeo23</a> for <a href="https://www.freecodecamp.com/">FreeCodeCamp</a> project</p>
      <p>Inspired by <a href="https://codepen.io/cguillou/">Clément Guillou</a></p>
    </footer>
  </div>
</div>
              
            
!

CSS

              
                @import "https://fonts.googleapis.com/css?family=Open+Sans:400,300,700";
@import url(http://weloveiconfonts.com/api/?family=fontawesome);

[class*="fontawesome-"]:before {
  font-family: 'FontAwesome', sans-serif;
}


body {
  color: #eee;
  font-family: 'Open Sans', sans-serif;
  background-color: #FFF3E0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.wrapper {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  margin-top: 3%;
}

section {
  height: 100%;
  box-sizing: border-box;
  padding: 2% 0;
  background: linear-gradient(#FBC02D, #FB8C00);
  border-radius: 7px;
  box-shadow: 0 5px 25px -5px rgba(0, 0, 0, 1);
}


section .temperature {
  padding: 2% 0 0;
  color: #3D414C;
}

section .temperature img {
  width: 75%;
  max-width: 96px;
  height: auto;
}

section .temperature h2 {
  display: inline;
  color: #eee;
  font-weight: 500;
  font-size: 6em;
}

section .temperature h2 span.degree-symbol {
  display: inline-block;
  margin: 0px 15px;
  font-size: 0.6em;
  vertical-align: top;
}
section .temperature h2 span.alt-deg {
  display: inline-block;
  margin: 10px 0px 0px 15px;
  color: #3D414C;
  font-size: 0.3em;
  vertical-align: top;
}

section .temperature h2 #secondary-deg{
  color: #3D414C;
  text-decoration: none;
}

section .temperature h2 #secondary-deg:hover {
  color: #BBBBBB;
}

@media screen and (max-width: 372px) {
	
  section > h2 {
    margin-bottom: 10px;
  }
  
  section .temperature img {
		display: block;
    margin: 0 auto;
	}
}

@media screen and (max-width: 271px) {
	section .temperature {
    padding: 1% 0 0;
    margin: 0 auto;
  }
  section .temperature h2 {
    display: block;
    font-size: 4em;
    margin: 0 auto;
  }
  section .temperature h2 span.degree-symbol {
    margin: 0px 5px;
    font-size: 0.5em;
  }
  section .temperature h2 span.alt-deg {
    margin: 5px 0px 0px 5px;
    font-size: 0.3em;
  }
}

section ul {
  padding: 0;
  width: 100%;
  max-width: 400px;
  margin: 2% auto;
}
section ul li {
  display: inline-block;
  margin-right: 15%;
  color: #3D414C;
  font-size: 2em;
}
section ul li:last-child {
  margin-right: 0px;
}

@media screen and (max-width: 271px) {
  section ul li {
    display: block;
    margin: 0 auto;
  }
}

section ul li span {
  padding-left: 10px;
  color: #eee;
  font-size: 0.6em;
  line-height: 30px;
  vertical-align: top;
}

footer {
  margin-top: 20px;
  text-align: center;
  clear: both;
  overflow:hidden;
  color: #000000;
}

footer p {
  display: block;
  font-size: 0.8em;
  font-weight: 300;
  width: 70%;
  padding: 0;
  margin: 0 auto;
}
              
            
!

JS

              
                // navigator.Geolocation doesn't work on http anymore. So I used https://htmlweb.ru for getting information about geolocation by IP-adress


var app = angular.module('weatherApp', []);






app.factory('WeatherFactory', function($http) {
  var method = {};
  
  method.getData = function(url) {
    return $http.get(url);
  };
   
  return method;
});






app.controller('WeatherAppCtrl', ['$scope', 'WeatherFactory', function($scope, WeatherFactory){

  var lat, lon, url, query;
  query = 'https://api.sypexgeo.net/json';
  WeatherFactory.getData(query).success(function(data) { 
    console.log(data);
    lat = data.city.lat;
    lon = data.city.lon;
    url = 'https://api.openweathermap.org/data/2.5/weather?lat=' + lat + '&lon=' + lon + '&APPID=2edf9572af6ab6dd92ba46fdbd03f702';
    WeatherFactory.getData(url).success(function(data) {
      var weatherData = {};
      weatherData.temp = {};
      weatherData.cityName = data.name;
      weatherData.country = data.sys.country;
      weatherData.temp.k = Math.round(data.main.temp);
      weatherData.temp.c = weatherData.temp.k - 273;
      weatherData.temp.f = Math.round(weatherData.temp.c * 9 / 5 + 32);
      weatherData.temp.unit1 = 'C';
      weatherData.temp.unit2 = 'F';
      weatherData.temp.value = weatherData.temp.c;
      weatherData.wind = Math.round(data.wind.speed);
      weatherData.humidity = Math.round(data.main.humidity);
      weatherData.icon = 'http://openweathermap.org/img/w/' + data.weather[0].icon + '.png';
      $scope.weatherData = weatherData;
    });
  });

  
  $scope.changeDeg = function(){
    if ($scope.weatherData.temp.unit1 === 'C') {
      $scope.weatherData.temp.unit1 = 'F';
      $scope.weatherData.temp.unit2 = 'C';
      $scope.weatherData.temp.value = $scope.weatherData.temp.f;
      $scope.weatherData = $scope.weatherData;
    } else if ($scope.weatherData.temp.unit1 === 'F') {
      $scope.weatherData.temp.unit1 = 'C';
      $scope.weatherData.temp.unit2 = 'F';
      $scope.weatherData.temp.value = $scope.weatherData.temp.c;
      $scope.weatherData = $scope.weatherData;
    };
  };
  
}]);



              
            
!
999px

Console