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

              
                <div class="message"></div>

<div class="container-fluid">
  <div class="content">
    <div class="currentWeather">
      <div class="place"></div>
      <div class ="column">
      <div class="temperatureDiv"><h3 class="heading">Temp:</h3><p class="temperature"></p></div>
      </div>
      <div class="column">
      <div class="humidityDiv"><h3 class="heading">Humidity:</h3><p class="humidity"></p></div>
      </div>
      <div class="clearfloats"></div>
      <div class="briefDiv"><h3 class="heading"></h3><p class="brief"></p></div>
      <div class="descriptionDiv"><h3 class="heading"></h3><p class="description"></p></div>
      <!-- <div id="icon"></div> -->
    </div>
    <div class="options">
      <a class="btn btn-primary" id="swapCF">C/F</a>
    </div>
  </div>

</div>
              
            
!

CSS

              
                
html {  

}

body {
/*   font-family: "Verdana", sans-serif; */
  font-family:"Open Sans", Arial;
  font-weight:100;
  margin:0px;
  padding:0px;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;

}

#swapCF{
  border: 2px solid white;
  border-radius:8px;
  background-color: rgb(0,0,0,0);
}

#swapCF:hover{
  background-color: rgb(0,0,0,0.25);
}

.place {
  font-size:50px;
}

.temperature, .humidity {
  font-size:30px;
  margin:0px;
  line-height:1em;
  padding-bottom:10px;
}

.heading {
  margin:0px;
}

h3 {
  font-size:20px;
}
.content{
  text-align:center;
  margin:auto;
/*   margin-top:15%; */
  max-width:400px;
  min-width:200px;
  background:rgb(69, 107, 168, 0.3);
  padding: 20px;
  border: 0px solid white;
  border-radius: 7px;
  color:white;
  box-shadow:0px 0px 100px 5px white;
  position: absolute;
/*      margin: auto; */
     top: 0;
     right: 0;
     bottom: 0;
     left: 0;
/*      width: 100px; */
     height: 280px;
}

.clearfloats {
  clear:left;
}

.tempKind {
  font-size:18px;
}

.column {
  width:50%;
  float:left;
}

.options{
  
}
.currentWeather{
/*   height:175px; */
}

.container-fluid {
/*   background-color:red; */
  padding: 50px;
}
              
            
!

JS

              
                
