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.

            
              <html>

<div id="container">
  <div id="header">
    <title>Local Weather</title>
  </div>

  <div id="body" class="container-fluid">
    <div id="wrapper">

      <div class="row">
        <div class="col-xs-2"></div>
        <div class="col-xs-8" id="head">

          <header class="text-center">
            <h1>The Weather for:<span id="city"></span></h1>
          </header>
          <br><br>
<div class="row">
        <div class="col-xs-2"></div>
        <div class="col-xs-8">
          <div id="raincloud">
            <p display: inline-block class="rainButtons text-center" id="sunButton">Sun</p>
            <p display: inline-block class="rainButtons text-center" id="tempButton">Conditions</p>
            <p display: inline-block class="rainButtons text-center" id="windButton">Wind</p>
          </div>
        </div>
        <div class="col-xs-2"></div>

      </div>
        </div>

        <div class="col-xs-2"></div>
      </div>
      

      <div id="info" class="row">
        <div class="col-xs-3"></div>
        <div class="col-xs-2">
          <div id="sun" class="text-center"></div>
        </div>
        <div class="col-xs-2">
          <div id="main">
            <div id="temperature" class="text-center"></div>
            <div id="conditions" class="text-center"></div>
          </div>
        </div>
        <div class="col-xs-2">
          <div id="wind" class="text-center">
            <div class="col-xs-3"></div>
          </div>
        </div>


      </div>
      <div id="footer">

        <h3 class="text-center"> Coded by <a href="http://www.williamcabell.com/" target="_blank">William Cabell</a><h3>
      
    </div>
       </div>
  </div>
    </div>
</html>
            
          
!
            
              html {
  margin: 0;
  padding: 0;
  height: 100%;
}

#container {
  min-height: 100%;
  position: relative;
}

body {
  margin: 0px;
  padding: 0px;
  height: 100%;
  z-index: 1;
}

h1 {
  color: black;
}

#raincloud {
  width: 100%;
  padding-left: 25%;
  padding-right: 25%;
  position: relative;
}

.rainButtons {
  margin-left: 30px;
  margin-right: 30px;
  font-size: 160%;
  float: left;
}

header {
  position: relative;
  height: 130px;
  z-index: 1;
  margin-top: 150px;
}

#head {
  background-image: url("http://cliparting.com/wp-content/uploads/2016/06/Clip-art-cloud-clipart-clipartcow.png");
  background-position: center;
  background-repeat: no-repeat;
  height: 400px;
  width: 100%;
  margin: 30px;
  padding: 20px;
}

#sun {
  background-color: #e8e8e8;
  margin: 10px;
  padding: 25px;
  position: relative;
  z-index: 1;
  display: inline;
  border-radius: 5px;
  font-size: 150%;
  display: none;
  width: 250px;
}

#main {
  background-color: #cccccc;
  margin: 10px;
  padding: 25px;
  border-radius: 5px;
  font-size: 150%;
  display: none;
  width: 250px;
}

#wind {
  background-color: #e8e8e8;
  margin: 10px;
  padding: 25px;
  border-radius: 5px;
  font-size: 150%;
  display: none;
  width: 250px;
}

#changeToFahr:hover {
  color: #5863c9;
}

