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.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <h1 class="header">Weather</h1><br>

<h2 class="location">We cannot find your location!</h2><br>

<button onclick ="changeTemp(temperature);" class="temperature" id="temperature" value="button text">60°F</button>


<img id="img" src="" class="weatherPic"><br><br></img>
<h2 class="conditions"></h2>

<h2 class="sunrise"></h2>
<h2 class="sunset"></h2>

<h3 class="footer"><a href="/">© Nick Katchur</a></h3>


                .header {
  text-align: center;

body {
  font-family: 'Coiny', cursive;
  color: white;
  background-color: black;
  text-align: center;

/*Footer name and link styling*/

.footer {
  text-decoration: none;
  color: white;
  background-color: black;
  margin-right: auto;
  bottom: 0;

/*To remove blue coloring and hover effect of link*/

a:visited {
  color: white;
  text-decoration: none;

/*Temperature text and button formating*/

.temperature {
  font-size: 200%;
  text-decoration: none;
  background-color: black;
  border: none;


                /*Creating temps array for later use with retrieved temperatures*/
temps = [60, 15.6, 288.7];
/*Assigning fareinheit to corresponding temperature*/
var temperature = temps[0] + "°F";

/*Switching temperature between F, C, and K*/
function changeTemp(temperature) {
  if (document.getElementById("temperature").textContent.slice(-1) == "F") {
    $(".temperature").text(temps[1] + "°C");
  } else if (document.getElementById("temperature").textContent.slice(-1) == "C") {
    $(".temperature").text(temps[2] + "K");
  } else if (document.getElementById("temperature").textContent.slice(-1) == "K") {
    $(".temperature").text(temps[0] + "°F");

$(document).ready(function() {

  /*Sending GET request to find out current location*/
  $.getJSON("", function(val) {
    var apiLocation = + "," + val.countryCode;
    /*Displaying current location*/
    if ( === undefined) {
      var geo_options = {enableHighAccuracy: true};
      var latitude = position.coords.latitude;
      var longitude = position.coords.longitude;
      var locationURL = "" + String(latitude) + "," + String(longitude) + "&key=AIzaSyCWc4g8rzR8G71wu1mrDIDEgGomqnOldHM";
      $.getJSON(locationURL, function(local) {
        apiLocation = local.results.address_components[6].long_name + "," + local.results.address_components[7].long_name;

    /*Getting location and assigning to openweather url*/
    apiUrl = "" + apiLocation + "&appid=569f4824cb1a2a5e07f330acd20cfd48";

    /*Sending GET request for weather at the zipcode location*/
    $.getJSON(apiUrl, function(value) {

      /*Assigning retrieved temperatures to temps array for later use*/
      temps[0] = Math.round((value.main.temp - 273) * 9 / 5) + 32;
      temps[1] = Math.round(value.main.temp - 273);
      temps[2] = Math.round(value.main.temp);

      /*Retreiving the OpenWeatherMap date from the jQuery request and converting it into standard long format.*/
      var sunriseDate = new Date(value.sys.sunrise * 1000);
      /*Getting the hours from the date value*/
      var sunriseHour = sunriseDate.getHours();
      /*Getting the minutes from the date value */
      var sunriseMinutes = sunriseDate.getMinutes();
      /*Creating the full correct formatted time for sunrise in order to be used later*/
      var sunrise = String(sunriseHour) + ":" + String(sunriseMinutes) + " AM";
      /*Displaying the sunrise time*/
      $(".sunrise").text("Sunrise: " + sunrise);

      /*Getting and displaying the sunset time*/
      var sunsetDate = new Date(value.sys.sunset * 1000);
      var sunsetHour = sunsetDate.getHours() - 12;
      var sunsetMinutes = sunsetDate.getMinutes();
      var sunset = String(sunsetHour) + ":" + String(sunsetMinutes) + " PM";
      $(".sunset").text("Sunset: " + sunset);

      /*Getting and displaying the weather coditions icon*/
      var icon =[0].icon;
      var iconUrl = "" + icon + ".png";
      document.getElementById("img").src = iconUrl;

      /*Getting and displaying the weather conditions*/
      var conditions =[0].main;

      /*Displaying temperature*/
      $(".temperature").text(temps[0] + "°F");