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 text-center">

  <div class="page-header">
    <h1>L<i class="fa fa-sun-o" aria-hidden="true"></i>CAL WEATHER</h1>
    <!--show city name and country-->
    <h4> <p id="city"></p></h4>
  </div>


  <!--Area that displays the data. By default, only row1 (Current Outlook, Min/Max and Humidity) is shown.-->
  <div class="container data">
    <div class="row">

      <div class="col-md-4 subdata">
        Currently
        <p id="temperature"></p>
      </div>
      <div class="col-md-4 subdata">
        Min. / Max.
        <p id="min-max"></p>
      </div>
      <div class="col-md-4 subdata">
        Humidity
        <p id="humidity"></p>
      </div>
    </div>

    <!--Row2 contains Wind, Pressure and Visibility data, displayed when user clicks on the "More" button at the bottom of the app-->
    <div class="row collapse" id="moreweather">
      <div class="col-md-4 subdata">
        Wind
        <p id="wind"></p>
      </div>
      <div class="col-md-4 subdata">
        Pressure
        <p id="pressure"></p>
      </div>
      <div class="col-md-4 subdata">
        Visibility
        <p id="visibility"></p>
      </div>
    </div>
    <!--options buttons at the bottom of the app-->
    <div class="row text-center optional">
      <button class="btn btn-default" id="celcius">°C</button>
      <button class="btn btn-default" id="fahren">°F</button>
      <button class="btn btn-default btn-toggledata" data-toggle="collapse" data-target="#moreweather">More</button>
      <!--Hiding this button for now!
      <button class="btn btn-default btn-togglecolor"><i class="fa fa-bars" aria-hidden="true"></i></button>-->
      <!--this button allows users to select a color scheme-->
      <div class="btn-group">
        <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">
    Customize <span class="caret"></span>
        </button>
        <ul class="dropdown-menu" role="menu">
          <li class="dropdown-header">Colour</li>
          <li><a href="#" id="blues"><i class="fa fa-square" style="color:#373442"></i> <i class="fa fa-square" style="color:#5e5c67
"></i></a></li>
          <li><a href="#" id="warms"><i class="fa fa-square" style="color:#331111"></i> <i class="fa fa-square" style="color:#5b4040"></i></a></li>
          <li><a href="#" id="sunnies"><i class="fa fa-square" style="color:#cc6611"></i> <i class="fa fa-square" style="color:#d68440"></i></a></li>
          <li><a href="#" id="turquoise"><i class="fa fa-square" style="color:#207068"></i> <i class="fa fa-square" style="color:#4c8c86"></i></a></li>
         
        </ul>
      </div>
    </div>

  </div>
              
            
!

CSS

              
                body{
  background-color: #207068; /* dark turquoise - originally I used #6d7993 lavender*/
  color: #fff;
}


.page-header {
    border-bottom: 0.5px solid rgb(140, 140, 140);
  
}

h1{
  letter-spacing: 2px;
  opacity: 0.5;
}


.data{
  padding: 20px;
  width: 70%;
  background-color:#4c8c86; /*medium light turquoise - originally I used #96858f dusty purple*/
  border-radius: 20px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}

.subdata{
  background-color: #207068;
}

.btn{
  font-size: 0.9em;
  padding: 4px 7px;
  margin: 4px 0px;
}

/*
.btn-togglecolor{
  display: none;
}
*/

p{
  font-size: 1.5em;
  
}

.fa-square{
  font-size: 1.8em;
}

.dropdown-menu {
 min-width: 87px;
 text-align: center;
}
 

/*---start of color schemes---*/
.body2{
  background-color: #8fc33a;
}

.data2{
  background-color: #e9c904;
}

.subdata2{
  background-color: #8fc33a;
}

.page-header2 {
    border-bottom: 0.5px solid #c4bf9b;
}

/*---end of color schemes---*/
              
            
!

JS

              
                $(document).ready(function(){
  
   //determine the user's position (latitude and longitude)
    navigator.geolocation.getCurrentPosition(success, error);

    function success(pos){
     
     var crd = pos.coords;
     var weatherAPI = "https://fcc-weather-api.glitch.me/api/current?lat=" + crd.latitude + "&lon=" + crd.longitude;
     
      $.getJSON(weatherAPI, function(result){
         $("#city").html(result.name + ", " + result.sys.country + "<img src=" + result.weather[0].icon + ">");//City, country and logo within the header
         $("#humidity").html(result.main.humidity + "%");
         $("#wind").html(result.wind.speed + " km/h");
         $("#pressure").html(result.main.pressure + " mb");
        var visib = Math.round(result.visibility/1000);
         $("#visibility").html(visib + " km");
        var tempC = Math.round(result.main.temp);
        var tempF = Math.round(result.main.temp * 1.8 + 32);
        var mintempC = Math.round(result.main.temp_min);
        var mintempF = Math.round(result.main.temp_min * 1.8 + 32);
        var maxtempC = Math.round(result.main.temp_max);
        var maxtempF = Math.round(result.main.temp_max * 1.8 + 32);
        $("#temperature").html(tempC + "° " + result.weather[0].main);//display temp in Celcius by default
        $("#min-max").html(mintempC + "° / " + maxtempC + "°");
        //switch between °F and °C by clicking the buttons
        $("#fahren").click(function(){
              $("#temperature").html(tempF + "° " + result.weather[0].main
); 
              $("#min-max").html(mintempF + "° / " + maxtempF + "°")
        });
        $("#celcius").click(function(){
              $("#temperature").html(tempC + "° " + result.weather[0].main
);
              $("#min-max").html(mintempC + "° / " + maxtempC + "°")
        });
        
       
      }).fail("Sorry, no weather data is currently available");//error handling when the API call is not successful
        };
     
  //text that appears if app cannot determine location
  function error(err){
  $(".data").html("<h2>Sorry, unable to determine your location</h2>");
    };
  
  //color scheme toggle option
  $(".btn-togglecolor").click(function(){
    $("body").toggleClass("body2");
    $(".data").toggleClass("data2");
    $(".subdata").toggleClass("subdata2");
    $(".page-header").toggleClass("page-header2");
  })
  
  //blues colors scheme
  $("#blues").click(function(){
    $("body").css("background-color", "#373442");
    $(".data").css("background-color", "#5e5c67");
    $(".subdata").css("background-color", "#373442");
    $(".page-header").toggleClass("page-header2");
  })
  
   //warms colors scheme
  $("#warms").click(function(){
    $("body").css("background-color", "#331111");
    $(".data").css("background-color", "#5b4040");
    $(".subdata").css("background-color", "#331111 ");
    $(".page-header").toggleClass("page-header2");
  })
  
  //sunnies colors scheme
  $("#sunnies").click(function(){
    $("body").css("background-color", "#cc6611");
    $(".data").css("background-color", "#d68440");
    $(".subdata").css("background-color", "#cc6611 ");
    $(".page-header").toggleClass("page-header2");
  })
  
  //turquoise colors scheme
  $("#turquoise").click(function(){
    $("body").css("background-color", "#207068");
    $(".data").css("background-color", "#4c8c86");
    $(".subdata").css("background-color", "#207068 ");
    $(".page-header").toggleClass("page-header2");
  })
  
  //change the toggle button "More" to "Less" and vice versa
  $("#moreweather").on("show.bs.collapse", function(){
    $(".btn-toggledata").html("Less");
  });
 $("#moreweather").on("hide.bs.collapse", function(){
    $(".btn-toggledata").html("More");
  });




  });
 
              
            
!
999px

Console