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

              
                <!DOCTYPE html>
<html>
    <head>
        <title>FCC Show the Local Weather</title>
        <link rel="stylesheet" href="style.css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
        <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
        <link href="https://fonts.googleapis.com/css?family=Istok+Web" rel="stylesheet">
    </head>
    
    <body>

        <!-- Summary Image + Info -->
        <div class="container-fluid full-width-image margins">
            <h1 id="city">City, Country</h1>
            <div class="btn-group" data-toggle="buttons">
                <label class="btn btn-outline-secondary active" id="label-C">
                    <input type="radio" name="options" id="option-C" autocomplete="off"> &deg;C 
                </label>
                <label class="btn btn-outline-secondary" id="label-F">
                    <input type="radio" name="options" id="option-F" autocomplete="off"> &deg;F
                </label>
            </div>
            <p id="date">16 June 2017</p>
            <p id="time">Fri, 17:37</p>
            <p id="cur-summary">Rain</p>
        </div>
        
        <!-- Weather Panel -->
        <div class="container">
            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                  <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href="#today" role="tab">Today</a>
                  </li>
                  <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#tomorrow" id="tab2" role="tab">Fri</a>
                  </li>
                  <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#third-day" id="tab3" role="tab">Sat</a>
                  </li>
                  <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#fourth-day" id="tab4" role="tab">Sun</a>
                  </li>
            </ul>
            <!-- Tab panes -->
            <div class="tab-content">
                <div class="tab-pane active" id="today" role="tabpanel">
                    <div class="row">
                        <div class="col-sm-4">
                            <p id="cur-status"><span id="cur-deg">27</span> &deg;<span class="deg-toggle">C</span><i class="ion-ios-rainy-outline" id="today-icon"></i></p> 
                            <p id="cur-status2"><i class="ion-leaf icons"></i><span id="cur-wind"> 37</span> <span class="speed-toggle">kph </span> <i class="ion-waterdrop icons"></i><span id="cur-humid"> 45</span> % </p> 
                        </div>
                        <div class="col">
                            <i id="hourly-icon-0" class="hourly-icons"></i>
                            <p class="hourly-degs"><span id="hourly-deg-0">25</span>&deg;</p>
                            <p class="hourly-times"><span id="hourly-time-0">17:00</span></p>
                        </div>
                        <div class="col">
                            <i id="hourly-icon-1" class="hourly-icons"></i>
                            <p class="hourly-degs"><span id="hourly-deg-1">25</span>&deg;</p>
                            <p class="hourly-times"><span id="hourly-time-1">21:00</span></p>
                            
                        </div>
                        <div class="col">
                            <i id="hourly-icon-2" class="hourly-icons"></i>
                            <p class="hourly-degs"><span id="hourly-deg-2">25</span>&deg;</p>
                            <p class="hourly-times"><span id="hourly-time-2">01:00</span></p>

                        </div>
                        <div class="col">
                            <i id="hourly-icon-3" class="hourly-icons"></i>
                            <p class="hourly-degs"><span id="hourly-deg-3">25</span>&deg;</p>
                            <p class="hourly-times"><span id="hourly-time-3">05:00</span></p>

                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="tomorrow" role="tabpanel">
                    <div class="row">
                        <div class="col-sm-4">
                            <p id="tomorrow-status"><span id="tomorrow-deg-max">27</span> &deg;<span class="deg-toggle">C</span><span id="tomorrow-deg-min">23</span> &deg;<span class="deg-toggle">C</span><br><i class="ion-ios-rainy-outline" id="tomorrow-icon"></i></p> 
                            <p id="tomorrow-status2"><i class="ion-leaf icons"></i><span id="tomorrow-wind"> 37</span> <span class="speed-toggle">kph </span> <i class="ion-waterdrop icons"></i><span id="tomorrow-humid"> 45</span> % </p>
                        </div>
                        <div class="col">
                            <h3>Day summary:</h3>
                            <p id="tomorrow-summary">Info</p>
                        </div>
                        <div class="col">
                            <p class="more-info">Cloud cover: <span id="tomorrow-cloud">20</span>%</p>
                            <p class="more-info">Chance of rain: <span id="tomorrow-rain">10</span>%</p>
                            <p class="more-info">Real feel max: <span id="tomorrow-real-max">29</span>&deg;</p>
                            <p class="more-info">Real feel min: <span id="tomorrow-real-min">18</span>&deg;</p>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="third-day" role="tabpanel">
                    <div class="row">
                        <div class="col-sm-4">
                            <p id="third-status"><span id="third-deg-max">27</span> &deg;<span class="deg-toggle">C</span><span id="third-deg-min">23</span> &deg;<span class="deg-toggle">C</span><br><i class="ion-ios-rainy-outline" id="third-icon"></i></p> 
                            <p id="third-status2"><i class="ion-leaf icons"></i><span id="third-wind"> 37</span> <span class="speed-toggle">kph </span> <i class="ion-waterdrop icons"></i><span id="third-humid"> 45</span> % </p>
                        </div>
                        <div class="col">
                            <h3>Day summary:</h3>
                            <p id="third-summary">Info</p>
                        </div>
                        <div class="col">
                            <p class="more-info">Cloud cover: <span id="third-cloud">20</span>%</p>
                            <p class="more-info">Chance of rain: <span id="third-rain">10</span>%</p>
                            <p class="more-info">Real feel max: <span id="third-real-max">29</span>&deg;</p>
                            <p class="more-info">Real feel min: <span id="third-real-min">18</span>&deg;</p>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="fourth-day" role="tabpanel">
                    <div class="row">
                        <div class="col-sm-4">
                            <p id="fourth-status"><span id="fourth-deg-max">27</span> &deg;<span class="deg-toggle">C</span><span id="fourth-deg-min">23</span> &deg;<span class="deg-toggle">C</span><br><i class="ion-ios-rainy-outline" id="fourth-icon"></i></p> 
                            <p id="fourth-status2"><i class="ion-leaf icons"></i><span id="fourth-wind"> 37</span> <span class="speed-toggle">kph </span> <i class="ion-waterdrop icons"></i><span id="fourth-humid"> 45</span> % </p>
                        </div>
                        <div class="col">
                            <h3>Day summary:</h3>
                            <p id="fourth-summary">Info</p>
                        </div>
                        <div class="col">
                            <p class="more-info">Cloud cover: <span id="fourth-cloud">20</span>%</p>
                            <p class="more-info">Chance of rain: <span id="fourth-rain">10</span>%</p>
                            <p class="more-info">Real feel max: <span id="fourth-real-max">29</span>&deg;</p>
                            <p class="more-info">Real feel min: <span id="fourth-real-min">18</span>&deg;</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        
        <!-- Footer -->
        <footer class="footer">
            <p id="credits">Coded by <a href="https://github.com/ness113" target="_blank"><i class="ion-social-octocat"></i> Mahdi Kamyar</a> for FCC</p>
            <p id="darksky">Powered by <a href="https://darksky.net/poweredby/" target="_blank">Darksky</a></p>
        </footer>
        
        
        <!-- Scripts -->
        <script
        src="https://code.jquery.com/jquery-3.2.1.js"
        integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
        crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
        <script src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>
        <script src="script.js"></script>
    </body>
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Great+Vibes');
#city, #date, #time, #cur-summary, .tab-content {
    font-family: 'Istok Web', sans-serif;
}

/****** HEADER ******/
.full-width-image {
  height: 500px;
  background: url("https://image.ibb.co/dtCUpa/wind.jpg") no-repeat center center fixed;
  background-size: cover;
}

.btn-group {
    float: right;
    margin-top: 30px;
}

#city {
    color: rgba(236, 236, 234, 0.8); /*city*/
    display: inline;
    position: relative;
    top: 20px;
}

#date, #time {
    color: rgba(232, 232, 232, 0.6); /*date*/
    position: relative;
    top: 40px;
    line-height: 13px;
}

#cur-summary {
    color: rgba(238, 236, 234, 0.2); /*summary*/
    margin-top: 70px;
    font-size: 220%;
}


/****** CONTENT ******/
ul.nav.nav-tabs {
    background-color: rgba(10, 40, 0, 0.6);
    margin-top: -41px;
}

ul.nav.nav-tabs li a {
    color: white;
}

ul.nav.nav-tabs li a:focus, ul.nav.nav-tabs li a:active {
    color: rgba(46, 44, 43, 0.6);
}

.col, .col-sm-4:nth-child(2), .col-sm-4:nth-child(3) {
    border-left: 1px solid rgba(216, 216, 216, 0.1);
}

#cur-status, #cur-status2, #tomorrow-status, #tomorrow-status2, #third-status, #third-status2, #fourth-status, #fourth-status2 {
    text-align: center;
}

