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

              
                <script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script src="https://use.fontawesome.com/c1c18a314b.js"></script>

<div id="container" class="weather">
<div id="location">
  <div id="city"></div>
  <div id="country"></div>
</div>
<div id="time"></div>
<div id="weather" class="highlight">
  <div id="flex">
    <div id="symbol"></div>
    <div id="DF">
      <div id="degree"></div>
      <div id="forecast"></div>
    </div>
    <div id="HWWD">
      <div id="humidity"></div>
      <div id="wind_speed"></div>
      <div id="wind_direction"></div>
  </div>
</div>
<i id="click" class="fa fa-chevron-circle-down" aria-hidden="true"></i>
</div>
<div id="container2"></div>
</div>
<div id="container3">
<div>

              
            
!

CSS

              
                @import "https://fonts.googleapis.com/css?family=Roboto";

body{
  background: rgb(35,35,35);
  font-family: "Roboto";
  text-transform: capitalize;
}

/* CARD */
#container{
  font-weight: 100;
  color: #e6dc9a;
  border-radius: 20px 20px 30px 30px;
  letter-spacing: 1px;
  padding: 10px 0 0;
  background: rgba(0,0,0,1);
  max-width: 45em;
  margin: 10% auto;
  box-shadow: inset 0 0 60px 5px rgba(255,255,255,.1);
  box-sizing: border-box;
}

/* LOCATION DATE TIME */
#location{
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
}

#city, #country, #time{
  margin-top: 10px;
  text-align: center;
  font-size: 3em;
  text-shadow:  1px 0 6px rgba(255,255,255,.3),
               -1px 0 6px rgba(255,255,255,.3),
                0 1px 6px rgba(255,255,255,.3),
                0 -1px 6px rgba(255,255,255,.3);
}
#time{
  font-size: 1.2em;
  letter-spacing: 3px;
  margin-bottom: 3px;
}

/* WEATHER */
#weather{
  padding: 20px;
  border-radius: 20px;
  background: rgba(0,0,0,.9);
  box-shadow:inset 0 10px 55px -2px rgba(100,100,100,.7);
}
.highlight{
  text-shadow: 1px 0 10px rgba(200,200,200,.2),
               -1px 0 10px rgba(200,200,200,.2),
                0 1px 10px rgba(200,200,200,.2),
                0 -1px 10px rgba(200,200,200,.2);
  transition: all 1.5s ease-in-out;
}
.glow{
  text-shadow: 1px 0 20px rgba(255,255,255,.2),
               -1px 0 20px rgba(255,255,255,.2),
                0 1px 20px rgba(255,255,255,.2),
                0 -1px 20px rgba(255,255,255,.2);
}

#flex{
  display: flex;
  flex-wrap: wrap-reverse;
  align-items: center;
  justify-content: space-around;
}


#symbol{
  padding: 10px 20px 0 20px;
  font-size: 10em;
}
#degree{
  font-size: 5em;
}
#forecast{
  text-align: center;
  letter-spacing: 1px;
  font-size: 1.5em;
}

.wi-fahrenheit, .wi-celsius{
  font-size: .4em;
  position: relative;
  top: -35px;
}

#HWWD{
  margin-top: 10px;
  padding: 10px;
  font-size: 1.2em;
  line-height: 1.5;
}
#wind_direction{
  display: flex;
  flow: row wrap;
  justify-content: center;
  align-items: center;
}
#wind_direction span{
  padding-left: 5px;
  font-size: 1.5em;
}
#wind_direction i{
  font-size: 2.5em;
}
#click{
  position: relative;
  top: -15px;
  font-size: 1.5em;
  float: right;
  text-shadow: 1px 0 7px rgba(80,80,80,1),
               -1px 0 7px rgba(80,80,80,1),
                0 1px 7px rgba(80,80,80,1),
                0 -1px 7px rgba(80,80,80,1);
  transition: all .2s ease;
}
#click:hover{
  color: #edebe9;
  text-shadow: 1px 0 15px rgba(80,80,80,1),
               -1px 0 15px rgba(80,80,80,1),
                0 1px 15px rgba(80,80,80,1),
                0 -1px 15px rgba(80,80,80,1);
}
#click:active{
  color: rgba(230,220,154,.5);
  text-shadow: 1px 0 0 rgba(80,80,80,1),
               -1px 0 0 rgba(80,80,80,1),
                0 1px 0 rgba(80,80,80,1),
                0 -1px 0 rgba(80,80,80,1);
}

