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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <head>


</head>  

<body>
<div class="background">
  <div class="background-overlay"></div>  
 <div class="weather-info">
   <h1 id="local" style="font-size: 48px;">Your Local Weather</h1>
   <br />
   <div class="loader" id="loaderDiv">Loading...</div>
   <div class="weather-data-div hidden">
     <p id="city"></p>
     <div class="temp-div">
     <p id="temp" onclick="degreeFunc()"></p>
     </div>
    <p id="conditions"></p>
   </div>
   <div class="icon-div">
    <img src="" id="icon"> 
   </div>
   <br />
  
   
<div class="forecast-container"> 
  
  <div class="forecast hidden" id="fcst0">
   
    <div class="forecastDay"><h3 id="fcstDay0"></h3></div>
    <div class="forecastIcon"><img src="" id="fcstIcon0"></div>
    <div class="forecastTemp" id="fcstTemp0">
      <p class="tempMax" id="tempMax0"></p>
      <p class="tempMin" id="tempMin0"></p>  
     </div>
  </div>
  <div class="forecast hidden" id="fcst1">
    <div class="forecastDay"><h3 id="fcstDay1"></h3></div>
    
    <div class="forecastIcon"><img src="" id="fcstIcon1"></div>
    
    <div class="forecastTemp" id="fcstTemp1">
      <p class="tempMax" id="tempMax1"></p>
      <p class="tempMin" id="tempMin1"></p>  
     </div>
     </div>
  
  <div class="forecast hidden" id="fcst2">
    <div class="forecastDay"><h3 id="fcstDay2"></h3></div>
    
    <div class="forecastIcon"><img src="" id="fcstIcon2"></div>
    
    <div class="forecastTemp" id="fcstTemp2">
      <p class="tempMax" id="tempMax2"></p>
      <p class="tempMin" id="tempMin2"></p> 
     </div>
     </div>
  <div class="forecast hidden" id="fcst3">
    <div class="forecastDay"><h3 id="fcstDay3"></h3></div>
  
    <div class="forecastIcon"><img src="" id="fcstIcon3"></div>
  
    <div class="forecastTemp" id="fcstTemp3">
      <p class="tempMax" id="tempMax3"></p>
      <p class="tempMin" id="tempMin3"></p> 
     </div>
  </div>
  <div class="forecast hidden" id="fcst4">
    <div class="forecastDay"><h3 id="fcstDay4"></h3></div>
    
    <div class="forecastIcon"><img src="" id="fcstIcon4"></div>
 
    <div class="forecastTemp" id="fcstTemp4">
      <p class="tempMax" id="tempMax4"></p>
      <p class="tempMin" id="tempMin4"></p> 
     </div>
     </div>
  
  </div>
   
   <br />
   <p style="text-align: center; width: 100%; display: block; white-space: nowrap; float: left">&copy 2017 Henry Burnett</p>
   <br />
   </div>
   </div>
</body> 
              
            
!

CSS

              
                
@import url('https://fonts.googleapis.com/css?family=Ubuntu');

body, html {
  font-family: Ubuntu;
  color: white;
  
}


a:hover{
  text-decoration: none;
}

.background {
  position: absolute;
  width: 100%;
  height: 1000px;
  background-color: #272a33;
  
}

.background-overlay{
  position: relative;
  width: 100%;
  height: 100%;
  background-color: rgb(255,255,255,0.1);
  margin: 0;
  padding: 0;
}

.hidden{
  display:none;
}

.loader,
.loader:before,
.loader:after {
  background: #ffffff;
  -webkit-animation: load1 1s infinite ease-in-out;
  animation: load1 1s infinite ease-in-out;
  width: 1em;
  height: 4em;
}
.loader {
  color: #ffffff;
  text-indent: -9999em;
  margin: 88px auto;
  position: relative;
  font-size: 11px;
  -webkit-transform: translateZ(0);
  -ms-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-animation-delay: -0.16s;
  animation-delay: -0.16s;
}
.loader:before,
.loader:after {
  position: absolute;
  top: 0;
  content: '';
}
.loader:before {
  left: -1.5em;
  -webkit-animation-delay: -0.32s;
  animation-delay: -0.32s;
}
.loader:after {
  left: 1.5em;
}
@-webkit-keyframes load1 {
  0%,
  80%,
  100% {
    box-shadow: 0 0;
    height: 4em;
  }
  40% {
    box-shadow: 0 -2em;
    height: 5em;
  }
}
@keyframes load1 {
  0%,
  80%,
  100% {
    box-shadow: 0 0;
    height: 4em;
  }
  40% {
    box-shadow: 0 -2em;
    height: 5em;
  }
}




.weather-info{
  text-align: center;
  border: 2px dashed black;
  border-radius: 15px;
  width: 40%;
  position: absolute;
  margin: 0 auto;
  top: 7.5%;
  left: 30%;
  background-color: #272a33
 
}

.weather-data-div{
  
  width: 35%;
  display: inline-block;
  text-align: left;
  padding-top: 10px;
  badding-bottom: 10px;
  

}


