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="container-fluid">
  <div class="row">
    <div class="col text-center">
      <h1>Local Weather App</h1>
    </div>
  </div>
  <div class="col text-center">
    <div class="weather-box">
      <div id="icon"></div>
      <p>Location: <span id="location"></span></p>
        <p>Temperature: <span class="temp" id="temp"></span></p>
        <p>Humidity: <span id="hum"></span></p>
        <p>Weather: <span id="over"></span></p>
        <p>Description: <span id="script"></span></p>
        <p>Wind Speed: <span id="wind"></span></p>
    </div>
  </div>
</div>
</div>

<!--FOOTER BELOW THIS LINE -->
<!--USE THIS FOOTER ON EVERY PROJECT-->
<div class="container-fluid footer">
  <div class="row">
    <div class="col-xs-auto">
      <a href="https://github.com/Jamiemufu" target="_blank"><image class="footer-icons" src="https://image.flaticon.com/icons/png/512/25/25231.png"></image></a>
<a href="https://www.freecodecamp.org/jamiemufu" target="_blank"><image class="footer-icons" src="https://cdn.rawgit.com/Deftwun/e3756a8b518cbb354425/raw/6584db8babd6cbc4ecb35ed36f0d184a506b979e/free-code-camp-logo.svg"></image></a>
<a href="http://gmail.com" target="_blank"><image class="footer-icons" src="http://www.free-icons-download.net/images/email-icon-82461.png"></image></a><b><i> Jamiemufu</b></i>
    </div>
  </div>
</div>
<!--END OF FOOTER -->

              
            
!

CSS

              
                body {
  background-color: black;
  font-family: verdana;
  color: white;
}
h1 {
  font-size: 45px;
  text-align: center;
  color: limegreen;
  font-family: "Audiowide", cursive;
  margin-top: 2%;
}

.weather-box {
  margin: 10px auto auto auto;
  text-align: center;
  width: 40%;
  font-size: 18px;
  margin-bottom: 5em;
}
span {
  color: limegreen;
  font-size: 20px;
  font-style: italic;
}

.temp:hover {
  cursor: pointer;
}
#script {
  text-transform: capitalize;
}


h3 {
  text-align:right;
}

.footer-icons {
  height: 50px;
  width: 50px;
  background-color: limegreen;
  padding: 10px;
  margin-left: -3px;
}
.footer {
  position:fixed;
  bottom: 0;
  width: 100%;
  color: limegreen;
  background-color:black;
  font-family: verdana;
  font-size: 12px;
}
              
            
!

JS

              
                //decalre some global variables
var api = "https://fcc-weather-api.glitch.me/api/current?lat=";
var lat;
var long;
var currentTemp;
var far;

$(document).ready(function() { //on document load
  if (navigator.geolocation) { //if geolocation allowed
    navigator.geolocation.getCurrentPosition(function(position) { 
      var lat = position.coords.latitude; //store lat position
      var long = position.coords.longitude; //store long position
      getInfo(lat, long); //call getInfo function
    });
  } else {
    console.log("geolocation not supported"); //if not supported
  }
});

//function to get all the data and use it on the screen
function getInfo(lat, long) { //pass lat and long thrugh function
  var urlstring = api + lat + "&&lon=" + long; //decalre url variable to get location
  $.ajax({
    url: urlstring, //use this url
    success: function(data) { //successfull
      var icon = '"' + data.weather[0].icon + '"'; //this is the built in icons on API
      var overView = data.weather[0].main; //overview from object
      var desc = data.weather[0].description; //decirption
      //needed to use 2 variables. One for rounded and one for working out far conversion. Kept getting NAN when trying to use currentTemp rounded with Far
      var currentTemp = data.main.temp;
      var currentTempRounded = Math.round(currentTemp) + String.fromCharCode(176) + "C";
      var far = currentTemp * (9 / 5) + 32;
      var farRounded = Math.round(far) + String.fromCharCode(176) + "F";
      var name = data.name;
      var country = data.sys.country;
      var windSpeed = data.wind.speed;
      var humidity = data.main.humidity;
      //Put data in span locations....
      $("#icon").append("<image src=" + icon + "</image>");
      $("#location").text(name + ", " + country);
      $("#temp").text(currentTempRounded);
      $("#hum").text(humidity);
      $("#over").text(overView);
      $("#script").text(desc);
      $("#wind").text(windSpeed + "mph");
      //call the function to change the temp on click
      changeTemps(currentTempRounded, farRounded);
    }
  });
}
//Function to adjust the temperatures onclick
function changeTemps(currentTempRounded, farRounded) {
$("#temp").click(function() {
  if ($("#temp").text() == currentTempRounded){
  $("#temp").text(farRounded);}
  else{
    $("#temp").text(currentTempRounded);
  }

 });
}

              
            
!
999px

Console