123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body id="bod">




<ul>
  <div id="tstuff">
  
  <li class="a" id="cityName"> </li>
  
  <li class="a" id="cel"> </li>
  
  <li class="a" id="weatherType"> </li>
  
  
  <li class="a" id="windInfo"></li>
  </div>
  
  <button id="but" class="btn btn-default"> Click here to change to Metric/Imperial</button>
  
  
   </ul>
  
  
  
</body>
            
          
!
            
              body{
  -webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
  
  
 
  font-family:timesnewroman;
}



.a{ text-align:center;
  font-size: 90px;
  
  
  
}
#tstuff {
  background-color: rgba(255, 255, 255, 0.3);

 width: 50%;
  background-color: rgba(255, 255, 255, 0.3);
  margin: 0 auto;
}

            
          
!
            
              $(document).ready(function() {
  //empty vars for use below
  var ftemp;
  var ctemp;
  var long;
  var lat;
  var conversion = true; //this must be a boolean
  // var api = `https://fcc-weather-api.glitch.me/api/current?lat=${coord.lat}&lon=${coord.long}`;
  var coord = {};
  function location() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        coord.long = position.coords.longitude;
        coord.lat = position.coords.latitude;
        console.log(long, lat);

        $("#data").html(
          "latitude: " + coord.lat + "<br>longitude: " + coord.long
        );

        // var api = `https://fcc-weather-api.glitch.me/api/current?lat=${lat}&lon=${long}`;
        weather();
      });
    }
  }
  function weather() {
    $.getJSON(
      "https://fcc-weather-api.glitch.me/api/current?lat=" +
        coord.lat +
        "&lon=" +
        coord.long,
      function(data) {
        console.log(coord.lat, coord.long);
        // This is the information that I want to display coming from the api
        console.log(data);
        var weatherType = data.weather[0].description;

        var cel = data.main.temp;
        var windInfo = data.wind.speed;
        var cloudInfo = data.clouds.all;
        var cityName = data.name;

        //end of the information still in Json call function here
        //temperature conversions
        ftemp = cel * (9 / 5) + 32;
        ctemp = (ftemp - 32) * (5 / 9);
        //temperature conversions
        // within the same function i will be targting the HTML with jQuery here

        $("#cityName").html(cityName);
        $("#cel").html(cel + "   C°");
        $("#weatherType").html(weatherType);
        $("#windInfo").html(windInfo + "  mph");

        //This will be the button making the conversion from ctemp to ftemp

        $("#but").click(function() {
          if (conversion === true) {
            $("#cel").html(ftemp.toFixed(2) + "   F°");
            conversion = false;
          } else if (conversion === false) {
            $("#cel").html(ctemp.toFixed(2) + "   C°");
            conversion = true;
          }
        });
        //end of the button to convert
        console.log(ctemp);
        if (ctemp <= 0) {
         $("#bod").css("background-image" , "url(https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-295247.jpg)");
          
        } 
        
        else if (ctemp <= 24) {
          $("#bod").css("background-image", "url(http://aceadventure.com.sg/wp-content/uploads/2015/04/Summit-lake-in-clear-weather.jpg)");
          // $("body").css("backgroundColor", "yellow");
         
        } else {
          $("#bod").css("background-image", "url(https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-354677.jpg)");
          
        }
      }
    );
  }

  location();
});

//COLD link : https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-295247.jpg

//MILD link:  https://alpha.wallhaven.cc/wallpaper/478131

//HOT link:  https://alpha.wallhaven.cc/wallpaper/354677

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console