.weather-data-div p{
  text-align: center;
  margin: 0 auto;
  font-size: 26px;
  padding-bottom: 10px
}

.btn {
  margin: auto;
  margin-bottom: 10px;
  font-size: 20px;
  border-radius: 12px;
  margin-top: 10px;
  display: block; 
  font-family: Ubuntu;
}

.temp-div{
  text-align: center;
  padding-bottom: 5px;
}
.temp-div p {
  display: inline;
  text-size: 18px;

}

.icon-div{
  
  width: 160px;
  margin: 0 auto;
  padding: 2.5px;
}

#icon {
  display: block;
  margin: 0 auto;
  width: 150px; 
}

.forecast-container{
  margin: 0 auto;
}

.forecast {
  float: left;
  width: 15%;
  margin: 2.25%;
  height: 125px;
  border: 2px solid rgb(255,255,255,0.5);
  text-align: center; 
  font-size: 18px;
  color: rgb(255,255,255,0.9);
  border-radius: 3px;
}

#fcst0 {
  margin-left: 3.5%;
}


div.forecast div {
  text-align: center;
  font-size: 16px;
}


#overlay{
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgb(255,255,255,0.1);
}

.forecastDay h3 {
  margin-top: 5px;
  margin-bottom: -3px;
  font-size: 22px;

}

.forecastIcon img {
  width: 52.5px;
  margin-top: 7px;
  margin-bottom: 7px;
}

.tempMax {
  display: inline;
  margin-right: 1.5px;
}

.tempMin {
  margin-left: 1.5px;
  display: inline;
  color: rgb(255,255,255,0.5)
}

              
            
!

JS

              
                jQuery(document).ready(weatherFunction());
var temp ="";
var tempMax = [];
var tempMin = [];
var dates = [];


function weatherFunction(){
  
 var currentLat = "";
 var currentLon = ""; 
  
navigator.geolocation.getCurrentPosition(function(position){
      
  currentLat = position.coords.latitude;
  currentLon = position.coords.longitude;
   
 
var APIkey = "c470d9117220df245654821524d1b0c2";  
     
var currentURL = "https://fcc-weather-api.glitch.me/api/current?lat=" + currentLat + "&lon=" + currentLon; 
  
var forecastURL = "https://api.openweathermap.org/data/2.5/forecast/daily?lat=" + currentLat + "&lon=" + currentLon + "&APPID=" + APIkey; 
  
//console.log("currentURL = " + currentURL);  

//THIS IS FOR CURRENT WEATHER  
$.get(currentURL, function(data){
 temp = data.main.temp;
 temp = Math.round((temp * 9/5) + 32); 
 $("#loaderDiv").fadeOut("fast");
 $(".weather-data-div").removeClass("hidden"); 
 //$("#temp").html(temp);
 //$("#degrees").html("&deg <a>F</a>"); 
  $("#temp").html(temp + " &deg<a>F</a>");  
  $("#city").html(data.name); $("#conditions").html(data.weather[0].main); 
 var iconId = data.weather[0].id;
 var iconURL = ""; 
 iconURL = data.weather[0].icon;
  
  if (iconId >= 200 && iconId < 300){ //thunderstorm icon
      iconURL = "https://image.ibb.co/es8aK5/weather_icons_tstorm.png"
    }; 
  if (iconId >= 300 && iconId < 400){ //"drizzle" i.e. showers
    iconURL = "https://image.ibb.co/njacXQ/weather_icons_showers.png"
  };
  if (iconId >= 500 && iconId < 600){ //rain
    iconURL = "https://image.ibb.co/nPh2z5/weather_icons_rain.png"
  };
  if (iconId >= 600 && iconId < 700){ //snow
    iconURL = "https://image.ibb.co/cwcrsQ/weather_icons_snow.png"
  };
  if (iconId >= 700 && iconId < 800){ //fog/"atmosphere"
    iconURL = "https://image.ibb.co/meX2z5/weather_icons_fog.png"
  };
  if (iconId == 800){ //clear
    iconURL = "https://image.ibb.co/jUK4CQ/weather_icons_clear.png"
  };
  if (iconId == 801){ //partly cloudy
    iconURL = "https://image.ibb.co/d3f0mk/weather_icons_partly_cloudy.png"
  };
  if (iconId >= 802 && iconId <= 804){ //clouds
    iconURL = "https://image.ibb.co/dOoLmk/weather_icons_cloud.png"
  };
 
document.getElementById("icon").src = iconURL;
 
 //console.log("iconId = " + iconId);
 //console.log("iconURL = " + iconURL);
   }); 
  
///THIS IS FOR FORECAST  - the whole thing needs to go in for-loop
  
 //for (var i=0; i<5; i++) 

$.get(forecastURL, function(data){
 console.log(data);  
  
 var d = new Date();
 var today = d.getDay();
 console.log("today = " + today); 
 var days = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]; 
 for (var d=0; d<5; d++){
   dates[d] = (today + d);
   if (dates[d] > 6){
     dates[d] = (dates[d] - 7);
   }
   else{
     dates[d] = dates[d];
   } 
   dates[d] = days[dates[d]];
 };
   
   
  
  
  
 
 for (var i = 0; i < 5; i++) { 
 //console.log("dates[" + i + "] = " + dates[i]);  
 document.getElementById("fcstDay" + i).innerHTML = (dates[i]);
      
 tempMax[i] = data.list[i].temp.max;
 tempMax[i] = Math.round(((tempMax[i] - 273) * 9/5) + 32);//Kelvin to Fahrenheit
 document.getElementById("tempMax" + i).innerHTML = (tempMax[i] + "&deg  ");
 
 
 tempMin[i] = data.list[i].temp.min;
 tempMin[i] = Math.round(((tempMin[i] - 273) * 9/5) + 32); //Kelvin to Fahrenheit
 document.getElementById("tempMin" + i).innerHTML = (tempMin[i] + "&deg");
 
 var iconId = [];  
 iconId[i] = data.list[i].weather[0].id;
 var iconURL = [];     
 iconURL[i] = "http://openweathermap.org/img/w/" + iconId[i] + ".png";
   
  if (iconId[i] >= 200 && iconId[i] < 300){ //thunderstorm icon
      iconURL[i] = "https://image.ibb.co/es8aK5/weather_icons_tstorm.png"
    }; 
  if (iconId[i] >= 300 && iconId[i] < 400){ //"drizzle" i.e. showers
    iconURL[i] = "https://image.ibb.co/njacXQ/weather_icons_showers.png"
  };
  if (iconId[i] >= 500 && iconId[i] < 600){ //rain
    iconURL[i] = "https://image.ibb.co/nPh2z5/weather_icons_rain.png"
  };
  if (iconId[i] >= 600 && iconId[i] < 700){ //snow
    iconURL[i] = "https://image.ibb.co/cwcrsQ/weather_icons_snow.png"
  };
  if (iconId[i] >= 700 && iconId[i] < 800){ //fog/"atmosphere"
    iconURL[i] = "https://image.ibb.co/meX2z5/weather_icons_fog.png"
  };
  if (iconId[i] == 800){ //clear
    iconURL[i] = "https://image.ibb.co/jUK4CQ/weather_icons_clear.png"
  };
  if (iconId[i] == 801){ //partly cloudy
    iconURL[i] = "https://image.ibb.co/d3f0mk/weather_icons_partly_cloudy.png"
  };
  if (iconId[i] >= 802 && iconId[i] <= 804){ //clouds
    iconURL[i] = "https://image.ibb.co/dOoLmk/weather_icons_cloud.png"
  };
 
 document.getElementById("fcstIcon" + i).src = iconURL[i];  
   
 console.log("iconURL[" + i + "] = " + iconURL[i] + "\n");
 
 };
  
  $(".forecast").removeClass("hidden");
});
 
},function(error){
  $("#loaderDiv").fadeOut("fast");
  $("#conditions").html("Could not obtain your current location.")
});

}
 
