cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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>
	<head>
<link href="https://fonts.googleapis.com/css?family=BioRhyme|Bungee" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
</head>
	
<body id="bgcolor">
 <div id="main-content" class="header">
  <div>
   <form action="" class="tempswitch">
    <input name="temp" type="radio" onclick="tempC();" > Celcius<br>
    <input name="temp" type="radio" onclick="tempF();"> Fahrenheit<br>
   </form>
   <h1 class="title"> Local Weather </h1>
  </div>
 </div>
	
 <div class="weatherinfo">
  <div id="wrap">
   <h2 id="weather"></h2>
  </div>
  <div id="wrap">
   <h2 id="temp"></h2>
   <h2 id="inner"></h2>
  </div>
	 <div> 
	 
  <h2 id="location">location</h2>
		 <canvas class="iconclass" id="iconid" width="64" height="64">
 </div>
	
	<a href = https://darksky.net/poweredby/ >Powered by Dark Sky </a>

</body>


    
</html>
            
          
!
            
                    body {
              }
#bgcolor {
  background-color: pink;
}
  .header {
    background-color:yellow;
    text-align: center;
    width: 100%;
    padding: 1% 0;
  }

      
      h1 {
        font-family: 'Bungee', cursive;
        text-align: center;
        font-weight: bold;
        font-size: 40px;
      }
.title {
   width: 400px;
   margin: 0px auto;
}

.tempswitch {
  float: right;
  color: grey;
  font-family: 'Bungee', cursive;
  width:150px;
  .label {
    float: left;
  }
  
}
      
      h2 {
        font-family: 'BioRhyme', serif;
        text-align: center;
        font-weight: bold;
        font-size: 30px;
        margin-top: 0;
        margin-bottom: 0;
      }
      
      #wrap {
        text-align: center;
      }
      
      #icon,
      #weather,
      #temp,
      #inner {
        display: inline-block;
      }
      
      h3 {
        font-family: 'David Libre', serif;
        font-size: 40px;
      }
      
      p {
        font-family: 'Athiti', sans-serif;
        padding: 0 10% 0 10%;
        font-size: 18px;
      }
      
      #main-content {
/*         padding: 20px 20px 20px 20px; */
        border-radius: 10px;
/*         margin: 20px 20px 20px 20px; */
      }
      
      .weatherinfo {
        background-color: lightblue;
        border-radius: 10px;
      }

.iconclass {
	margin-left: auto;
    margin-right: auto;
    display: block;
}




      
/*       .button {
        background-color: #66ffcc;
        border: none;
        border-radius: 5px;
        color: white;
        padding: 15px 32px;
        text-align: center;
        text-decoration: none;
        display: block;
        margin: auto;
        font-size: 16px;
        cursor: pointer;
        -webkit-transition-duration: 0.4s;
        transition-duration: 0.4s;
      }
      
      .button:hover {
        box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
      }
      
      .button:active {
        transform: scale(0.95);
      }  */
            
          
!
            
              // Global variables underneath

var api_Key = "e4ee4e08479f304c27ed35b06b56f873";
var loc0, loc1, currentTempFaherenheit, currentTempCelcius, weatherIcon;

$(document).ready(function(){
  // Gets the current location in degrees and prints the location: city and region.
  $.getJSON("https://ipinfo.io", function(data){
	  var city = data.city;
	  var region = data.region;
	  $("#location").html(city + ", " + region); // @Todo do not replace location but instead make the text "your current location is:"
	  
	  
	  var loc = data.loc;
	  var locArray = loc.split(",");
	  loc0 = locArray[0];
	  loc1 = locArray[1];
	  
	  $.getJSON("https://api.darksky.net/forecast/" + api_Key + "/" + loc0 + "," + loc1 + "?callback=?", function(data){

		   currentTempFaherenheit = Math.round(data.currently.temperature);
		   currentTempCelcius = Math.round((currentTempFaherenheit - 32) * 5/9);
		   weatherIcon = data.currently.icon;
		   $('.iconclass').attr('id', weatherIcon);
		   
// This will add the icons available for use.
var icons = new Skycons(),
  list  = [
    "clear-day", "clear-night", "partly-cloudy-day",
    "partly-cloudy-night", "cloudy", "rain", "sleet", "snow", "wind",
     "fog"
   ],
       i;
      for(i = list.length; i--; )
        icons.set(list[i], list[i]);
      icons.play();
		   
		  
		   
  });
  });  
});

// This is triggered by the radiobutton with ID: #temp.

var tempC = function() {
  $("#temp").text(currentTempCelcius + "C");
};

var tempF = function() {
   $("#temp").text(currentTempFaherenheit + "F");
};








	  



 






            
          
!
999px
Loading ..................

Console