#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60px;
  /* Height of the footer */
  background: #e8e8e8;
}
            
          
!
            
              if (navigator.geolocation) {

  navigator.geolocation.getCurrentPosition(function(position) {

    $.getJSON("https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude + "&APPID=b227615bf69f72681b17d4d63ebd669a", function(where) {

      var sunrain = where.weather[0].main;

      $("#conditions").html("<p>Current Conditions: " + sunrain + "<p>")

      console.log(where.weather[0].id)

      if (where.weather[0].id >= 200 && where.weather[0].id <= 232) {
        $.backstretch("https://static.pexels.com/photos/56614/lightning-storm-night-firebird-56614.jpeg");
      } else if (where.weather[0].id >= 300 && where.weather[0].id <= 321) {
        $.backstretch("https://static.pexels.com/photos/31202/pexels-photo-31202.jpg");
      } else if (where.weather[0].id >= 500 && where.weather[0].id <= 531) {
        $.backstretch("https://static.pexels.com/photos/110874/pexels-photo-110874.jpeg");
      } else if (where.weather[0].id >= 600 && where.weather[0].id <= 622) {
        $.backstretch("https://static.pexels.com/photos/6672/snow-forest-trees-winter.jpeg");
      } else if (where.weather[0].id >= 701 && where.weather[0].id <= 781) {
        $.backstretch("https://static.pexels.com/photos/48678/pexels-photo-48678.jpeg");
      } else if (where.weather[0].id === 800) {
        $.backstretch("https://static.pexels.com/photos/72161/pexels-photo-72161.jpeg");
      } else if (where.weather[0].id >= 801 && where.weather[0].id <= 803) {
        $.backstretch("https://static.pexels.com/photos/3768/sky-sunny-clouds-cloudy.jpg")

      } else if (where.weather[0].id === 804) {
        $.backstretch("https://static.pexels.com/photos/59320/pexels-photo-59320.jpeg");
      } else if (where.weather[0].id >= 951 && where.weather[0].id <= 962) {
        $.backstretch("https://static.pexels.com/photos/7763/pexels-photo.jpg");
      } else {
        $.backstretch("https://static.pexels.com/photos/33834/landscape-shore-sunset-clouds.jpg")
      };

      console.log(where);

      $("#city").html("<h1>" + where.name + "</h1>");

      //Sunrise
      var rise = new Date(where.sys.sunrise * 1000);

      var hours = rise.getHours();

      var minutes = "0" + rise.getMinutes();

      var seconds = "0" + rise.getSeconds();

      var newRise = hours + ":" + minutes.substr(-2) + ":" + seconds.substr(-2);

      //Sunset
      var set = new Date(where.sys.sunset * 1000);

      var hours = set.getHours();

      var minutes = "0" + set.getMinutes();

      var seconds = "0" + set.getSeconds();

      var newSet = hours - 12 + ":" + minutes.substr(-2) + ":" + seconds.substr(-2);

      $("#sun").html("<p>Sunrise: " + newRise + "AM</p> <br> <p>Sunset: " + newSet + "PM</p>");

      //Temperature
      var celsius = where.main.temp - 273.15;

      var fahrenheit = where.main.temp * 1.8 - 459.67;

      $("#temperature").html("<p><span id='changeToFahr'>Current Temperature:</span> " + "<span id = 'celFahr'>" + Math.floor(celsius) + "&#8451</span></p>")

      var tempCel = true;

      //Celsius to Fahrenheit
      $("#changeToFahr").click(function() {
        if (tempCel == true) {

          tempCel = false;
          console.log(tempCel);
          $("#celFahr").html(Math.floor(fahrenheit) + "&#8457")

        } else if (tempCel == false) {

          tempCel = true;
          console.log(tempCel);

          $("#celFahr").html(Math.floor(celsius) + "&#8451")

        };
      });

      //Wind Speed

      var windSpeed = where.wind.speed * 2.237;

      var degree = where.wind.deg;

      if (11.25 < degree && degree <= 33.75) {
        var direction = "North Northeast";
      } else if (33.75 < degree && degree <= 56.25) {
        var direction = "Northeast";
      } else if (56.25 < degree && degree <= 78.75) {
        var direction = "East Northeast";
      } else if (78.75 < degree && degree <= 101.25) {
        var direction = "East";
      } else if (101.25 < degree && degree <= 123.75) {
        var direction = "East Southeast";
      } else if (123.75 < degree && degree <= 146.25) {
        var direction = "Southeast";
      } else if (146.25 < degree && degree <= 168.75) {
        var direction = "South Southeast";
      } else if (168.75 < degree && degree <= 191.25) {
        var direction = "South";
      } else if (191.25 < degree && degree <= 213.75) {
        var direction = "South Southwest";
      } else if (213.75 < degree && degree <= 236.25) {
        var direction = "Southwest";
      } else if (236.25 < degree && degree <= 258.75) {
        var direction = "West Southwest";
      } else if (258.75 < degree && degree <= 281.25) {
        var direction = "West";
      } else if (281.25 < degree && degree <= 303.75) {
        var direction = "West Northwest";
      } else if (303.75 < degree && degree <= 326.25) {
        var direction = "Northwest";
      } else if (326.25 < degree && degree <= 348.75) {
        var direction = "North Northwest";
      } else if (348.75 < degree && degree <= 11.25) {
        var direction = "North";
      };

      $("#wind").html("<p>Wind Speed: <br>" + Math.floor(windSpeed) + " MPH</p><br><p>Wind Direction: " + direction + "</p>")

    });
    $("#sunButton").click(function() {

      $("#sun").slideToggle();

    });
    $("#tempButton").click(function() {

      $("#main").slideToggle();

    });
    $("#windButton").click(function() {

      $("#wind").slideToggle();

    });

  });
};
            
          
!
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