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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <body>
<div class = "container-fluid">
  

<img id="icon" src = "">

<p id = "header">Weather</p>

<p id = "temp">Temperature</p>
<button id="button" class = "btn-primary">Celsius/Fahrenheit</button>

<p id="long">Longitude</p>
<p id="lat">Latitude</p>
<p id="city">City</p>
<p id="country">Country</p>

<!--<p id="test">Test</p>
  <p id = "icontest">IconTest</p>
  <p id= "loctest">LocationTest</p>
  -->

  </div>
  </body>

              
            
!

CSS

              
                body{
/*  background-color: rgb(0,0,0);*/
background-image: url("http://static.pexels.com/photos/28215/pexels-photo.jpg");
 
  -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
  background-positon: center;
  background-size: cover;
  text-align: left;
  margin:0;
  padding:0;
  
  /*
  min-height: 100%;
  min-width: 1024px;
  
  width:100%;
  height: auto;
  
  position: fixed;
  top: 0;
  left: 0;
*/
}


p {
  color: rgb(255,255,255);
  font-weight: bold;
}
              
            
!

JS

              
                $(document).ready(function(){

  //API for location  
      $.getJSON("http://ip-api.com/json", function(json) {
   

    
    var long = JSON.stringify(json.lon);
    $("#long").html(long);

    var lat = JSON.stringify(json.lat);
    $("#lat").html(lat)

    $("#icontest").html("http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+long+"&appid=a574f0d98f8e459239c30ea0ae5fc64f");
    
        $("#idk").html("Yes");
        
    var city = JSON.stringify(json.city);
    var cLen = city.length
    city = city.slice(1,cLen-1);
    
    $("#city").html(city);
    
    var country = JSON.stringify(json.countryCode);
    var coLen = country.length
    country = country.slice(1,coLen-1);
    
    $("#country").html(country);
    
    
  
  //gets web address based on your long/lat  
  var address = "http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+long+"&appid=a574f0d98f8e459239c30ea0ae5fc64f"; 
 
   document.getElementById("lat").innerHTML = lat;
document.getElementById("long").innerHTML = long;
  
  
  $.getJSON(address, function(json) {
//Weather description
var weather = JSON.stringify(json.weather[0].description);
    
    
var wLen = weather.length;
weather = weather.slice(1,wLen-1);
var wFirst = weather.charAt(0).toUpperCase();
var wRest = weather.slice(1,wLen-2);
var wJoined = wFirst+wRest;      
    
$("#header").html(wJoined);

//Icon
var icon = JSON.stringify(json.weather[0].icon);

icon = icon.slice(1,4);
$("#icon").html(icon);
      
      var icon2 = "http://openweathermap.org/img/w/"+icon+".png"      
  
        document.getElementById("icon").src = icon2;
      
//Temperature
var temp = JSON.stringify(json.main.temp);
var celsius = Math.round((temp-273.15)*10)/10;
    var celsius1 = celsius + '&deg'+"C";
var fahr = Math.round((celsius * 9/5 + 32)*10)/10;
var fahr1 = fahr+'&deg'+"F";
    
$("#temp").html(celsius1);
var temp1 = celsius1;
      
//toggle button
    $("#button").click(function(){
        if(temp1==celsius1){ $("#temp").html(fahr1);
temp1=fahr1;}
      else {$("#temp").html(celsius1);
            temp1=celsius1;}

    
    });  //ends toggle button function
var mainId = JSON.stringify(json.weather[0].id);
    
    var id = 0;
    var daytime;
    daytime = icon.charAt(2);
    
        if(mainId == "800"){id = mainId;} else {id = mainId.charAt(0);};
    
    var code = mainId+daytime;
    
  $("#test").html(id);
    

switch(code){
//thunder day
  case "2d":
    $("#test").html("thunder day");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/99577/barn-lightning-bolt-storm-99577.jpeg)');
    break;
    //thunder night
    case "2n":
    $("#test").html("thunder night");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/24660/pexels-photo.jpg)');
    break;
    
    //drizzle day
  case "3d":
    $("#test").html("drizzle day");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/197112/pexels-photo-197112.jpeg)');
    break;
    
    //drizzle night
      case "3n":
    $("#test").html("drizzle night");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/315191/pexels-photo-315191.jpeg)');
    break;
    
    //rainy day
  case "5d":
    $("#test").html("rainy day");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/17739/pexels-photo.jpg)');
    $('p').css('color','rgb(0,0,0)');
    break;
    
    //rainy night
      case "5n":
    $("#test").html("rainy night");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/7467/pexels-photo.jpeg)');
    break;
    
    //snow day
  case "6d":
    $("#test").html("snowy day");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/202105/pexels-photo-202105.jpeg)');
    
    break;
    
    //snow night
    case "6n":
    $("#test").html("snowy night");
    $('body').css('background-image', 'url(https://static.pexels.com/photos/24639/pexels-photo-24639.jpg)');
    
    break;
    
  //clear & sunny day
  case "800d":
    $("#test").html("clear & sunny day");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/28215/pexels-photo.jpg)');
    $('p').css('color','rgb(0,0,0)');
  break;
    //clear night
    case "800n":
    $("#test").html("clear night");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/107958/pexels-photo-107958.jpeg)');
    break;
    
    //cloudy day
  case "8d":
    $("#test").html("cloudy day");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/1780/landscape-nature-clouds-cloudy.jpg)');
    break;
    
    //cloudy night
      case "8n":
    $("#test").html("cloudy night");
    $('body').css('background-image', 'url(https://static.pexels.com/photos/316874/pexels-photo-316874.jpeg)');
    break;
    
    
  default:
    $("#test").html("Default");
    $('body').css('background-image', 'url(http://static.pexels.com/photos/45848/kumamoto-japan-aso-cloud-45848.jpeg)');
    
               
               } //ends switch
    
    
    $("#loctest").html(code);
    
    
   });  //ends navigation getjson 
    
    
}); //ends weather detail getjson

});  //ends all
  

              
            
!
999px

Console