#cur-status, #tomorrow-status, #third-status, #fourth-status {
    margin-top: 10%;
}

#cur-status2, #tomorrow-status2, #third-status2, #fourth-status2 {
    margin-bottom: 10%;
}

#tomorrow-status2, #third-status2, #fourth-status2 {
    margin-top: -15px;
}


#today-icon {
    font-size: 520%;
    padding-left: 30px;
    color: rgba(46, 44, 43, 0.9);
} 

#tomorrow-icon, #third-icon, #fourth-icon {
    font-size: 450%;
    color: rgba(74, 175, 70, 0.9);
}

#cur-deg {
    font-size: 500%;
    color: rgba(74, 175, 70, 0.9);
}

#tomorrow-deg-max, #tomorrow-deg-min, #third-deg-max, #third-deg-min, #fourth-deg-max, #fourth-deg-min {
    font-size: 200%;
}

#tomorrow-deg-max, #third-deg-max, #fourth-deg-max {
    color: crimson;
}

#tomorrow-deg-min, #third-deg-min, #fourth-deg-min {
    color: skyblue;
    padding-left: 20px;
}

.col h3 {
    font-size: 120%;
    text-align: center;
    margin-top: 15%;
    color: rgba(46, 44, 43, 0.8);
}

#tomorrow-summary, #third-summary, #fourth-summary {
    text-align: center;
    margin-top: 10%;
    font-size: 130%;
    color: rgba(36, 36, 36, 0.9);
  font-style: italic;
}

.more-info:nth-child(1) {
    margin-top: 15%;
}

.more-info {
    text-align: center;
    color: rgba(46, 44, 43, 0.8);
    font-size: 120%;
}

.speed-toggle {
    margin-right: 15px;
}

.icons {
    font-size: 140%;
    color: darkslategray;
    padding-right: 5px;
}

.icons:nth-child(3) {
    padding-left: 20px;
}

.hourly-icons {
    font-size: 60px;
    display: block;
    text-align: center;
    margin-top: 20px;
    color: rgba(74, 175, 70, 0.9);
}

.hourly-degs {
    text-align: center;
    margin-top: 20px;
    font-size: 120%;
    font-weight: 500;
}

.hourly-times {
    text-align: center;
    margin-top: 50px;
    margin-bottom: 60px;
    color: rgba(46, 44, 43, 0.8);
}

@media only screen and (max-width: 768px) {
  .more-info:nth-child(4), .hourly-times {
    margin-bottom: 20px;
  }
  
  #cur-status, {
    margin-top: 15px;
  }
  
  .more-info {
    font-size: 100%;
  }
}

/****** FOOTER ******/
.footer {
  padding-top: 20px;
    height: 50px;
    color: black;
    text-align: center;
    margin-top: 50px;
    font-size: 90%;
  line-height: 5px;
}

#darksky {
  padding-bottom: 20px;
}

.footer a {
   // text-align:right;
  font-size: 14px;
  font-family: 'Great Vibes', cursive;
 // top: 50px;
  //padding: 1rem;
 color : #cccc00;
   // color: rgba(74, 175, 70, 0.9);
}
              
            
!

