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

            
              <script src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>

<div class="container-fluid">

<div class="row">
<h1>Local Weather App</h1>
</div> 

<div class="row">
<p id="location">Location</p>
</div> 

<div class="row kelvincelsius">
<p id="temperature">Temperature</p>
<p id="temp_sign" ></p>
</div> 
  
<div class="row">
<p id="description">Weather description</p>
</div> 

<div class="row">
<canvas id="icon" alt="weather_icon"></canvas>
</div>

<div class="row">
<p style="margin-top: 25px; font-size: 13px">Wrtitten and coded by: 
<a href="https://codepen.io/PipsChips/#" target="_blank" style="font-size: 15px">PipsChips</a>
</p>
<p><a href = "https://darksky.net/poweredby/" target="_blank">Powered by Dark Sky</a></p>
</div>

<div>
<img id="img1" src="https://media1.giphy.com/media/3oEjHGZkrolm9UgvM4/giphy.gif">
</div>
  
</div>
            
          
!

CSS

            
              body {  
  text-align: center;
}

h1 {
  margin-top: 50px;
}

#location {
  margin-top: 10px;
  font-size: 250%;
}

#temperature {
  font-size: 200%;
}

#temp_sign {
  font-size: 200%;
  color: blue;
}

#temp_sign:hover {
  color: red;
  font-size: 250%;
}

#description {
  font-size: 200%;
}

#icon {
  height: 10%;
  width: 10%;
}

.kelvincelsius p {
  display: inline-block;
  ertical-align: top;
}

#img1 {
  margin-top: 100px;
}




            
          
!

JS

            
              $(document).ready(function () {  
  
  $.getJSON('https://ipinfo.io/', function(data){
    console.log(data);
    var lati, long = "";    
    $("#location").html(data.city + ", " + data.country);    
    lati = data.loc.split(",")[0].toString();
    long = data.loc.split(",")[1].toString();
    getWeather(lati,long);
  }); 
  
  function getWeather (lati, long) {
    
    var url = "https://api.darksky.net/forecast/d0dc4eac57ce86b331955e710495abbe/" + lati + "," + long + "?callback=?";
    
    $.getJSON(url, function showWeather(json) {
    console.log(json);  
    var fahr = (json.currently.temperature);
    var cels = Math.round((json.currently.temperature - 32)*(5/9)*100)/100;
    
    var weatherIcon = json.currently.icon; 
    console.log(weatherIcon);
    var skycons = new Skycons;
      
    switch (weatherIcon) {
      case "clear-day":
        skycons.set("icon", Skycons.CLEAR_DAY);      
        break;
      case "clear-night":
        skycons.set("icon", Skycons.CLEAR_NIGHT);      
        break;
      case "partly-cloudy-day":
        skycons.set("icon", Skycons.PARTLY_CLOUDY_DAY);      
        break;
      case "partly-cloudy-night":
        skycons.set("icon", Skycons.PARTLY_CLOUDY_NIGHT);      
        break;
      case "cloudy":
        skycons.set("icon", Skycons.CLOUDY);
        break;
      case "rain":
        skycons.set("icon", Skycons.RAIN);
        break;
      case "sleet":
        skycons.set("icon", Skycons.SLEET);
        break;
      case "snow":
        skycons.set("icon", Skycons.SNOW);
        break;
      case "wind":
        skycons.set("icon", Skycons.WIND);
        break; 
      case "fog":
        skycons.set("icon", Skycons.FOG);          
    }      
    skycons.play();  
      
    $("#temperature").html(cels + " ");
    $("#temp_sign").html("&#8451");       
    $("#temp_sign").click(function() {
      if ($("#temperature").html() == cels + " ") {
        $("#temperature").html(fahr + " ");
        $("#temp_sign").html("&#8457");  
      }
      else {
        $("#temperature").html(cels + " ");
        $("#temp_sign").html("&#8451");
      }
    });
    
  $("#description").html(json.currently.summary);     
  });
    
  }  // function getWeather() --> CLOSE
  
}); // $(document).ready(function()) --> CLOSE
                 
            
          
!
999px

Console