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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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

              
                <link href='http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext' rel='stylesheet'>

<div class="container-fluid">
   <div class="block text-center">
     <h2 class=text-center>FCC Weather App</h2>
     
     <div class="btnList text-center">
      <button class="btn btn-primary btn1">
        <div class="row">
        <img>
      <h5 class= "text-center" id="weatherCondition"> </h5>
        </div>
       </button>
       <button class="btn btn-primary btn2">
         <h5 class="text-center" id = "tempCondition"></h5>
       </button>
       <button class="btn btn-primary btn3" id="weatherbutton"><h5>get weather button</h5>
       </button>
     </div>
      
     <h6 class="text-center"> <i>Click on the Temperature to toggle between F and C <i></h6>     
     
     
  </div>
  
   <footer class="page-footer">
    Project by <a href="https://codablejoy.com/" >CodableJoy</a>
    </footer>
  
</div>
</div>

    
              
            
!

CSS

              
                body{
  background-image: url("http://unsplash.com/photos/hVF_04fzKO4/download?force=true");
  background-size: 1600px 600px;
  background-repeat: no-repeat;
}

.block{
  background-color: white;
  width: 1000px;
  height: 350px;
  padding-top: 50px;
  padding-right: 20px;
  padding-left: 20px;
  margin-right: auto;
  margin-left: auto;
  margin-top: 50px;
  text-align:center;
  font-family: 'Lato', sans-serif;
  opacity: 0.75;
}

h2{
  padding: 20px;
 margin-top: 50px;
 font-family: 'Lato', sans-serif;
  
}

h5{
  color: black;
  margin: auto;
}

.btn1{
  height: 80px;
  width: 300px;
  margin: 20px;
  background-color: white;
  border: none;
}
.btn1:hover{
  border: none;
  background-color: white;
}

.btn2{
  height: 80px;
  width: 200px;
  margin: 20px;
  background-color: white;
  border: none;
}
.btn2:hover{
  border: none;
  background-color: #FFA07A;
}

.btn3{
  height: 80px;
  width: 200px;
  margin: 20px;
  background-color: #FFA07A;
  border: none;
}

.page-footer{
  margin-top: 150px;
  font-size: 10px;
  text-align: center;
}

a:hover {text-decoration: none;}

h6{
  margin-top: 20px;
  font-size: 15px;
  color: black;
  
}
              
            
!

JS

              
                

$(document).ready(function() {
  
  var locationLat;
  var locationLong;
  
  if (navigator.geolocation) { 
navigator.geolocation.getCurrentPosition(function(position) { 
  locationLat = position.coords.latitude;
  locationLong = position.coords.longitude;
}); 
};

  
   $('#weatherbutton').click(function () {
   url = "https://crossorigin.me/https://api.darksky.net/forecast/a24805f95bcff8508810dda799ced947/" + locationLat + "," + locationLong; 
   $.getJSON(url, function(data){
      var newWeather; 
  var newTempF;
     var newTempC1;
     var newTempC
     var tempSwatch = true;
  newWeather= data["currently"].icon;
     newTempF = data["currently"].temperature;
    newTempC1 = (newTempF-32) * 5 / 9;
     newTempC = newTempC1.toFixed(2);
     
     
       
     $("#weatherCondition").html("Weather:" + newWeather); 
     
 $("#tempCondition").html("Temperature:" + newTempF + "F");    
     
 $(".btn2").click(function(){
   if(tempSwatch === true){
    $('#tempCondition').html("Temperature:" + newTempC + "C");
     tempSwatch=false;
   }
   else {$('#tempCondition').html("Temperature:" + newTempF + "F");
    tempSwatch=true;     
        };
 });
   

     if(newWeather === "clear-day"){
  $('img').attr('src', 'url(http://openweathermap.org/img/w/01d.png)');}
     else if(newWeather === "clear-night"){
       $('img').attr("src", 'http://openweathermap.org/img/w/01n.png');}
     else if(newWeather === "partly-cloudy-night"){
        $('img').attr("src", 'http://openweathermap.org/img/w/02n.png');}
      else if(newWeather === "rain"){
        $('img').attr("src", 'http://openweathermap.org/img/w/10d.png');}
     else if(newWeather === "snow"|| newWeather ==="sleet"){
        $('img').attr("src", 'http://openweathermap.org/img/w/13d.png');}
     else if(newWeather === "wind"|| newWeather === "fog"){
        $('img').attr("src", 'http://openweathermap.org/img/w/03d.png');}
      else if(newWeather === "cloudy"||newWeather === "partly-cloudy-day"){
        $('img').attr("src", 'http://openweathermap.org/img/w/03d.png');}
    

  
  switch(newWeather){
   case "clear-day":
  $('body').css("background-image", 'url("http://unsplash.com/photos/hVF_04fzKO4/download?force=true")');
      //Set background image
      break;
   case "fog":
       $('body').css("background-image", 'url("http://unsplash.com/photos/uvbA1IHilCI/download?force=true")');
      break;
   case "rain":
       $('body').css("background-image", 'url("http://unsplash.com/photos/Kwi60PbAM9I/download?force=true")');
      //Set different background image
      break;
    case "cloudy":
      case "partly-cloudy-day":
       $('body').css("background-image", 'url("http://unsplash.com/photos/KFnu4Y0uNJA/download?force=true")');
      break;
    case "clear-night":
      case "partly-cloudy-night":
     $('body').css("background-image", 'url("http://unsplash.com/photos/wGC7lGah18E/download?force=true")');
      break;
    case "snow":
      case "sleet":
      $('body').css("background-image", 'url("http://unsplash.com/photos/n1h2kVc549c/download?force=true")');
      break;
    case "wind":
        $('body').css("background-image", 'url("http://unsplash.com/photos/kmF_Aq8gkp0/download?force=true")');
      break;
   
}
     
     
   
   });
    
     
   });
                                              
});

 

    
    



  
 
              
            
!
999px

Console