//-----------------------------------------//
function degreeFunc(){  
  
  var degreesF = temp; 
  var degreesC = Math.floor((temp - 32) * 5/9);
  var tempNow = $("#temp").html();
   
   var maxF = tempMax;
   var minF = tempMin; 
   var maxC = [];
   var minC = []; 
  for (var i = 0; i<5; i++){
  
    maxC[i] = Math.floor((maxF[i] - 32) * 5/9);
    minC[i] = Math.floor((minF[i] - 32) * 5/9);
  }
  
    if (tempNow == temp + " °<a>F</a>"){ //#temp is in Farhenheit
      $("#temp").html(degreesC + " °<a>C</a>");
      for (var j=0; j<5; j++){//change #temp intoCelsius
      document.getElementById("tempMax" + j).innerHTML = (maxC[j] + "&deg  ");
      document.getElementById("tempMin" + j).innerHTML = (minC[j] + "&deg");
      }
    }
    else {//should mean that #temp is in Fahrenheit
       $("#temp").html(degreesF + " °<a>F</a>");
        for (var j=0; j<5; j++){
       document.getElementById("tempMax" + j).innerHTML = (maxF[j] + "&deg  ");
       document.getElementById("tempMin" + j).innerHTML = (minF[j] + "&deg");
       }
    }
/*  console.log("temp = " + temp);
  console.log("degreesC = " + degreesC);
  console.log("degreesF = " + degreesF);
  console.log("tempNow = " + tempNow);  
  
  for (var v=0; v<5; v++){
    console.log("tempMax[" + v + "] = " + tempMax[v]);
    console.log("tempMin{" + v + "] = " + tempMin[v]);
    console.log( "maxF [" + v + "] = " + maxF[v]);
    console.log( "minF [" + v + "] = " + minF[v]);
    console.log( "maxC [" + v + "] = " + maxC[v]);
    console.log( "minC [" + v + "] = " + minC[v]); 
  } */
  
}
              
            
!
999px

Console