Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <head>
  <link href='https://fonts.googleapis.com/css?family=Roboto:400,500,300,100' rel='stylesheet' type='text/css'>
</head>
<body>
  <div class="fondu">
    <div class="content">
      <h1>FreeCodeCamp Weather</h1>
      <h2 id="city"></h2>
      <h2 id="weather"></h2>
      <h2 id="weather-icon" class="icon"></h2>
      <h1 id="temp" class="default"></h1>
      <h2 id="wind"></h2>
      <h4 id="data"></h4>
      <form action="">
      <input class="noEnterSubmit" type="text" id="text" name="name" value="" />
      <input class="btn btn-primary get" type="button" id="text_value" value="Get Value"/>
      </form>
    </div>
  </div>
</body>

            
          
!
            
              @font-face {
    font-family: 'weather';
    src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.eot');
    src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.eot?#iefix') format('embedded-opentype'),
         url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.woff') format('woff'),
         url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.ttf') format('truetype'),
         url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/93/artill_clean_icons-webfont.svg#artill_clean_weather_iconsRg') format('svg');
    font-weight: normal;
    font-style: normal;
}

#weather-icon { 
  font-family: weather; 
  font-size:11em;
}

.icon-01d:before { content: "1"; }
.icon-01n:before { content: "6"; }
.icon-02d:before { content: "2"; }
.icon-02n:before { content: "a"; }
.icon-03d:before { content: "A"; }
.icon-03n:before { content: "a"; }
.icon-04d:before { content: "3"; }
.icon-04n:before { content: "3"; }
.icon-10d:before, .icon-10n:before { content: "U"; }


.wall-01d {
  background: url('https://www.housebloggen.no/wp-content/uploads/2013/10/horisont.jpg') bottom;
}

.wall-02d, .wall-03d {
  background: url('http://www.win10themes.com/wp-content/uploads/2016/03/Wallpaper-Weather.jpg') center center;
}

.wall-04d {
  background: url('https://www.walldevil.com/wallpapers/a72/sea-of-clouds-beautiful-scenery.jpg') center center;
}

.wall-10d {
  background: url('http://www.win10themes.com/wp-content/uploads/2016/03/Rainy-Weather-Wallpaper.jpg') center center;
}

.wall-10n {
  background: url('http://www.wallcheap.com/wp-content/uploads/2016/05/rain_at_night_wallpaper_hd.jpg') center center;
}

html, body {
  text-align: center;
  color: white;
  height:100%;
  background-size:cover !important;
  background-color: black;
}

h1,h2,h3,h4,input,p {
    font-family: 'Roboto', sans-serif;
    font-weight:300;
}

.fondu {
  background-color:rgba(0,0,0,0.35);
  height:100%;
  display: flex;
}

.content { 
  margin:auto;
}

.content h1 {
  margin-top: 0px;
}

#weather::first-letter {
  text-transform: uppercase;
}

input {
  color: white;
}

input#text {
  background-color:transparent;
  border:1px solid white;
  padding:5px;
  margin-top:10px;
}

.btn-primary {
  background-color:transparent;
  border: 1px solid white;
  border-radius: 0px;
  padding: 5px 15px;
}

.btn-primary:hover {
  transition:300ms;
  background-color:white;
  color:#555;
  border: 1px solid white;
}

div {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
            
          
!
            
              $(document).ready(function test() {

  var long;
  var lat;
  var temp;

  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      lat = position.coords.latitude;
      long = position.coords.longitude;

      var api = 'https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat=' + lat + '&lon=' + long + '&units=metric&appid=9db1464acb5397dd3c1340f59afc0880';

      function test(api) {
        $.getJSON(api, function(data) {
          var winSpeed = data.wind.speed;
          var city = data.name;
          var weather = data.weather[0].description;
          var weatherIcon = data.weather[0].icon;
          temp = data.main.temp;
          $('.get').click(function() {
            $(".icon").hide().removeClass('icon-' + weatherIcon);
            $("body").hide().removeClass('wall-' + weatherIcon);
          });
          $("#weather").hide().html(weather).fadeIn(1000);
          $(".icon").hide().addClass('icon-' + weatherIcon).fadeIn(1500);
          $("#city").hide().html(city).fadeIn(600);
          $("#temp").hide().html(temp + "°").fadeIn(1800);
          $("body").hide().addClass('wall-' + weatherIcon).fadeIn(500); 

        });
      }
      test(api);

      $('.get').click(function() {
        var val = $('input').val();
        var api = 'https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?q=' + val + '&appid=9db1464acb5397dd3c1340f59afc0880&units=metric';
        return test(api);
      });

      $("#temp").click(function() {
        if ($("#temp").hasClass("default")) {
          var Ftemp = ((temp * 9) / 5) + 32;
          $('#temp').text(Ftemp + " F°")
          $(this).removeClass('default');
          $(this).addClass('open');
        } else {
          $("#temp").text(temp + "°");
          $(this).removeClass('open');
          $(this).addClass('default');
        }
      });

      $('.noEnterSubmit').keypress(function(e) {
        if (e.which == 13) return false;
        //or...
        if (e.which == 13) e.preventDefault();
      });

    });
  };
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console