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

              
                <!--MY LOCAL WEATHER -- LOCATION -- C/F -- IMAGERY -->
<div class = "container-fluid">

<div id = "date"></div>
<div id = "locale"></div>
<div id = "temperature" class = "float-left"></div>
<button class="my-button" id="c-f-toggle"></button>
<div id = "desc"></div>
<div id = "sunrise"></div>
<div id = "sunset"></div>
<div><i id = "icon" class = "wi"></i></div>
  
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,500");

body {
  font-family: 'Open Sans Condensed', sans-serif;
  font-size: 24px;
  text-align: left;
}

.container-fluid div {
  display: block;
  margin-left: 500px;
  margin-right: auto;
}


.float-left {
  float: left;
}

.my-button {
  border: none;
  font-family: 'Open Sans Condensed', sans-serif;
  color: #002bff;
  font-size: 24px;
  background: #ffffff;
  padding: 0px 10px 0px 10px;
  text-decoration: none;
}

.my-button:hover {
  background: #94d6ff;
  text-decoration: none;
}
              
            
!

JS

              
                // api.openweathermap.org/data/2.5/weather?lat=35&lon=139&APPID=3b68aa704e7e5a961da6e01ea6dff289

//works in firefox, not in chrome

$(document).ready(function() {
  
  //initial vars
  var userLat;
  var userLon;
  var apiUrlString;
  var isFarenheit = true;
  var unit = "ºF";
  
  //vars to return from api json keys
  var UNIX_timestamp;
  var userDT;
  var userSunset;
  var userSunrise;
  var jsonWeather;
  var wDescription;
  var tempInC;
  var tempInF;
  var userCity;
  var iconId;
  
  getLocation();
  
  function getLocation () {
    navigator.geolocation.getCurrentPosition( function(position) {
      userLat = position.coords.latitude;
      userLon = position.coords.longitude;
      doAPIStuff (userLat,userLon);
    });
  }  //getLocation
      
function doAPIStuff(lat,lon) {
  apiUrlString = "http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&units=imperial&appid=3b68aa704e7e5a961da6e01ea6dff289";
  
  $.get(apiUrlString, function(json) {
    jsonWeather = JSON.stringify(json);  //just in case
    //console.log(jsonWeather);
    userSunset = timeConverter(json.sys.sunset);
    userSunrise = timeConverter(json.sys.sunrise);
    userDT = timeConverter(json.dt);
    userSunset = dateTimeSeparate(userSunset,"time"); 
    userSunrise = dateTimeSeparate(userSunrise,"time");
    wDescription = json.weather[0].description;  // "clear sky" 30 Dec 2016 3:15am stands true..  I see a star out the window.
    tempInF = Math.floor(json.main.temp);
    tempInC = Math.floor(json.main.temp-32*0.5556);
    userCity = json.name;
    iconId = json.weather[0].id;
    
    toHTML();
    //console.log(jsonWeather);
    },'jsonp' );
  //jsonWeather = testWeather; ////replace with above 4 lines
}//doAPIStuff

function timeConverter(UNIX_timestamp){
  var a = new Date(UNIX_timestamp * 1000);
  var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  var year = a.getFullYear();
  var month = months[a.getMonth()];
  var date = a.getDate();
  var hour = a.getHours();
  var min = a.getMinutes();
  var ampm = "am";
    if (hour>11 && hour!=24) {
    ampm="pm";
  }
  if (hour>12) {
    hour-=12;
  }
  //var sec = a.getSeconds();
  var time = date+' '+month+' '+year+' '+hour+':'+min+ampm;
  return time;
}  // time converter
  
function dateTimeSeparate(date,dayOrTime) {
  var day = date.substring(0,10);
  var time = date.substring(11);
  if (dayOrTime === "day") { return day; } else { return time; }
}

function toHTML() {
  $("#locale").html(userCity);
  $("#date").html(userDT);
  $("#sunrise").html("Sunrise: " + userSunrise);
  $("#sunset").html("Sunset: " + userSunset);
  $("#temperature").html(tempInF);
  $("#desc").html(wDescription);
  $("#c-f-toggle").html(unit);
  
  $("#c-f-toggle").on("click", function() {
  if (isFarenheit) {
    isFarenheit = false;
    unit = "ºC";
    $("#temperature").html(tempInC);
    $("#c-f-toggle").html(unit);
  } else { 
    isFarenheit = true;
    unit = "ºF";
    $("#temperature").html(tempInF);
    $("#c-f-toggle").html(unit);
  } //else thing
    }); // click function
    var classId = "wi-owm-"+iconId;
    console.log(classId);
    $('#icon').addClass(classId);
} //to html function

}); //docreadyfunction

              
            
!
999px

Console