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. 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

JavaScript

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

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Current Weather</title>
<!--     <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link href="https://fonts.googleapis.com/css?family=IM+Fell+French+Canon+SC" rel="stylesheet">
    <link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
    <script src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/weather.js"></script> -->
  <!-- External Links
  # Bootstrap 3.3.7
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  # Font Awesome 4.7.0
  <link rel="stylesheet prefetch" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  # Bootstrap 3.3.7 JS
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  # jQuery 3.2.1
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  # jQueryUI 1.11.2
  <script src="https//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
  -->
</head>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Current Weather</title>
  <link rel="stylesheet" href="../css/bootstrap.min.css">
  <link rel="stylesheet" href="css/dev-style.css">
  <link rel="stylesheet" href="../climacons/webfont/climacons-font.css">
  <link rel="stylesheet" href="../font-awesome-4.7.0/css/font-awesome.min.css">
  <script type="text/javascript" src="../js/jquery-3.2.1.min.js"></script>
  <script type="text/javascript" src="../js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/dev-weather.js"></script>

  <!-- External Links
  # Bootstrap 3.3.7
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  # Font Awesome 4.7.0
  <link rel="stylesheet prefetch" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  # Bootstrap 3.3.7 JS
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  # jQuery 3.2.1
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  # jQueryUI 1.11.2
  <script src="https//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
  -->
</head>

<body>
  <div id="data"></div>
  <div class="container">
    <div class="row">
      <div class="col-xs-12 col-md-10 col-md-offset-1" id="weatherSection">

        <!-- Main Header (City) -->
        <div class="row bg-light">
          <div class="col-xs-12" id="mainHeader">
            <div id="userLoc">
            </div>
          </div>
        </div>
        <!-- Main Current Condition Text -->
        <div class="row">
          <div class="col-xs-12">
            <div id="currentConditionText">
            </div>
          </div>
        </div>
        <!-- Main Current Condition Icon -->
        <div class="row">
          <div class="col-xs-12">
            <div id="currentConditionIcon">
            </div>
          </div>
        </div>
        <!-- Main Current Temp -->
        <div class="row">
          <div class="col-xs-12">
            <div id="currentTemp">
            </div>
          </div>
        </div>
        <button role="button" class="btn btn-default changeUnit">Change Unit</button>

        <!-- Current Info Header -->
        <div class="row">
          <div class="col-xs-12">
            <div class="textSmall smallHeader" id="currentHeader">
              Current
            </div>
          </div>
        </div>
        <!-- Current Info -->
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Feels Like
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="feelsLike">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Humidity
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="humidity">
            </div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              High
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="maxTemp">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Low
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="minTemp">
            </div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Wind Speed
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="currentWindSpeed"></div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Wind Direction
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="currentWindDirection"></div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Visibility
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="visibility"></div>
          </div>
        </div>
        <!-- All Day Info -->
        <div class="row">
          <div class="col-xs-12">
            <div class="textSmall smallHeader">
              All Day
            </div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Total Rain
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="totalRain"></div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Avg. Temp
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="avgTemp"></div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Avg. Humidity
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="avgHumidity"></div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Sunrise
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="sunrise"></div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Sunset
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="sunset"></div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Moonrise
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="moonrise"></div>
          </div>
        </div>
        <div class="row bg-light">
          <div class="col-xs-6">
            <div class="textSmall infoLeft">
              Moonset
            </div>
          </div>
          <div class="col-xs-6">
            <div class="textSmall infoRight" id="moonset"></div>
          </div>
        </div>

        <footer class="credits">

          <span>Powered by</span><br/>
          <a href="http://adamwhitcroft.com/climacons/" target="_blank"><span class="climacon lightning sun climaLogo"></span>Climacons</a>
          <span>&nbsp;&amp;&nbsp;</span>
          <a href="http://apixu.com/" target="_blank">APIxu</a><br/>
          <span class="contact"><a href="https://github.com/harryrf" target="_blank">harryrf3</a> &copy; 2017</span>

        </footer>

      </div>
    </div>
  </div>


  <script src="../js/bootstrap.min.js"></script>
  <!-- External Bootstrap 3.3.7 JS
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js "></script>
  -->