/* FORECAST RULES */
#container2{
  display: none;
  overflow: hidden;
  font-family: "Roboto";
  border-radius: 0 0 30px 30px;
  letter-spacing: 1px;
  margin: 0 auto;
  width: 100%;
}
#fah{
  font-size: 1em;
  position: static;
}
.day{
  display: inline-block;
  margin: 10px 0 0 0;
}

.list{
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.2);
  border-radius: 0 0 30px 30px;
  box-shadow: inset 0 -50px 85px -45px rgba(255,255,255,.4);
  text-shadow: -1px 0 5px black,
               1px 0 5px black,
               0 -1px 5px black,
               0 1px 5px black;
}

.list:nth-child(1),
.list:nth-child(2),
.list:nth-child(3),
.list:nth-child(4){
  box-shadow: inset 0 -50px 85px -45px rgba(255,255,255,.3);
}

.weatherIcon{
  line-height: 1.6;
  font-size: 3em;
  padding: 5px;
}
ul{
  padding: 0;
  list-style: none;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
}
li{
  font-size:1.2em;
  letter-spacing: 2px;
  display: flex;
  flex-flow: column;
}
.info{
  font-size: 1.7em;
}
.info div{
  font-size: .6em
}
.row{
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  justify-content: center;
}

 @media all and (min-width: 317px) and (max-width: 680px){
   #container{
     max-width: 27em;
   }
}
              
            
!

JS

              
                // main
$(()=>{
  // main variables
  const weather = {
    lat: geoplugin_latitude(),
    lon: geoplugin_longitude(),
    city: geoplugin_city(),
    country: geoplugin_countryName(),
    region: geoplugin_regionName(),
    Degree: $('#degree'),
    City: $('#city'),
    Country: $('#country'),
    Forecast: $('#forecast'),
    Symbol: $('#symbol'),
    Humidity: $('#humidity'),
    WindSpeed: $('#wind_speed'),
    WindDirection: $('#wind_direction'),
  },
        wURL = `http://api.openweathermap.org/data/2.5/weather?&APPID=0fda1291dbb48140dacfa9c0d29ccd7f&type=accurate&units=imperial&lat=${weather.lat}&lon=${weather.lon}`,
        fURL = `http://api.openweathermap.org/data/2.5/forecast?&APPID=0fda1291dbb48140dacfa9c0d29ccd7f&type=accurate&units=imperial&lat=${weather.lat}&lon=${weather.lon}`

  // set show time
  setInterval(_time, 1000);

  // weather data
  _mainWeather(weather, wURL)

  _restWeather(fURL);
  
  
  // UI functions
  $('#click').on('click',function(){
    $(this).toggleClass('fa-chevron-circle-down');
    $(this).toggleClass('fa-chevron-circle-up');
    $('#weather').toggleClass('shadow')
    $('#container2').animate({
      height: "toggle",
    }, 1000, "linear")
  })
  
  setInterval(function(){
    $('#weather').toggleClass('glow')
  },1500)
  
}) // end main

// Weather API
function _mainWeather(obj, URL){
  
  // start API
  $.getJSON(URL, data => {
    console.log(data);
    
    // local vars
    let icon = _getIcon(data.weather[0].id),
        deg = Math.round(data.wind.deg),
        direction = `<i class="wi wi-wind from-${deg}-deg"></i>`;
    
    // main layout
    obj.City
      .html(`${obj.city}, ${obj.region}`);
    obj.Country
      .text(obj.country)
    obj.Symbol
      .html(`<i class="wi ${icon}"></i>`);
    obj.Degree
      .html(Math.round(data.main.temp)+"<i class='wi wi-fahrenheit'></i>");
    obj.Forecast
      .text(data.weather[0].description);
    obj.Humidity
      .text(`Humidity: ${data.main.humidity}%`);
    obj.WindSpeed
      .text(`Wind: ${data.wind.speed}MPH`);
    obj.WindDirection
      .html(direction+`<span>${_direction(deg)}</span>`);

    /************************************************************************************/
    
    /**Main weather function***/
    function _getIcon(ID) {
    let icon = "wi-owm-",
        date = new Date(),
        hour = date.getHours();
    icon += hour >= 6 && hour <= 18 ? 'day-' : 'night-';
    return icon + ID;
  }
    function _direction(deg){
	let obj = {SSW: 22.5,SW: 45,WSW: 67.5,
             W: 90,WNW: 112.5,NW: 135,
             NNW: 157.5,N: 180,NNE: 202.5,
             NE: 225,ENE: 247.5,E: 270,
             ESE: 292.5,SE: 315,SSE: 337.5,}
			
  return ((deg >= 0 && deg <= 12)|| (deg <= 360 && deg >= 353))
          ?'S':Object.keys(obj).reduce((x,y)=>{
            return (Math.abs(deg-obj[x])<Math.abs(deg-obj[y]))?x:y})
}

 
  }); //end Weather data
}

// Forecast API
function _restWeather(URL){
  // start API
  $.getJSON(URL, data=>{
    console.log(data)
    
    //
    let dailyForecast = _extractDailyForecast(data.list)

    _showForeCast(dailyForecast)

    function _extractDailyForecast(arr){
      let A = [],
          B = arr.filter(x=>Number(x.dt_txt.match(/\d{2}:\d{2}:\d{2}/)[0].split(':')[0]) % 6 === 0),
          p = /^\d{4}-\d{2}-\d{2}/;
      for(var x = 0; x < B.length; x+=z) {
        var y = x;
        var z = 0;

        while(B[y] && B[y].dt_txt.match(p)[0] === B[x].dt_txt.match(p)[0]) {
          y++;
          z++;
        }
        A.push(B.slice(x, x+z));
      }
      return A;

    }

    function _showForeCast(arr){
      console.log(arr)
      let container = $('#container2');
      let temp = `<i id="fah" class="wi wi-fahrenheit"></i>`;
      // append ULs into the DOM
      arr.forEach(x=>{
        let list = [],
            day = _dayConverter(x[0].dt_txt);
        x.forEach(y=>{
          let ID = y.weather[0].id,
              description = y.weather[0].description,
              icon = _iconConverter(y.dt_txt, ID),
              hour = _hourConverter(y.dt_txt);
              

          list.push(`
<li>
  <div class="row">
    <div class="weatherIcon"><i class='${icon}'></i></div>
    <div class="info">${Math.round(y.main.temp)+temp}<div>${hour}</div></div>
  </div>
  <div>${description}</div>
</li>`);
        })
        container.append(`
<div class="list">
  <span class="day">${day}</span>
  <ul>${list.join('')}</ul>
</div>`);
      })
    }

    function _dayConverter(str){
        let date = new Date(str),
            week = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
            day = date.getDay(),
            theDay = `${date.getMonth()+1}/${date.getDate()}`
        return `${week[day]} ${theDay}`
    }
    function _iconConverter(str, id){
        let icon = "wi wi-owm-",
            date = new Date(str),
            hour = date.getHours();
      icon += hour >= 6 && hour < 18? 'day-':'night-';
      
      return icon+id;
    }
    function _hourConverter(str){
      let date = new Date(str),
          hour = date.getHours();
      
      return _12H(hour)+_period(hour)
    }

  }) //end Forecast data
}




function _time() {
  let date = new Date(),
      hours = date.getHours(),
      minutes = _pad(date.getMinutes()),
      seconds = _pad(date.getSeconds()),
      week = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
      day = week[date.getDay()],
      period = _period(hours),
      Time = $('#time')
  Time
    .text(day + " " + _pad(_12H(hours)) + ":" + minutes +
          ":" + seconds + " " + period)
  
} 
function _pad(num) {
      return ('0' + num)
        .substr(('0' + num).length - 2);
    }
function _12H(num) {
      switch (true) {
        case num > 12 && num < 24:
          return num - 12;
        case num === 0:
          return num + 12;
        default:
          return num;
                  }
    }
function _period(num) {
      switch (true) {
      case num >= 0 && num < 12:
        return 'AM';
      default:
        return 'PM';
                }
}
              
            
!
999px

Console