JS

              
                
$(window).on('load', function () {
    if ('geolocation' in navigator) {
        navigator.geolocation.getCurrentPosition(function(position) {
            var lat = position.coords.latitude;
            var lon = position.coords.longitude;
      
            var url = 'https://api.darksky.net/forecast/08fe70f4acbb5f48981535f29ee9a4d8/'+ lat + ',' + lon + '?callback=?';
      
            $.getJSON(url, getForecast);
            $.getJSON("https://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+lon+"&key=AIzaSyDDFZmBU6s4WfuTU1abbslOKnRlNqVkQ98", function(googleLocation) {
                $("#city").text(googleLocation.results[3].formatted_address);
            });
        });
      
    } else {
        alert("Browser doesn't support geolocation!");
    }
});

// Real time and date
var now = new Date();
var minutes = now.getMinutes();

if (minutes < 10) {
    minutes = "0" + minutes;
};

$('#date').html(now.toDateString());
$('#time').html(now.getHours() + ":" + minutes);

// Temperature Conversion
var tempConvert = function(temp) {
    return Math.round((temp - 32) * 5/9);
}


// FORECAST
var getForecast = function(data) {
    console.log(data);
    
    // Click events on buttons (toggle data between C and F)
    $('#label-C').on('click', function () {
        $('#cur-wind').html(Math.round(data.currently.windSpeed * 1.6));
        $('#cur-deg').html(tempConvert(data.currently.temperature));
        $('.deg-toggle').html('C');
        $('.speed-toggle').html('kph');
        if ($('#label-F').hasClass('active')) {
            $('#label-F').removeClass('active');
            $('#label-C').addClass('active');
        }
        hourlyForecast();
        tomorrowForecast();
        thirdForecast();
        fourthForecast();
    }); 
    
    $('#label-F').on('click', function () {    
        $('#cur-wind').html(Math.round(data.currently.windSpeed));
        $('#cur-deg').html(Math.round(data.currently.temperature));
        $('.deg-toggle').html('F');
        $('.speed-toggle').html('mph');
        if ($('#label-C').hasClass('active')) {
            $('#label-C').removeClass('active');
            $('#label-F').addClass('active');
        }
        hourlyForecast();
        tomorrowForecast();
        thirdForecast();
        fourthForecast();
    });
    
    
    // Change text color according to pictures
    if (data.currently.icon === 'clear-day' || data.currently.icon === 'clear-night' || data.currently.icon === 'partly-cloudy-night' || data.currently.icon === 'wind') {
        $('#city, #cur-summary').css('color', 'rgba(238, 236, 234, 0.9)');
        $('#date, #time').css('color', 'rgba(232, 232, 232, 0.8)');
    } else {
        $('#city, #cur-summary').css('color', 'rgba(46, 44, 43, 0.9)');
        $('#date, #time').css('color', 'rgba(42, 41, 41, 0.8)');
    }
    
   
    // Main today forecast
    $('#cur-summary').html(data.currently.summary);
    $('.full-width-image').css({'background': 'url(' + pictures(data.currently.icon) + ') no-repeat center center fixed', 'background-size': 'cover'});
    $('#cur-humid').html(Math.round(data.currently.humidity * 100));
    $('#today-icon').attr('class', iconClasses(data.currently.icon));
  $('#cur-deg').html(tempConvert(data.currently.temperature));
    
    
    // Hourly forecast
    var hourlyForecast = function() {
        var hourlyData = data.hourly.data;
        var hourlyArr = [];

        for (var i = 0; i < hourlyData.length; i += 4) {
            hourlyArr.push(hourlyData[i]);
        }

        for (i = 0; i < hourlyArr.length; i++) {
            $('#hourly-icon-' + i).addClass(iconClasses(hourlyArr[i].icon));

            var date = new Date(hourlyArr[i].time * 1000);
            $('#hourly-time-' + i).html(date.getHours() + ':00');

            if ($('#label-C').hasClass('active')) {
                $('#hourly-deg-' + i).html(tempConvert(hourlyArr[i].temperature));
            } else {
                $('#hourly-deg-' + i).html(Math.round(hourlyArr[i].temperature));
            }
        }
    }
    hourlyForecast();
    
    
    // Tomorrow forecast
    var tomorrowForecast = function() {
        $('#tomorrow-humid').html(Math.round(data.daily.data[1].humidity * 100));
        $('#tomorrow-icon').attr('class', iconClasses(data.daily.data[1].icon));
        $('#tomorrow-summary').html(data.daily.data[1].summary);
        $('#tomorrow-cloud').html(Math.round(data.daily.data[1].cloudCover * 100));
        $('#tomorrow-rain').html(Math.round(data.daily.data[1].precipProbability * 100));
        
        if ($('#label-C').hasClass('active')) {
            $('#tomorrow-wind').html(Math.round(data.daily.data[1].windSpeed * 1.6));
            $('#tomorrow-deg-max').html(tempConvert(data.daily.data[1].temperatureMax));
            $('#tomorrow-deg-min').html(tempConvert(data.daily.data[1].temperatureMin));
            $('#tomorrow-real-max').html(tempConvert(data.daily.data[1].apparentTemperatureMax));
            $('#tomorrow-real-min').html(tempConvert(data.daily.data[1].apparentTemperatureMin));
        } else {
            $('#tomorrow-wind').html(Math.round(data.daily.data[1].windSpeed));
            $('#tomorrow-deg-max').html(Math.round(data.daily.data[1].temperatureMax));
            $('#tomorrow-deg-min').html(Math.round(data.daily.data[1].temperatureMin));
            $('#tomorrow-real-max').html(Math.round(data.daily.data[1].apparentTemperatureMax));
            $('#tomorrow-real-min').html(Math.round(data.daily.data[1].apparentTemperatureMin));
        }
    }
    tomorrowForecast();
    
    
    // Third forecast
    var thirdForecast = function() {
        $('#third-humid').html(Math.round(data.daily.data[2].humidity * 100));
        $('#third-icon').attr('class', iconClasses(data.daily.data[2].icon));
        $('#third-summary').html(data.daily.data[2].summary);
        $('#third-cloud').html(Math.round(data.daily.data[2].cloudCover * 100));
        $('#third-rain').html(Math.round(data.daily.data[2].precipProbability * 100));
        
        if ($('#label-C').hasClass('active')) {
            $('#third-wind').html(Math.round(data.daily.data[2].windSpeed * 1.6));
            $('#third-deg-max').html(tempConvert(data.daily.data[2].temperatureMax));
            $('#third-deg-min').html(tempConvert(data.daily.data[2].temperatureMin));
            $('#third-real-max').html(tempConvert(data.daily.data[2].apparentTemperatureMax));
            $('#third-real-min').html(tempConvert(data.daily.data[2].apparentTemperatureMin));
        } else {
            $('#third-wind').html(Math.round(data.daily.data[2].windSpeed));
            $('#third-deg-max').html(Math.round(data.daily.data[2].temperatureMax));
            $('#third-deg-min').html(Math.round(data.daily.data[2].temperatureMin));
            $('#third-real-max').html(Math.round(data.daily.data[2].apparentTemperatureMax));
            $('#third-real-min').html(Math.round(data.daily.data[2].apparentTemperatureMin));
        }
    }
    thirdForecast();
    
    
    // Fourth forecast
    var fourthForecast = function() {
        $('#fourth-humid').html(Math.round(data.daily.data[3].humidity * 100));
        $('#fourth-icon').attr('class', iconClasses(data.daily.data[3].icon));
        $('#fourth-summary').html(data.daily.data[3].summary);
        $('#fourth-cloud').html(Math.round(data.daily.data[3].cloudCover * 100));
        $('#fourth-rain').html(Math.round(data.daily.data[3].precipProbability * 100));
        
        if ($('#label-C').hasClass('active')) {
            $('#fourth-wind').html(Math.round(data.daily.data[3].windSpeed * 1.6));
            $('#fourth-deg-max').html(tempConvert(data.daily.data[3].temperatureMax));
            $('#fourth-deg-min').html(tempConvert(data.daily.data[3].temperatureMin));
            $('#fourth-real-max').html(tempConvert(data.daily.data[3].apparentTemperatureMax));
            $('#fourth-real-min').html(tempConvert(data.daily.data[3].apparentTemperatureMin));
        } else {
            $('#fourth-wind').html(Math.round(data.daily.data[3].windSpeed));
            $('#fourth-deg-max').html(Math.round(data.daily.data[3].temperatureMax));
            $('#fourth-deg-min').html(Math.round(data.daily.data[3].temperatureMin));
            $('#fourth-real-max').html(Math.round(data.daily.data[3].apparentTemperatureMax));
            $('#fourth-real-min').html(Math.round(data.daily.data[3].apparentTemperatureMin));
        }
    }
    fourthForecast();
    
    // Change the day in tabs
    $('#tab2').html(unixTimeToDay(data.daily.data[1]));
    $('#tab3').html(unixTimeToDay(data.daily.data[2]));
    $('#tab4').html(unixTimeToDay(data.daily.data[3]));
}


