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

Packages

Add 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 or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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>
  <head>
  <link href='https://fonts.googleapis.com/css?family=Sriracha' rel='stylesheet'>
  </head>
<body>

  

 <div class="wrapper">
  <div class="container">  
    <div class="row"><h1>International Weather App</h1></div>
    <div class="row"><div class="col-sm-12"><p id="time"></p></div></div>
    <div class="row dataRow"><div class="col-sm-12"><p id="userData"></p></div></div>
    <div class="row dataRow" id="mainRow">
      <div class="col-sm-6"><p id="temperature"></p></div>
      <div class="col-sm-6"><p id="weatherIcon"></p></div>
    </div>
    <div class="row dataRow">
      <div class="col-sm-6"><p id="summary"></p></div>
      <div class="col-sm-6"><p id="daySummary"></p></div>
        
    </div>
    <div class="row buttonRow">
      
        <div class="btn-group btn-group-justified">
          <div class="btn-group"><button type="button" id="tokyo" class="btn btn-info">Tokyo</button></div>
          <div class="btn-group"><button type="button" id="sydney" class="btn btn-info">Sydney</button></div>
          <div class="btn-group"><button type="button" id="moscow" class="btn btn-info">Moscow</button></div>
          <div class="btn-group"><button type="button" id="nyc" class="btn btn-info">NYC</button></div>
          <div class="btn-group"><button type="button" id="sanFran" class="btn btn-info">San Francisco</button></div>
          <div class="btn-group"><button type="button" id="london" class="btn btn-info">London</button></div>
          <div class="btn-group"><button type="button" id="home" class="btn btn-info">My Location</button></div>
          
        </div>
 
    </div>
    <div class="row dataRow">
      <div class="col-sm-12"><button id="converter" class="btn btn-info">Convert F/C</button></div>
      <!-- <div class="col-sm-4"><button id="tester" class="btn-default">Test it!</button></div>-->
      <div class="col-sm-12"><p id="darkSkyLink"><a href="https://darksky.net/poweredby/">Powered by Dark Sky</a><p></div>
   </div>
 </div>
</div>
</body>
</html>

            
          
!
            
              body{
  font-family: Sriracha;
  background-size: 100%;
  color: white;
  text-shadow: 1px 1px 4px #000000;
  /*background-image: url('http://imgur.com/H2FDNdZ.jpg')*/
}
#userData{
  text-align: center;
  font-size: 3.5vw;
  text-shadow: 1px 1px 4px #000000;
}
#darkSkyLink{
  text-align: center;
  text-shadow: none;
}
.container{
  width: 70%;
  background: rgba(180, 180, 180, 0.6)
}
/*
.wrapper{
  margin: 0 auto;
  margin-top: 20px;
  width:60%;
  background: rgba(180, 180, 180, 0.6);
  border-radius: 10px;
  border-style: solid;
  border-width: 2px;
  border-color: white;
} */
/*
.buttonRow{
  padding: 10px;
  margin: 0 auto;
  text-align: center;
  width: 100%;
} */
.top{
  padding-top:5px;
  width:100%;
}
.dataRow{
  margin: 0 auto;
  width:100%;
  text-align:center;
  opacity: 1;
}
#temperature{
  padding-top:20px;
  font-size:6vw;
  border-bottom: 1px solid;
  
}
/*
#mainRow{
  height: 200px;
  font-size: 2vw;
}*/
/*
h1{
  margin:20px auto;
  width:100%;
  text-align:center;
  padding:1px;
  text-transform:uppercase;
  font-size:3vw;
  letter-spacing:1px;
  border-top:1px solid;
  border-bottom:1px solid;
}*/
#weatherIcon{
  padding-top: 20px;
  font-size:6vw;
  border-bottom: 1px solid;
}
#converter{
  opacity: 100%;
}
#summary{
  font-size: 1.5vw;
}
#daySummary{
  font-size: 1.5vw;
}
            
          
!
            
              $(document).ready(function(){
//document.body.style.backgroundImage = "url('http://imgur.com/H2FDNdZ.jpg')";
if (navigator.geolocation){
  navigator.geolocation.getCurrentPosition(showPosition);
} else {
  alert("Geolocation not supported by this browser")
}
  function showPosition(position){
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var latLon = latitude + "," + longitude;
    var locLookUpURL = "https://nominatim.openstreetmap.org/reverse?format=json&lat=" + latitude + "&lon=" + longitude + "&zoom=18&addressdetails=1";
    var darkSkyURL = "https://crossorigin.me/https://api.darksky.net/forecast/61f348d275ade97e861955de88616ae0/" + latLon;
    
    $.getJSON(locLookUpURL, function(data){
      var city = data.address.city;
      var state = data.address.state;
      //console.log("city: " + city);
      $("#userData").html(city + ", " + state);
    });

    $.getJSON(darkSkyURL, function(data){
      var temp = Math.round(data.currently.temperature);
      var loc = data.timezone;
      var summary = data.currently.summary;
      var unit = "F";
      var icon = data.currently.icon;
      var daySummary = data.daily.summary;
      $("#temperature").html(temp + "&#176F");
      $("#summary").html(summary);
      $("#daySummary").html(daySummary);
      
      // $("#icon").html("The icon is: " + icon);
      BackgroundChange(icon);
      $("#converter").on("click", function(){
        if(unit == "F"){
          ConvertToCelsius(temp);
          unit = "C"
        } else if (unit == "C"){
          ResetToF(temp);
          unit = "F"
        }
      }); // end onClick
      $("#tester").on("click", function(){
        var bgArray = ["clear-day", "clear-night", "rain", "snow", "sleet", "wind", "fog", "cloudy", "partly-cloudy-day", "partly-cloudy-night"];
        var rnd = Math.floor(Math.random() * 10);
       
        var tester = bgArray[rnd];
        //console.log(tester);
        BackgroundChange(tester);
      })// end tester
    }); // end getJSON DarkSky
  } // end showPosition Function
  
  function ConvertToCelsius(temperature){
    var convertedTemp = (temperature - 32) * (5/9);
    convertedTemp = Math.round( convertedTemp * 10 ) / 10;
    //console.log("Converted Temp:" + convertedTemp);
    $("#temperature").html(convertedTemp + "&#176C");
  } // end Convert to Celsius Function
  
  function ResetToF(temperature){
    $("#temperature").html(temperature + "&#176F");
  } // end Revert function
  
  function BackgroundChange(iconValue){
    switch (iconValue){
      case "clear-day":
        document.body.style.backgroundImage = "url('http://i.imgur.com/rxVwpt0.jpg')";
        $("#weatherIcon").html("<i class='wi wi-day-sunny'></i>");
        break;
      case "partly-cloudy-day":
        document.body.style.backgroundImage = "url('http://i.imgur.com/H2FDNdZ.jpg')";
        $("#weatherIcon").html("<i class='wi wi-day-sunny-overcast'></i>");
        break;
      case "rain":
        document.body.style.backgroundImage = "url('http://i.imgur.com/KWzG0Gt.jpg')";
        $("#weatherIcon").html("<i class='wi wi-day-rain'></i>");
        break;
      case "clear-night":
        document.body.style.backgroundImage = "url('http://i.imgur.com/FUOa5iJ.jpg')";
        $("#weatherIcon").html("<i class='wi wi-night-clear'></i>");
        break;
      case "snow":
        document.body.style.backgroundImage = "url('http://i.imgur.com/zvhn4Fw.jpg')";
        $("#weatherIcon").html("<i class='wi wi-snow'></i>");
        break;
      case "sleet":
        document.body.style.backgroundImage = "url('http://i.imgur.com/SKSxFd8.jpg')";
        $("#weatherIcon").html("<i class='wi wi-sleet'></i>");
        break;
      case "wind":
        document.body.style.backgroundImage = "url('http://i.imgur.com/R7dDHa1.jpg')";
        $("#weatherIcon").html("<i class='wi wi-strong-wind'></i>");
        break;
      case "fog":
        document.body.style.backgroundImage = "url('http://i.imgur.com/9Fl8g8x.jpg')";
        $("#weatherIcon").html("<i class='wi wi-fog'></i>");
        break;
      case "cloudy":
        document.body.style.backgroundImage = "url('http://i.imgur.com/IhLGIrU.jpg')";
        $("#weatherIcon").html("<i class='wi wi-day-cloudy'></i>");
        break;
      case "partly-cloudy-night":
        document.body.style.backgroundImage = "url('http://i.imgur.com/abHtVdw.jpg')";
        $("#weatherIcon").html("<i class='wi wi-night-partly-cloudy'></i>");
        break;
      default: 
        document.body.style.backgroundImage = "url('http://i.imgur.com/rxVwpt0.jpg')";
    } // end switch
  } // end backgroundChanger
  
  function CityChanger(lat, lon, offset){
    var latLon = lat + ", " + lon;
    var locLookUpURL = "https://nominatim.openstreetmap.org/reverse?format=json&lat=" + lat + "&lon=" + lon + "&zoom=18&addressdetails=1";
    var darkSkyURL = "https://crossorigin.me/https://api.darksky.net/forecast/61f348d275ade97e861955de88616ae0/" + latLon;
    
    
    
    $.getJSON(darkSkyURL, function(data){
      var temp = Math.round(data.currently.temperature);
      var loc = data.timezone;
      var summary = data.currently.summary;
      var unit = "F";
      var icon = data.currently.icon;
      var daySummary = data.daily.summary;
      $("#temperature").html(temp + "&#176F");
      $("#summary").html(summary);
      $("#daySummary").html(daySummary);
      
    $.getJSON(locLookUpURL, function(data){
      var city = data.address.city;
      var state = data.address.state;
      //console.log("city: " + city);
      $("#userData").html(city + ", " + state);
    });
      
      BackgroundChange(icon);
      $("#converter").on("click", function(){
        if(unit == "F"){
          ConvertToCelsius(temp);
          unit = "C"
        } else if (unit == "C"){
          ResetToF(temp);
          unit = "F"
        }
      }); // end onClick
      $("#tester").on("click", function(){
        var bgArray = ["clear-day", "clear-night", "rain", "snow", "sleet", "wind", "fog", "cloudy", "partly-cloudy-day", "partly-cloudy-night"];
        var rnd = Math.floor(Math.random() * 10);
       
        var tester = bgArray[rnd];
        //console.log(tester);
        BackgroundChange(tester);
      })// end tester
    }); // end getJSON DarkSky
  }
  // location buttons
  $("#tokyo").on("click", function(){
    CityChanger("35.652832", "139.839478", 32400);
  });
  $("#sydney").on("click", function(){
    CityChanger("-33.865143", "151.209900", 36000);
  });
  $("#moscow").on("click", function(){
    CityChanger("55.752121", "37.617664", 10800);
  });
  $("#nyc").on("click", function(){
    CityChanger("40.730610", "-73.935242", 14400);
  });
  $("#sanFran").on("click", function(){
    CityChanger("37.733795", "-122.446747", 25200);
  });
  $("#london").on("click", function(){
    CityChanger("51.501476", "-0.140634", 3600);
  });
  $("#home").on("click", function(){
    navigator.geolocation.getCurrentPosition(showPosition);
  });
  
}); //end Document Ready
            
          
!
999px

Console