Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm 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. We'll also process your JavaScript with Babel.

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

Code Indentation

     

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.

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.

            
              <div id="#about" class="text-center">
  <div class="row">
    <div class="col-sm-8 col-sm-offset-2"><h1>Mike's 5 Day Weather Forecast</h1>
      <hr class="fancy-line"/>
    </div>
    <div class=" temp-btn-con col-sm-2">
      <button class="btn temp-btn">Convert Temp<br>to Celcius</button></div>
    </div>
    <div>
      <div class="box block-center"></div>
      <div class="col-xs-12"><a class="text-center" href="https://darksky.net/poweredby/"> Powered by Dark Sky</a></div>
  </div>
  <link href="https://fonts.googleapis.com/css?family=Architects+Daughter|Lobster" rel="stylesheet">
  </link>
  <script         src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>
</div>
<!--<figure id="index' + [i] + '" class="col-xs-2">
  <h3></h3>
  <canvas class="icon" width="64" height="64"></canvas>
  <p id="current">Summary:</p>
  <span class="current"></span>
  <class="temp-cont">
      <p style="width:100%;display:block;">Temp:</p>
      <span class="half-w tempMin"><span class="cF">F</span>°</span>
      <span class="half-w tempMax"><span class="cF">F</span>°</span>
    
    <p style="width:100%;display:block;">Heat Index:</p>
      
      <span class="half-w hIndexMin"><span class="cF">F</span>°</span>
      <span class="half-w hIndexMax"><span class="cF">F</span>°</span>
    
  </div> 
  </figure>-->

            
          
!
            
              html, body{
  font-family: 'Architects Daughter', cursive;
  color:#f9f9f9;
  background:url(https://www.justtinarealtor.com/wp-content/uploads/sites/1/2017/07/instagram.jpg);
    background-size: cover;
    height:100%;
    margin:0;
    padding:0;
  font-size:1.1em;
}
h1{
  font-family: 'Lobster', cursive;
}
hr.fancy-line{
  border-bottom:solid 2px #000;
  width:30%;
}
.box{
  display: flex;
  justify-content: center;
  
}
figure,.temp-btn {
  color:#999;
  border:solid #ff0  1px!important;
  background:rgba(0,0,0,.3);
  border-radius:15px;
  margin: 0 1em;
  text-shadow:1px 1px 1px #000;
  box-shadow:5px 5px 15px  rgba(20,20,20,.4);
}
span,.temps{
  color:#ff0;
}
.temps{
  margin-bottom:0;
}
figure:hover,.temp-btn:hover{
  color:#fff;
  background:rgba(0,0,0,.5);
  box-shadow:5px 5px 15px  rgba(20,20,20,.8);
}
.col-xs-2{
  
  
}
#index5, #index6, #index7{
  display:none; 
}
canvas:nth-child(){
  z-index:99;
}
#current{
  height:125px;
}
.half-w{
  display:inline-block;
  width:50%;
}

.temp-btn-con{
  height:100px;
  position:relative;
}
.temp-btn{
  border-radius:10px;
  position: absolute;
  top: 50%;
  left:50%;
  transform: translate(-50%,-50%);
  background:rgba(0,0,0,.4);
}
figure h3, .temp-btn{
  color:#fff!important;
}
.col-xs-12 a{
  color:#000;
}

            
          
!
            
              

  var icon;
  var current;
  var tempMin;
  var tempMax;
  var hIndexMin;
  var hIndexMax;
  var hIndexM;
  var dayName;
  var i = 0;
  var dmDays;
  var cF = "F";
  var temps = [tempMin,tempMax,hIndexMin,hIndexMax];
  var icons = new Skycons({"color": "orange"});
  icons.set("clear-day", Skycons.CLEAR_DAY);
  icons.set("clear-night", Skycons.CLEAR_NIGHT);
  icons.set("partly-cloudy-day", Skycons.PARTLY_CLOUDY_DAY);
  icons.set("partly-cloudy-night", Skycons.PARTLY_CLOUDY_NIGHT);
  icons.set("cloudy", Skycons.CLOUDY);
  icons.set("rain", Skycons.RAIN);
  icons.set("sleet", Skycons.SLEET);
  icons.set("snow", Skycons.SNOW);
  icons.set("wind", Skycons.WIND);
  icons.set("fog", Skycons.FOG);
  icons.play();
  function convertToF(f){
    f = (f * 1.8 + 32).toFixed(1);
  };
  function convertToC(c){
   c =  ((c -32) * 5/9).toFixed(1);
  };
  function clickConvert(){
    $(".temp-btn").on("click",function(){
      console.log(cF);
     if  (cF === "F"){       
         
          $(".temp-btn").html("Convert Temp<br>to Fahrenheit");
          //math
          cF = "C"; 
       } else if (cF === "C"){
          $(".temp-btn").html("Convert Temp<br>to Celcius");
          
          cF = "F";
       }
   
  });
  };
  
  
  navigator.geolocation.getCurrentPosition(function(position) {
    var lat = position.coords.latitude;
    var long = position.coords.longitude;  
    var apiUrl = ("https://thingproxy.freeboard.io/fetch/https://api.darksky.net/forecast/9604dc1ddeb95283966fa07dcce9fc96/" + lat + "," + long);
    
    $.ajax( {
    url: apiUrl, 
    success: function(json) {
      console.log(json);      
      dayName = ["Today","Tomorrow","Day 3","Day 4","Day 5","Day 6"];      
      dmDays = json.daily.data;
      $.each(dmDays, function(index, dmDays){
        
        icon = json.daily.data[i].icon;
        current = json.daily.data[i].summary;
        tempMin = Math.round(json.daily.data[i].temperatureMin);       
        tempMax = Math.round(json.daily.data[i].temperatureMax);
        hIndexMin = Math.round(json.daily.data[i].apparentTemperatureMin);
        hIndexMax = Math.round(json.daily.data[i].apparentTemperatureMax);
         //if  (cF == "C"){       
          convertToF(tempMin[i]);
          convertToF(tempMax);
          console.log(tempMin);
        // }
        $(".box").append(`
<figure id="index${[i]}" class="col-xs-2">
<h3><strong>${dayName[i]}</strong></h3>
<canvas class=${icon} width="64" height="64"></canvas>
<p id="current"><strong>Summary: </strong>${current}</p>

<p class="temps"><strong>Temp:</strong></p>
<span><span class="half-w">${tempMin}°${cF}/Min</span><span class="half-w">${tempMax}°${cF}/Max</span></span>
<p class="temps"><strong>Heat Index:</strong></p><span><span class="half-w">${hIndexMin}°${cF}/Min</span><span class="half-w">${hIndexMax}°${cF}/Max</span></span></figure>`); 
        icons.add($(icon)[icons]);
        i++;
        
      });
     }
   }        
 )}
)
clickConvert();
 

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console