</body>

</html>
              
            
!

CSS

              
                body {
  color: aliceblue;
  background-color: #333;
  text-align: center;
  font-family: 'Lato', sans-serif;
  font-size: 100%;
}


/* Used for current view of forecast */

#mainHeader {
  font-size: 3.5em;
  margin: 30px 0px;
}

#currentHeader {
  margin-top: 10px;
}

#currentInfo {
  margin-top: 5px;
  border-bottom: 2px solid rgba(240, 248, 255, 0.375);
}

#currentConditionText {
  font-size: 3.25em;
  margin-top: 15px;
}

#currentCondition {
  margin: 0;
}

#currentTemp {
  font-size: 12em;
}

.iconLarge {
  font-size: 30em;
  margin-top: -75px;
  margin-bottom: -75px;
}

.iconMedium {
  font-size: 20em;
  margin-bottom: -20px;
}

.textSmall {
  font-size: 1.60em;
  margin-top: 6px;
  margin-bottom: 6px;
}

.extraInfo {
  border-bottom: 2px solid rgba(240, 248, 255, 0.375);
}

footer {
  padding: 50px 0px;
}

.contact,
.credits {
  margin-top: 10px;
  text-align: center;
  font-size: 1.25em;
}

.climaLogo {
  font-size: 1.5em !important;
}

.contact a,
.credits a {
  text-decoration: none !important;
  color: #fff;
}

              
            
!

JS

              
                // HTTP and HTTPs are interchangable for these API's
// Use HTTP for offline editing
// Use HTTPS for online editing

// &#8451; = degrees Celsius
// &#8457; = degrees Fahrenheit