$(document).ready(function() {
  navigator.geolocation.getCurrentPosition(function(location) {
    var lon = location.coords.longitude;
    var lat = location.coords.latitude;
    // var lon = -76.7406721;
    // var lat = 38.9602881;
    
    // console.log(lon);
    // console.log(lat);

    var API =
      "https://fcc-weather-api.glitch.me/api/current?lon=" + lon + "&lat=" + lat;
    // console.log(API);

    //Opens FCC weather API

    $.getJSON(API, function(json) {
      // console.log(json);

      var rawTemp = json.main.temp;
      var fixTemp = rawTemp;
      var tempKind = "c";

      function convertTemp(C) {
        if (tempKind === "c") {
          var T = C * 1.8 + 32;
          tempKind = "f";
          fixTemp = T;
          return fixTemp;
        } else {
          var T = (C - 32) / 1.8;
          tempKind = "c";
          fixTemp = T;
          return fixTemp;
        }
      }
      
      convertTemp(fixTemp);
      
      var temperature = fixTemp;
      var humidity = json.main.humidity;
      var brief = json.weather[0].main;
      console.log(brief);
      // var brief = "Clear";
      var description = json.weather[0].description;
      var place = json.name;
      var icons = json.weather[0].icon;

      //Randomize background images
      function randomizeImage(condition){
        
// number generator
      function randomNumber(min,max){
        return Math.floor(Math.random() * (max - min) + min);
      }
        
        var rainUrls = ['https://images.unsplash.com/photo-1487762488615-8a011458b53e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=3008819eae6e8e6e82675619ba1a48fd&auto=format&fit=crop&w=1567&q=80','https://images.unsplash.com/photo-1485797460056-2310c82d1213?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=80022edfa67ee90440f01350c6e1a156&auto=format&fit=crop&w=1500&q=80','https://images.unsplash.com/photo-1509041487337-74a81a42e9d8?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6ab44bdf519218449a090c4e7335ae13&auto=format&fit=crop&w=1500&q=80'];
        //Rain done
        var clearUrls = ['https://images.unsplash.com/photo-1474059060963-44710306956c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=cab105717c6e890e7362b8593a607b0e&auto=format&fit=crop&w=1510&q=80','https://images.unsplash.com/photo-1519398799687-5edacbb4815a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=da31fd46588fc9a1dbf6e4ba00488f7e&auto=format&fit=crop&w=1500&q=80','https://images.unsplash.com/photo-1464495310703-83aac94583ee?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=d5327053dfd4398eb9800b31ec05f0d9&auto=format&fit=crop&w=1567&q=80'];
        //Clear done
        var drizzleUrls = ['https://images.unsplash.com/photo-1485134532658-d720895a3b5e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=0a567162e2fc65dff05c82334953eb38&auto=format&fit=crop&w=1053&q=80', 'https://images.unsplash.com/photo-1511799952331-858a5fdb31cd?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=aba8f54735a7b16ef1f64350747655ef&auto=format&fit=crop&w=1567&q=80', 'https://images.unsplash.com/photo-1492227982298-644b223e666d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a1c0afa43d33a3900e09400bd22f77b0&auto=format&fit=crop&w=1500&q=80'];
        //Drizzle done
        var cloudsUrls = ['https://images.unsplash.com/photo-1505832573663-4771041870d0?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=10fe0977dbc093e29189d7b106bb364f&auto=format&fit=crop&w=1500&q=80','https://images.unsplash.com/photo-1518277748204-ba05cb84d9f5?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9ea3b1a82b08a4ba9764a8788c9cdaaa&auto=format&fit=crop&w=1498&q=80','https://images.unsplash.com/photo-1511680321409-d92a85fc4f66?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9701fc643680b39a1682e2efe3512b01&auto=format&fit=crop&w=1506&q=80'];
        //Clouds Done
        var snowUrls = ['https://images.unsplash.com/photo-1468476775582-6bede20f356f?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=ee24ef8412027b4f9b1d631bba413f25&auto=format&fit=crop&w=1532&q=80','https://images.unsplash.com/photo-1515080496064-bf1309a108f6?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9d2a3925566808b19b4fd7da8b343098&auto=format&fit=crop&w=1500&q=80','https://images.unsplash.com/photo-1427955569621-3e494de2b1d2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=54078fb00185b26eea7707139e3c5de1&auto=format&fit=crop&w=1500&q=80'];
        //Snow done
        var thunderstormUrls = ['https://images.unsplash.com/photo-1461511669078-d46bf351cd6e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=54722f2a0c22a81fe5361e46ef625a13&auto=format&fit=crop&w=1500&q=80', 'https://images.unsplash.com/photo-1504123010103-b1f3fe484a32?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a61d36db98daa7dc6010b1159e69a3c8&auto=format&fit=crop&w=1500&q=80','https://images.unsplash.com/photo-1500674425229-f692875b0ab7?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=98b22b953b66ec5c2370537e342c46cf&auto=format&fit=crop&w=1500&q=80'];
        //Thunderstorms done
        var mistUrls = ['https://images.unsplash.com/photo-1496286069291-1a0c6b13f4ae?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=088518efbd32c4dfaf1fe6a5f603975c&auto=format&fit=crop&w=1050&q=80','https://images.unsplash.com/photo-1446104838475-bc6508184f08?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=d17594aa67af9dc6efc427dbd1324318&auto=format&fit=crop&w=1510&q=80','https://images.unsplash.com/photo-1513282276619-951d6c2285cb?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=0da2c9c2df11f738f6b5ff64cca8950d&auto=format&fit=crop&w=1500&q=80'];
        //Mist done
        var hazeUrls = ['https://images.unsplash.com/photo-1487454323353-9b88981d3846?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=df2d33014ed382df4006bbce349cbdab&auto=format&fit=crop&w=2700&q=80', 'https://images.unsplash.com/36/STzPBJUsSza3mzUxiplj_DSC09775.JPG?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=ceae180f652c22cce1a004b1706c412b&auto=format&fit=crop&w=2684&q=80','https://images.unsplash.com/photo-1470010553688-8e1aa13f066b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=392420226c2a21afe77f6a197e743c0b&auto=format&fit=crop&w=1474&q=80'];
        //Haze done
        
        if(condition === "Rain"){
          $("body").css(
            "background",
            "url(" + rainUrls[randomNumber(0,rainUrls.length)] + ") no-repeat center center fixed"
          );
          
          //Fixed Rain Backgrounds
          
        } else if (condition === "Clear") {
           $("body").css(
            "background",
            "url(" + clearUrls[randomNumber(0,clearUrls.length)] + ") no-repeat center center fixed"
          );
          
          // Fixed Clear Backgrounds
          
        } else if (condition === "Drizzle") {
           $("body").css(
            "background",
            "url(" + drizzleUrls[randomNumber(0,drizzleUrls.length)] + ") no-repeat center center fixed"
          );
          
          // Fixed Drizzle Backgrounds
          
        } else if (condition === "Clouds") {
           $("body").css(
            "background",
            "url(" + cloudsUrls[randomNumber(0,cloudsUrls.length)] + ") no-repeat center center fixed"
          );
          
          //Fixed Clouds Backgrounds; make the rest reflect
          
        } else if (condition === "Snow") {
           $("body").css(
            "background",
            "url(" + snowUrls[randomNumber(0,snowUrls.length)] + ") no-repeat center center fixed"
          ); 
          
          //Fixed Snow Backgrounds
          
        } else if (condition === "Thunderstorm") {
           $("body").css(
            "background",
            "url(" + thunderstormUrls[randomNumber(0,thunderstormUrls.length)] + ") no-repeat center center fixed"
          );
          
          //Fixed Thunderstorm Backgrounds
          
        } else if (condition === "Mist") {
           $("body").css(
            "background",
            "url(" + mistUrls[randomNumber(0,mistUrls.length)] + ") no-repeat center center fixed"
          );        
          
          // Fixed Mist Backgrounds
          
        } else if (condition === "Haze") {
           $("body").css(
            "background",
            "url(" + hazeUrls[randomNumber(0,hazeUrls.length)] + ") no-repeat center center fixed"
          );
          
          //Fixed Haze Backgrounds
          
          console.log(randomNumber(0,hazeUrls.length))
        }                    
      };
      console.log(brief);
      randomizeImage(brief);
      
      $(".place").html(place);
      $(".temperature").html(Math.floor(fixTemp) + '<span class ="tempKind">' + tempKind + '</span>');
      $(".humidity").html(humidity);
      $(".brief").html(brief + ", " + description);
      // $(".description").html(description);
      // $("#icon").html('<img src="'+icons+'">');

      $("#swapCF").click(function() {
        $(".temperature").html(
          Math.floor(convertTemp(fixTemp)) + '<span class ="tempKind">' + tempKind + '</span>'
        );
        


      });
    });
  });
});


              
            
!
999px

Console