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>
  <!--Cellphone Wrapper-->
  <div class="second-layer">
    <div>
      <h2><b>Simple Weather App</b></h2>
    </div>
    <div class="third-layer">
      <div>
        <h3 id='cityName'></h3> 
      </div>
      <div>
        <h4 id='countryName'></h4>
      </div>
      <div><img id='weatherIcon'></div>
      <div id='weatherType'></div>
      <div class='spacing'><button id='tempCel'></button>
      </div>
    </div>
  <!--Hide Latitude and Longitude
  <div id="data"></div> -->
  </div> <!--End of Cellphone Wrapper-->
  <!--In Small Print-->
  <div><p class="design">Design by Katherine Sirgey Yoon</p></div>
</body>


 
              
            
!

CSS

              
                html {
  margin: 0;
  padding-top: 150px;
  height: 100%;
}

body {
  height: 100%;
  font-family: Georgia;
  background-color: #C4D18B;
  color: #5B5A5A;
}

div {
  text-align: center;
}

h2 {
  padding-bottom: 12px;
}

.second-layer { /* Cell Phone */
  margin: auto;
  width: 300px;
  height: 400px;
  border: 3px solid #FFD394;
  border-radius: 10px;
  background-color: #FFF5D1;
  box-shadow: 2px 2px 5px 1.2px rgba(0, 0, 0, 0.2);
}

.third-layer { /* Screen */
  margin: auto;
  width: 240px;
  height: 254px;
  border: 3px solid #E4DBB9;
  border-radius: 10px;
  background-color: #F8F6F0;
  box-shadow: inset 1px 1px 2px 0.3px rgba(0, 0, 0, 0.3);
}

#weatherType {
  font-size: 18px;
  padding-top: 2px;
}

.spacing { /* Between Weather Type and Button */
  padding-top: 20px;
}

button {
  font-size: 20px;
  border-radius: 5px;
  outline: none;
  color: #000000;
  box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.5);
}

.design {
  padding-top: 10px;
  font-size: 10px;
}

              
            
!

JS

              
                $(document).ready(function() {
  
  //Obtain the latitude and longitude of the starting point of the request.
  if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    $("#data").html("latitude: " + position.coords.latitude + " longitude: " + position.coords.longitude);
    
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;

  //Using the positions, obtain current weather data about the area wherein the user made the request.
	$.ajax({
		type: "GET",
		url: "https://fcc-weather-api.glitch.me/api/current?lat=" + latitude + "&lon=" + longitude + "",
		success: weatherNow
	});
    
    });
    
  } else {
    alert("Your browser does not support Geolocation. Please download the latest version of Chrome or Firefox to view your weather data.");
  };
  
  //Situate the data (city, country, weather type, weather icon) on the website.
  function weatherNow(data) {
    $('#cityName').html(data.name);
    $('#countryName').html(data.sys.country);
    $('#weatherType').html(data.weather[0].main);
    $('#weatherIcon').attr({src: data.weather[0].icon});
    
    //Round temperatures to the nearest integer.
    var c = Math.round(data.main.temp);
    $('#tempCel').html(c + " C°");
    var f = Math.round((data.main.temp * 1.8) + 32);
    //$('#tempFahr').html(f);
   
    var tempCel = false;
    
    //Toggle between Fahrenheit and Celsius.
    $('#tempCel').on("click", function() {
      if (tempCel == false) {
        $('#tempCel').html(f + " F°");
        tempCel = true;
      } else {
        $(this).html(c + " C°");
        tempCel = false;
      };
      
    });
    
    };
  
});
              
            
!
999px

Console