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

              
                

<body>
 
   <p id="checking">Checking the weather...</p>
  <img id="window" src="http://pre02.deviantart.net/e941/th/pre/i/2014/356/5/e/boy_looking_trough_window_sketch_by_dragon_fire-d8asqls.jpg"/>
  <div id="main">
    <img id="icon" src="#"/>
    <p id="city"></p>
    <p id="summary"></p>
    <p id="humidity"></p>
    <p id="windSpeed"></p>
    <p id="t"></p>
    <button id="units">Fahrenheit/Celsius</button>
   
  </div>
</body>


              
            
!

CSS

              
                html {
  height:100%;
}

body {
  height:100%;
  width:100%;
  margin:0px;
  background-color:blue;
  background: -webkit-gradient(linear, 0% 0%,0% 0%, from(blue), to(white));
  background: -webkit-linear-gradient(top, blue, white);
  background: -moz-linear-gradient(top, blue, white);
 background: -ms-linear-gradient(top, Green, Yellow);
  background: -o-linear-gradient(top, blue, white); 
}

#main {  
  font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
  position: absolute;
  width: 40%;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  text-align: center;
      
}
#window {
  width:15%;
  position:relative;
  top: 65%;
  left: 50%;
  transform:translate(-50%,-50%);
  border-radius:50%;
  opacity: 0.75;
}

#checking {  
  font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
  position: absolute;
  width: 40%;
  top: 35%;
  left: 50%;
  transform: translate(-50%,-50%);
  text-align: center;
      
}


              
            
!

JS

              
                $(document).ready(function() {

  
var apiKey = "&appid=0f988bbfa0147c2dbb658c0350c8c0e5";
$("#main").hide();

var lat;
var lon;
  //find out local lat and lon  
  $.getJSON("https://api.wunderground.com/api/751b1d895edfa455/geolookup/q/autoip.json"
, function(data) {
    var lat = (data.location.lat);
    var lon = (data.location.lon);   
  
    //wunderground
  //751b1d895edfa455
  //google
    //AIzaSyB_6O1qmU7Hebp5HLrSLWOi_hjUW7BKkM8

  /*if("geolocation" in navigator) {
	  navigator.geolocation.getCurrentPosition(function(position) {
		  var lat = (position.coords.latitude).toFixed(2);
      var lon = (position.coords.longitude).toFixed(2);*/
  
  
      //generate api call
      var weather ="https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + apiKey;
      console.log(weather);
      
      $.getJSON(weather, function(data){  
          //assign variables (arrays) to data 
          var t = [data.main.temp];//current temperature 
          var humidity = data.main.humidity;
          var windSpeed = data.wind.speed;
          var summary = data.weather[0].main;
          var icon = data.weather[0].icon;
          var iconSrc = "https://openweathermap.org/img/w/" + icon + ".png"; 
          //convert units and added values to arrays:index 0=Kelvin; 1=Fahr; 2=Celsius
          //limit to 2 decimal places
          t.push((t[0]* (9/5) - 459.67).toFixed(1) + " \u00b0F");
          t.push((t[0] - 273.15).toFixed(1) + " \u00b0C");

          var u = 1;//u for units; 1=F, 2=C
            //default is set for Fahr(u=1)
          function changeUnit(){//adds temperature data to html with desired units
            if (u==1) {
              u++;
            } else { 
              u--;
            };//end else        
            $('#t').text("Current Temperature: " + t[u]);         
          };//changeUnit function end*/
        
          
          //plug data into html
          $("#icon").attr("src", iconSrc);
          $('#city').text("City: " + data.name);
          $('#summary').text("Weather: " + data.weather[0].main);
          $('#t').text("Current Temperature: " + t[1]);
          $('#humidity').text("Humidity: " + humidity + "%");
          $('#windSpeed').text("Wind Speed: " + windSpeed);


$("#checking").fadeOut(300);
$("#window").fadeTo(500,.15);
$("#main").fadeIn(400);      

var u = 1;//u for units; 1=F, 2=C; default is set for Fahr(u=1)        
$("#units").click(function() {
  if (u==1) {u++;} else {u--};
  $('#t').text("Current Temperature: " + t[u]);
  $('#maxTemp').text("Today's High: " + maxTemp[u]);
  $('#minTemp').text("Today's Low: " + minTemp[u]);  
});//end button click function*/

   
      });//end getJSON (weather) function*/

    });//end getJSON freegeo    
  //end if (geolocation in navigator)

});// end document ready
              
            
!
999px

Console