$(document).ready(function () {
  // Use this one for location
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
      var coords = position.coords.latitude + "," + position.coords.longitude;

      // *NOTE: Change location API to browser, this one is off
      // location API
      //  $.getJSON("https://ipinfo.io/json", function (location) {
      //var coords = location.loc;

      // Live API
      api =
        "https://api.apixu.com/v1/forecast.json?key=49f97e05d5144c9c829185418170806&q=" +
        coords +
        "&days=3";

      devapi =
        "http://192.168.1.10:8080/projects/localweather/dev/json/dev-3-day-forecast.json";

      // Location

      $("#userLoc").html(location.name);

      // coordinates gathered from ipinfo.io
      // it's more precise

      // #### ALL CONTENT BELOW THIS LINE WILL GO INTO LIVE WEATHER.JS FILE ####

      // weather API
      $.getJSON(api, function (geo) {
        var location = geo.location;
        current = geo.current;
        condition = geo.current.condition;
        forecastday = geo.forecast.forecastday[0].day;
        astro = geo.forecast.forecastday[0].astro;
        is_day = geo.current.is_day;
        cCode = geo.current.condition.code;

        //    NO LONGER NEEDED, just proud of it
        //
        //    check how much total precipitation will
        //    occur in current day 's 24 hours
        //    var hoursToday = geo.forecast.forecastday[0].hour;
        //    var totalRain_in = 0;
        //    // After testing, this keeps adding to totalRain_in
        //    // day after day and never resets. Needs fixed.
        //    for (i = 0; i < hoursToday.length; i++) {
        //      totalRain_in += hoursToday[i].precip_in;
        //    }

        // check if is_day == 1 (day)
        // then check the conidition and set
        // icon based on the day conditions.
        // if is_day != (night) check conditions
        // then set icon based on night conditions.

        var icon = "";

        if (is_day == 1) {
          switch (true) {
            case cCode == 1000:
              icon = "climacon sun iconMedium";
              break;

            case cCode == 1003:
              icon = "climacon cloud sun iconMedium";
              break;

            case cCode == 1006:
              icon = "climacon cloud iconMedium";
              break;

            case cCode == 1009:
              icon = "climacon haze sun iconMedium";
              break;

            case cCode == 1030:
            case cCode == 1135:
              icon = "climacon fog sun iconMedium";
              break;

            case cCode == 1063:
            case cCode == 1180:
            case cCode == 1183:
            case cCode == 1240:
            case cCode == 1243:
              icon = "climacon rain sun iconMedium";
              break;

            case cCode == 1066:
            case cCode == 1210:
            case cCode == 1216:
            case cCode == 1222:
            case cCode == 1255:
            case cCode == 1258:
              icon = "climacon snow sun iconMedium";
              break;

            case cCode == 1069:
            case cCode == 1204:
            case cCode == 1207:
            case cCode == 1249:
            case cCode == 1252:
            case cCode == 1261:
            case cCode == 1264:
              icon = "climacon sleet sun iconMedium";
              break;

            case cCode == 1072:
            case cCode == 1198:
            case cCode == 1201:
              // needs climacon thermometer
              icon = "climacon rain iconMedium";
              break;

            case cCode == 1186:
            case cCode == 1189:
              icon = "climacon rain iconMedium";
              break;

            case cCode == 1087:
            case cCode == 1273:
              icon = "climacon lightning sun iconMedium";
              break;

            case cCode == 1279:
              // needs climacon snowflake
              icon = "climacon lightning sun iconMedium";
              break;

            case cCode == 1282:
              // needs climacon snowflake
              icon = "climacon lightning iconMedium";
              break;

            case cCode == 1114:
              // needs climacon wind
              icon = "climacon snow iconMedium";
              break;

            case cCode == 1117:
            case cCode == 1213:
            case cCode == 1219:
            case cCode == 1225:
              icon = "climacon snow iconMedium iconMedium";
              break;

            case cCode == 1147:
              // needs climacon thermometer
              icon = "climacon fog iconMedium";
              break;

            case cCode == 1150:
            case cCode == 1153:
              icon = "climacon drizzle sun iconMedium";
              break;

            case cCode == 1168:
            case cCode == 1171:
              // needs climacon thermometer
              icon = "climacon drizzle iconMedium";
              break;

            case cCode == 1192:
            case cCode == 1246:
              icon = "climacon downpour sun iconMedium";
              break;

            case cCode == 1195:
              icon = "climacon downpour iconMedium";
              break;

            case cCode == 1237:
              icon = "climacon sleet iconMedium";
              break;

            case cCode == 1276:
              icon = "climacon lightning iconMedium";
              break;
          }
        } else {
          switch (true) {
            case cCode == 1000:
              icon = "climacon moon iconLarge";
              break;

            case cCode == 1003:
              icon = "climacon cloud moon iconMedium";
              break;

            case cCode == 1006:
              icon = "climacon cloud iconMedium";
              break;

            case cCode == 1009:
              icon = "climacon haze moon iconMedium";
              break;

            case cCode == 1030:
            case cCode == 1135:
              icon = "climacon fog moon iconMedium";
              break;

            case cCode == 1063:
            case cCode == 1180:
            case cCode == 1183:
            case cCode == 1240:
            case cCode == 1243:
              icon = "climacon rain moon iconMedium";
              break;

            case cCode == 1066:
            case cCode == 1210:
            case cCode == 1216:
            case cCode == 1222:
            case cCode == 1255:
            case cCode == 1258:
              icon = "climacon snow moon iconMedium";
              break;

            case cCode == 1069:
            case cCode == 1204:
            case cCode == 1207:
            case cCode == 1249:
            case cCode == 1252:
            case cCode == 1261:
            case cCode == 1264:
              icon = "climacon sleet moon iconMedium";
              break;

            case cCode == 1072:
            case cCode == 1198:
            case cCode == 1201:
              // needs climacon thermometer
              icon = "climacon rain iconMedium";
              break;

            case cCode == 1186:
            case cCode == 1189:
              icon = "climacon rain iconMedium";
              break;

            case cCode == 1087:
            case cCode == 1273:
              icon = "climacon lightning moon iconMedium";
              break;

            case cCode == 1279:
              // needs climacon snowflake
              icon = "climacon lightning moon iconMedium";
              break;

            case cCode == 1282:
              // needs climacon snowflake
              icon = "climacon lightning iconMedium";
              break;

            case cCode == 1114:
              // needs climacon wind
              icon = "climacon snow iconMedium";
              break;

            case cCode == 1117:
            case cCode == 1213:
            case cCode == 1219:
            case cCode == 1225:
              icon = "climacon snow iconMedium";
              break;

            case cCode == 1147:
              // needs climacon thermometer
              icon = "climacon fog iconMedium";
              break;

            case cCode == 1150:
            case cCode == 1153:
              icon = "climacon drizzle moon iconMedium";
              break;

            case cCode == 1168:
            case cCode == 1171:
              // needs climacon thermometer
              icon = "climacon drizzle iconMedium";
              break;

            case cCode == 1192:
            case cCode == 1246:
              icon = "climacon downpour moon iconMedium";
              break;

            case cCode == 1195:
              icon = "climacon downpour iconMedium";
              break;

            case cCode == 1237:
              iconMedium;
              icon = "climacon sleet iconMedium";
              break;

            case cCode == 1276:
              icon = "climacon lightning iconMedium";
              break;
          }
        }

        // Current Condition Text and Icon

        $("#currentConditionText").html(condition.text);
        $("#currentConditionIcon").append("<div class='" + icon + "'></div>");

        // Switch for Fahrenheit and Celsius

        var fahrenheit = true;

        function changeUnit() {
          console.log(fahrenheit);
          if (fahrenheit == true) {
            // current temp
            temp = Math.floor(current.temp_f) + "&#8457;";
            // current info
            feelslike = Math.floor(current.feelslike_f) + "&#8457;";
            maxtemp = Math.floor(forecastday.maxtemp_f) + "&#8457;";
            mintemp = Math.floor(forecastday.mintemp_f) + "&#8457;";
            wind = current.wind_mph + " MPH";
            vis = current.vis_miles + " MI";
            // forecasted current day
            avgtemp = Math.floor(forecastday.avgtemp_f) + "&#8457;";
            maxwind = forecastday.maxwind_mph + " MPH";
            avgvis = forecastday.avgvis_miles + " MI";
            totalprecip = forecastday.totalprecip_in + " IN";
            fahrenheit = false;
          } else {
            // current temp
            temp = Math.floor(current.temp_c) + "&#8451;";
            // current info
            feelslike = Math.floor(current.feelslike_c) + "&#8451;";
            maxtemp = Math.floor(forecastday.maxtemp_c) + "&#8451;";
            mintemp = Math.floor(forecastday.mintemp_c) + "&#8451;";
            wind = current.wind_kph + " KPH";
            vis = current.vis_km + " KM";
            // forecasted current day
            totalprecip = forecastday.totalprecip_mm / 100 + " CM";
            avgtemp = Math.floor(forecastday.avgtemp_c) + "&#8451;";
            maxwind = forecastday.maxwind_kph + " KPH";
            avgvis = forecastday.avgvis_km + " KM";
            fahrenheit = true;
          }

          // Current Weather

          $("#currentTemp").html(temp);

          // Current Info

          $("#feelsLike").html(feelslike);
          $("#humidity").html(current.humidity + "&#37;");
          $("#maxTemp").html(maxtemp);
          $("#minTemp").html(mintemp);
          $("#currentWindSpeed").html(wind);
          $("#currentWindDirection").html(current.wind_dir);
          $("#visibility").html(vis);

          // Forecasted Current Day

          $("#totalRain").html(totalprecip);
          $("#avgTemp").html(avgtemp);
          $("#avgHumidity").html(forecastday.avghumidity + "&#37;");
          $("#maxWind").html(maxwind);
          $("#sunrise").html(astro.sunrise);
          $("#sunset").html(astro.sunset);
          $("#moonrise").html(astro.moonrise);
          $("#moonset").html(astro.moonset);

          //          return fahrenheit;
          
        } // end changeUnit();

        changeUnit();

        $(".changeUnit").on("click", function () {
          changeUnit();
        });

      }); // getJSON
    }); // nav func
  } // nav if
}); // doc ready

              
            
!
999px
Be the developer your linter thinks you are.

Console