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.

+ add another resource


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


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.


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.


                <div id="wrapper">
  <div id="main">
    <h1>Local Weather Station</h1>
    <h2 id="locale">Loading...</h2>
    <h3 id="error"></h3>
    <div id="icon"></div>
    <span id="temperature"></span>
    <span id="button"></span>
    <p>by <a href="" target="_blank">Daniel Feldman</a></p>


                @import url(',300,400,500,600,700');

#main {
  text-align: center;
  margin-top: 22px;
body {
  margin: 0;
  padding: 0;
  width: 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
h1, h2, h3, a, p {
  font-family: 'Oswald', sans-serif;
  text-shadow: 1px 1px black;
h1 {
  font-size: 4em;
  font-weight: 700;
  color: silver;
h2 {
  font-size: 3em;
  font-weight: 400;
  color: goldenRod;
  margin-top: -25px;
h3 {
  font-size: 1.7em;
  font-weight: 300;
  color: goldenRod;
p, a {
  font-size: 1.2em;
  font-weight: 200;
  color: silver;
  text-decoration: none;
  color: lightGoldenRodYellow;
#icon {
  background-color: rgba(0,0,0,.22);
  border-radius: 50%;
  display: inline-block;
  width: 50px;
  padding: 10px;
  margin: -20px 0px 0px;
#toggleTemp {
  padding: 0px 0px 10px;
  font-family: 'Oswald', sans-serif;
  font-size: 1em;
  background-color: silver;
  width: 100px;
  height: 30px;
  border-radius: 10px;
#toggleTemp:hover {
  background-color: lightGoldenRodYellow;
footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100px;
  text-align: center;
footer p {
  padding-top: 30px;

/* Background image from: */



                var output = $("#locale");
var errorMsg = $("#error");
var latitude, longitude;

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(getPosition, showError);
  } else {
    output.html("Geolocation is not supported by this browser.");

function getPosition(position) {
  latitude = position.coords.latitude;
  longitude = position.coords.longitude;

  getWeather(latitude, longitude);

function showError(error) {
  switch (error.code) {
    case error.PERMISSION_DENIED:
      errorMsg.html("User denied the request for Geolocation.");
      output.html("Location information is unavailable.");
    case error.TIMEOUT:
      output.html("The request to get user location timed out.");
    case error.UNKNOWN_ERROR:
      output.html("An unknown error occurred.");

function getWeather() {
    url: "",
    format: "json",
    method: "GET",
    data: {
      lon: longitude,
      lat: latitude
    success: function(response) {
      var tempC = Math.floor(response.main.temp);
      var tempF = Math.floor(tempC * 1.8) + 32;
      var description =[0].description;


      $("#icon").html("<img src=" +[0].icon + ">");

      $("#temperature").html("<h3>The temperature is "+ tempC + "&deg;C with " + description + "</h3>");

      $("#button").html("<button id='toggleTemp' onclick='this.blur()'>toggle &deg;F/&deg;C</button>");

      toggleTemp(tempC, tempF, description);


function toggleTemp(tempC, tempF, description) {
  var tempInC = true;

  $("#toggleTemp").on("click", function() {
    if (tempInC) {
      $("#temperature").html("<h3>The temperature is " + tempF + "&deg;F with " + description + "</h3>");
      tempInC = false;
    } else {
      $("#temperature").html("<h3>The temperature is " + tempC + "&deg;C with " + description +"</h3>");
      tempInC = true;


/***** NOTES *****
Fahrenheit to Celsius conversions:
C to F: Multiply by 1.8 (or 9/5) and add 32.
F to C: Subtract 32 and multiply by .5556 (or 5/9).

jQuery.param() can be used to construct query string: