cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <head>
 <meta charset="UTF-8">
 <title>Free Code Camp Weather App</title>
 <link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE-edge">
 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=nos">
 <script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
 <script src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>
</head>

<body>
 <div class="wrapper">
  <div class="col-md-12">
   <header>
    <h1 class="h1-title">Local Weather App </h1>
    <h3></h3>
   </header>
   <div class="weather-info-div">
    <h2 class="location-section"></h2>
    <div class="darksky-icon">
     <canvas id="clear-day" width="64" height="64"></canvas>
     <canvas id="clear-night" width="64" height="64"></canvas>
     <canvas id="partly-cloudy-day" width="64" height="64"></canvas>
     <canvas id="partly-cloudy-night" width="64" height="64"></canvas>
     <canvas id="cloudy" width="64" height="64"></canvas>
     <canvas id="rain" width="64" height="64"></canvas>
     <canvas id="sleet" width="64" height="64"></canvas>
     <canvas id="snow" width="64" height="64"></canvas>
     <canvas id="wind" width="64" height="64"></canvas>
     <canvas id="fog" width="64" height="64"></canvas>
    </div>
    <!-- <div>
            <img src="images/clear-night.jpg" alt="clear-night" />
            <img src="images/fog.jpg" alt="fog" />
            <img src="images/partly-cloudy-day.jpg" alt="partly-cloudy-day" />
            <img src="images/partly-cloudy-night.jpg" alt="partly-cloudy-night">
            <img src="images/rain.jpg" alt="rain">
            <img src="images/sleet.jpg" alt="sleet">
            <img src="images/snow.jpg" alt="snow">
            <img src="images" alt="">
          </div> -->
    <a><h2 class="temp-div"></h2>
            <h2 class="temp-measurement"></h2>
            <h2 class="temp-div-celsius"></h2>
            <h2 class="temp-measurement-celsius"></h2></a>
    <h2 class="weather-summary"></h2>
    <h4 class="daily-summary"></h4>
   </div>
  </div>
 </div>


 <footer>
  <a href="https://darksky.net/poweredby/">Powered by Dark Sky</a>
  <h5>Made with ❤️ in Pittsburgh, Pennsylvania</h5>
 </footer>
</body>

            
          
!
            
              .h1-title,
.location-section,
.weather-summary,
.daily-summary,
.temp-div,
.temp-div-celsius,
.temp-measuremment-celsius,
footer {
	color: #fff;
	text-shadow: #000 3px 3px 2px;
	text-align: center;
}

.temp-measurement, .darksky-icon {
	text-align: center;
}

html {
	min-height: 100%;
}

body {
	font-family: "Roboto";
	font-weight: 400;
	background-size: cover;
	background-repeat: no-repeat;
}

footer {
	font-family: "Roboto";
	font-weight: 400;
}
a:link {
	color: #fff;
	text-decoration: none;
}

            
          
!
            
              $(document).ready(function() {
  navigator.geolocation.getCurrentPosition(function(position) {
    $.getJSON(
      "https://api.darksky.net/forecast/" +
      position.coords.latitude +
      "," +
      position.coords.longitude,
      function(json) {
        console.log(json);
      }
    );
    console.log(position);
    $.ajax({
      url:
      "https://api.darksky.net/forecast/2a7c48d3a8dbf4822b57b8da897195fc/" +
      position.coords.latitude +
      "," +
      position.coords.longitude,
      type: "GET",
      dataType: "jsonp",

      success: function(json) {
        console.log(json);
        let farenheitTemp = json.currently.temperature;
        let location = json.timezone;
        let currentIcon = json.currently.icon;
        let weatherSummary = json.currently.summary;
        let tempF =
        "<img class='farenheit-image' src ='https://s3-us-west-2.amazonaws.com/s.cdpn.io/281152/fahrenheit1.svg' width='30px' height='30px'></img>";
        let tempC =
        "<img class='celsius-image' src ='https://s3-us-west-2.amazonaws.com/s.cdpn.io/281152/celsius1.svg' width='30px' height='30px'></img>";
        let dailySummary = json.daily.summary;
        let celsiusTemp = Math.round((farenheitTemp - 32) / 1.8);


        $(".location-section").html("Your current local conditions are<br>");

        let iconDisplay = (iconName, current) => {
          const jqObj = $(`#${iconName}`);
          iconName === current ? jqObj.show() : jqObj.hide();
        };


          iconDisplay("clear-day", currentIcon);
          iconDisplay("clear-night", currentIcon);
          iconDisplay("partly-cloudy-day", currentIcon);
          iconDisplay("partly-cloudy-night", currentIcon);
          iconDisplay("cloudy", currentIcon);
          iconDisplay("fog", currentIcon);
          iconDisplay("rain", currentIcon);
          iconDisplay("sleet", currentIcon);
          iconDisplay("snow", currentIcon);
          iconDisplay("wind", currentIcon);



         const iconMap = {
          "clear-day": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/sunny.jpg)",
          "partly-cloudy-night": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/fineas-anton-136459+copy.jpg)",
          "clear-night": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/sam-mcjunkin-38078.jpg)",
          "partly-cloudy-day": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/jeff-nafura-294909.jpg)",
          "cloudy": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/jonatan-pie-260835.jpg)",
          "rain": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/3opt_rain.jpeg)",
          "sleet": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/jonatan-pie-190398.jpg)",
          "snow": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/snow.jpg)",
          "wind": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/jon-flobrant-2845.jpg)",
          "fog": "url(https://s3.us-east-2.amazonaws.com/weatherappfcc/elaine-li-416.jpg)"
        };



        (function() {
          $("body").css("background-image", iconMap[currentIcon]);
        })();


        $(".temp-div-celsius").html(celsiusTemp).hide();
        $(".temp-measurement-celsius")
        .html(tempC)
        .hide();
        $(".temp-div").html(farenheitTemp);
        $(".temp-measurement").html(tempF);
        $(".weather-summary").html(weatherSummary);
        $(".daily-summary").html(dailySummary);

        $(".temp-div, .temp-measurement").on("click", function() {
          $(".temp-div, .temp-measurement").hide();
          $(".temp-div-celsius, .temp-measurement-celsius").show();
        });
        $(".temp-div-celsius, .temp-measurement-celsius"
      ).on("click", function() {
        $(".temp-div-celsius, .temp-measurement-celsius"
      ).hide();
      $(".temp-div, .temp-measurement").show();
    });

    let icons = new Skycons({ color: "#fff" });

    icons.set("clear-day", Skycons.CLEAR_DAY);
    icons.set("clear-night", Skycons.CLEAR_NIGHT);
    icons.set("partly-cloudy-day", Skycons.PARTLY_CLOUDY_DAY);
    icons.set("partly-cloudy-night", Skycons.PARTLY_CLOUDY_NIGHT);
    icons.set("cloudy", Skycons.CLOUDY);
    icons.set("rain", Skycons.RAIN);
    icons.set("sleet", Skycons.SLEET);
    icons.set("snow", Skycons.SNOW);
    icons.set("wind", Skycons.WIND);
    icons.set("fog", Skycons.FOG);

    icons.play();
  }
});
});
});
            
          
!
999px
Loading ..................

Console