// Ionicons classes
function iconClasses (apiData) {
    var iconClass;
        
    if (apiData === 'clear-day') {
        iconClass = 'ion-ios-sunny-outline';
    } else if (apiData === 'clear-night') {
        iconClass = 'ion-ios-moon-outline';
    } else if (apiData === 'partly-cloudy-day') {
        iconClass = 'ion-ios-partlysunny-outline';
    } else if (apiData === 'partly-cloudy-night') {
        iconClass = 'ion-ios-cloudy-night-outline';
    } else if (apiData === 'cloudy') {
        iconClass = 'ion-ios-cloudy-outline';
    } else if (apiData === 'rain') {
        iconClass = 'ion-ios-rainy-outline';
    } else if (apiData === 'sleet') {
        iconClass = 'ion-ios-rainy-outline';
    } else if (apiData === 'snow') {
        iconClass = 'ion-ios-snowy';
    } else if (apiData === 'wind') {
        iconClass = 'ion-leaf';
    } else if (apiData === 'fog') {
        iconClass = 'ion-ios-analytics';
    }
    
    return iconClass;
}


// Background picture links
function pictures (apiData) {
    var picLink;
        
    if (apiData === 'clear-day') {
        picLink = 'https://image.ibb.co/nu6B2v/sunny.jpg';
    } else if (apiData === 'clear-night') {
        picLink = 'https://image.ibb.co/mqWN9a/clear_night.jpg';
    } else if (apiData === 'partly-cloudy-day') {
        picLink = 'https://image.ibb.co/kkFh9a/mostly_cloudy.jpg';
    } else if (apiData === 'partly-cloudy-night') {
        picLink = 'https://image.ibb.co/bE829a/cloudy_night.jpg';
    } else if (apiData === 'cloudy') {
        picLink = 'https://image.ibb.co/jFvFUa/cloudy.jpg';
    } else if (apiData === 'rain') {
        picLink = 'https://image.ibb.co/jikh9a/rain.jpg';
    } else if (apiData === 'sleet') {
        picLink = 'https://image.ibb.co/druaUa/sleet.jpg';
    } else if (apiData === 'snow') {
        picLink = 'https://image.ibb.co/haRppa/snow.jpg';
    } else if (apiData === 'wind') {
        picLink = 'https://image.ibb.co/dtCUpa/wind.jpg';
    } else if (apiData === 'fog') {
        picLink = 'https://image.ibb.co/f2q4Nv/fog.jpg';
    }

    return picLink;
}

// Convert unix time
function unixTimeToDay(data) {
    var date = new Date(data.time * 1000);
    var dayName = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    return dayName[date.getDay()];
};
              
            
!
999px

Console