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

              
                <div class="container">
    <div class="row" id="title">
        <div class="col-xs-12 p-t-3 p-b-2">
            <h2>Local Weather Report</h2>
        </div>
    </div>
    <div class="row" id="output">
        <div class="col-xs-12 col-sm-4">
            <div class="well well-lg" id="data">
                <div id="location"></div>
                <div id="tempC" class="temp-toggle"></div>
                <div id="tempF" class="temp-toggle hidden"></div>
                <div id="desc"></div>

                <div class="btn-group p-t-2" role="group">
                    <button type="button" class="btn btn-warning units-toggle">Celsius</button>
                    <button type="button" class="btn units-toggle faded">Fahrenheit</button>
                </div>
            </div>
        </div>
        <div class="col-xs-12 col-sm-8">
            <div class="media">
                <img class="img-responsive" id="imgMap">
            </div>
        </div>
    </div>
</div>

<div class="row hidden" id="http-only">

 
  <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3">
    <h2>HTTPS protocol is not supported in this version.<br><small>Please reload the application by HTTP: <a href='https://codepen.io/maynagashev/pen/WGYmkO' target=_blank>https://codepen.io/maynagashev/pen/WGYmkO</a></small></h2>        
    <div style="margin-top: -40px;">
    <i class="material-icons md-60">https</i>  
    <i class="material-icons md-60">arrow_forward</i>
    <i class="material-icons md-96" style="font-size: 120px; position: relative; top: 30px;">http</i>    
    </div>
  </div>
</div>

<footer class="footer">
    <div class="container-fluid">
        <div class="row">
            <div class="col-xs-12 col-sm-10 col-sm-offset-1 footer-icons text-center">
                <a href="https://www.linkedin.com/in/maynagashev" target="_blank"><i class="fa fa-linkedin"></i></a>
                <a href="https://codepen.io/maynagashev/pens/public" target="_blank"><i class="fa fa-codepen"></i></a>
                <a href="https://freecodecamp.com/maynagashev" target="_blank"><i class="fa fa-fire"></i></a>
                <a href="https://github.com/maynagashev" target="_blank"><i class="fa fa-github"></i></a>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-10 col-sm-offset-1 footer-text text-center">
                Copyright &copy; 2016 <a href="http://maynagashev.com" target="_blank">Evgeniy Maynagashev</a>. All rights reserved. <br>
                <!-- -->
                Developed for the freeCodeCamp Front-end Development Challenge<a href="" target="_blank"></a>.
            </div>
        </div>
    </div>
</footer>
              
            
!

CSS

              
                
/* Standart footer for projects */
html {
  position: relative;
  min-height: 100%;
  font-family: "Open Sans", "Sans", sans-serif;
}
body {
  margin-bottom: 90px; /* Margin bottom by footer height */
}
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 90px;
  background-color: #f5f5f5;
}
.footer-text {padding: 10px; color: #666; font-size: 80%;}
.footer-icons {padding-top:10px; font-size: 20px; color: #666;}
.footer-icons a {margin: 0 3px; color: #666;}

/* Bootstrap 4 spacing features */
/* top */
.p-t-0 { padding-top: 0px; }
.p-t-1 { padding-top: 10px; }
.p-t-2 { padding-top: 15px; }
.p-t-3 { padding-top: 30px; }
/* bottom */
.p-b-0 { padding-bottom: 0px; }
.p-b-1 { padding-bottom: 10px; }
.p-b-2 { padding-bottom: 15px; }
.p-b-3 { padding-bottom: 30px; }
.m-b-0 { margin-bottom: 0px; }
.m-b-1 { margin-bottom: 10px; }
.m-b-2 { margin-bottom: 15px; }
.m-b-3 { margin-bottom: 30px; }
/* --- end of Bootstrap 4 features --- */
#tempC, #tempF {font-size: 200%;}
.faded {color: #bbb;}
.clouds {color: #555;}
#location {font-size: 130%; font-weight: 400;}

.material-icons.md-18 { font-size: 18px; }
.material-icons.md-24 { font-size: 24px; }
.material-icons.md-36 { font-size: 36px; }
.material-icons.md-48 { font-size: 48px; }
.material-icons.md-60 { font-size: 60px; }
.material-icons.md-96 { font-size: 96px; }

#http-only {
  margin-top: 40px;
}
              
            
!

JS

              
                $( document ).ready(function() {
    doWeather();
});

function doWeather() {
    $.getJSON('http://ipinfo.io', function(d){
        console.log(d);
        //showData(d);
        showMap(d.loc);
        showCurrentLoc(d)
        getWeather(d);
    })
    .fail(function() {
        console.log( "error loading geo data" );
        $('#http-only').toggleClass('hidden');
        $('#output, #title').hide();
    });
    $(".units-toggle").on("click", function(){
        $(".units-toggle").toggleClass("btn-warning");
        $(".units-toggle").toggleClass("faded");
        $(".temp-toggle").toggleClass("hidden");
    });
    function getWeather(d) {
        var m = d.loc.match(/^([\d\.]+),([\d\.]+)/);
        var lat = (m) ? m[1] : 0;
        var lon = (m) ? m[2] : 0;
        var appid = "afa46564f097eecbc5fa34dab15fee02";
        //http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=b1b15e88fa797225412429c1c50c122a1
        $.getJSON("http://api.openweathermap.org/data/2.5/weather?units=metric&lat="+lat+"&lon="+lon+"&appid="+appid, function(w){
            console.log(w);
            //showData(w.main);
            //showData(w.weather[0]);
            //showData(w.wind);
            showWeather(w);
        });

    }
    function showWeather(d) {
        var desc = /* "<span>Clouds: "+d.clouds.all+"%</span><br>*/ "<img src='http://openweathermap.org/img/w/"+ d.weather[0]['icon']+".png'><br>"
                    +d.weather[0]['main']+" ("+d.weather[0]['description']+")";

        var tempC = d.main.temp;
        var tempF = tempC*1.8+32;

        document.getElementById("tempC").innerHTML = tempC.toFixed(1)+"°C";
        document.getElementById("tempF").innerHTML = tempF.toFixed(1)+"°F";
        document.getElementById("desc").innerHTML = desc;
    }
    function showCurrentLoc(d) {
        var ar = (d.city) ? [d.city] : [];
        if (d.region) ar.push(d.region);
        if (d.country) ar.push(d.country);

        document.getElementById("location").innerHTML = ar.join(", ");
    }
    function showData(d) {
        var items = [];
        $.each( d, function( key, val ) {
            items.push( "<li id='" + key + "'>" + key + ": <b>" + val + "</b></li>" );
        });
        $( "<ul/>", {
            "class": "my-new-list",
            html: items.join( "" )
        }).appendTo( "body" );
    }
    function showMap(loc) {
        var img = document.getElementById("imgMap");
        img.src = "https://maps.googleapis.com/maps/api/staticmap?key=AIzaSyBsoDhZWT9hlBVPc0iTw854GjXG8LEj0JA&center="+loc+"&zoom=9&size=640x240"; //&maptype=hybrid";
    }
} // end of doWeather()
              
            
!
999px

Console