cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
   

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
      
    <div class="container.fluid">
    <div class="row"id="rowColor2">
      <div class="col-md-12">
        <h1 class="text-center paddingH" id="H1white">Local weather</h1>
      </div> 
   </div>
  </div>
    
    <div class="container padding2">
    <div class="row">
      <div class="col-md-12">
        <div class="text-center paddingIcon"><img id="img" src=""/></div>
        <p class="text-center paddingTemp" id="currentTemp">°C</p>
        <div class="text-center" id="data"><h4>Weather description</h4></div>
        <div class="text-center padding"><button type="button" class="btn btn-danger"id="tempType"onclick="tempButton()">Fahrenheit</button></div>
      </div>
   </div>
  </div>
  
<div class="footer-section padding2">
  <footer> &copy; Brandon Whitton - 2017</footer>
</div>
    
    <link href='https://fonts.googleapis.com/css?family=Rubik+Mono+One' rel='stylesheet' type='text/css'>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  
  </body>
</html>
            
          
!
            
              body{
  background-color:#FFA947;
}

H1{
  font-family: 'Rubik Mono One', sans-serif;
  color: #222222;
}

p{
  color: #222222;
  font-size:100px;
}

#H1red{
  font-family: 'Rubik Mono One', sans-serif;
  color:red !important;
}

#H1white{
  font-family: 'Rubik Mono One', sans-serif;
  color:white !important;
}

.originalcolor{
  font-family: 'Rubik Mono One', sans-serif;
}

.padding{
  padding-top:20px;
  padding-bottom:20x;
}

.paddingText{
  padding-top:18px;
}

.paddingTemp{
  padding-top:50px;
}

.paddingIcon{
  padding-top:100px;
}

.paddingH{
  padding-bottom:10px;
}

.paddingR{
  padding-top:20px;
  padding-bottom:0px;
}

.padding2{
  padding-top:20px;
  padding-bottom:20px;
}

.paddingSides{
  padding-left:20px;
  padding-right:20px;
}

#rowColor2{
  background-color:#011F3B;
}

.padding-img{
  padding-top:5px;
  padding-bottom:20px;
}

 /* danger button */
    .btn-danger {
        background-color: #000 !important;
        color: #fff !important;
        border-color: #3276b1 !important;
    }
    .btn-danger:hover,
    .btn-danger:focus,
    .btn-danger:active    {
        background-color: #333 !important;
        color: #FFF !important;
        border-color: #285e8e !important;
    }

.footer-section{
  position: absolute;
  bottom: 0;
  width: 100%;
  background:#011F3B;
  min-height:80px;
  color:#fff;
  text-align:center;
}


            
          
!
            
              //Attention - this project is designed to work over http! It will not work over https.

var lat;
var lon;
var tempTypeShown = "celsius";
var tempCelsius;
var tempFahrenheit;


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

function findMe()
{
  $.getJSON("http://ip-api.com/json", function(data) {
    lat = data.lat;
    lon = data.lon;
    getWeather();
  });
  
}

function getWeather()
{
    
    var Weather = "http://api.wunderground.com/api/2ddaf6ff74d84205/forecast/geolookup/conditions/q/" + lat + "," + lon + ".json";
    
    $.ajax({
    url : Weather,
    dataType : "jsonp",
    success : function(data) {
    // get all the information
    var location = data['location']['city'];
    var temp = data['current_observation']['temp_c'];
    var tempf = data['current_observation']['temp_f'];
    var img = data['current_observation']['icon_url'];
    var icon = data['current_observation']['icon'];
    var desc = data['current_observation']['weather'];
    
    //add code to pass temps to global var.
    tempCelsius = temp;
    tempFahrenheit = tempf;
      
    //display the information
    $("#data").html(desc);
    $("#currentTemp").html(temp+"°C");
    $("#H1white").html(location+" Weather");
    //add switch statement to determine which icon to display.
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-01.png");
      
      
  switch (icon) 
   {
  case "sunny":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-01.png");
    break;
    
  case "chanceflurries":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather-icon-68.png");
    break;
           
  case "chancerain":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-36.png");
    break;
    
  case "chancesleet":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-25.png");
    break;
           
  case "chancesnow":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-68.png");
    break;
           
  case "chancetstorms":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-28.png");
    break;
           
  case "clear":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-01.png");
    break;      
     
   case "cloudy":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-16.png");
    break;
    
  case "flurries":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-68.png");
    break;
           
  case "fog":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-39.png");
    break;
    
  case "hazy":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-40.png");
    break;
           
  case "mostlycloudy":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-17.png");
    break;
           
  case "mostlysunny":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-17.png");
    break;
           
  case "partlycloudy":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-17.png");
    break;      
           
   case "partlysunny":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-17.png");
    break;
    
  case "sleet":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-25.png");
    break;
           
  case "rain":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-36.png");
    break;
    
  case "snow":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-68.png");
    break;
           
  case "tstorms":
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-28.png");
    break;
           
  default:
    $('#img').attr('src', "http://www.brandonwhitton.com/weather_icon-17.png");
    
               
    }
      
    }
    });
             
}


function tempButton()
{
  if (tempTypeShown == "celsius")
  {
    $("#tempType").html("Celsius");
    $("#currentTemp").html(tempFahrenheit+"°F");
    tempTypeShown = "fahrenheit";
  }else
    {
    $("#tempType").html("Fahrenheit");
    $("#currentTemp").html(tempCelsius+"°C");
    tempTypeShown = "celsius";
    }
  
}



            
          
!
999px
Loading ..................

Console