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.

              <html lang="en">
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
      Weather application
    <div class = "container-fluid ">
       <div class="row">
      <div class = "col-xs-2">
      </div> <!--class = "col-xs-6"-->
      <div class = "">
    <div class = "col-xs-8 text-center">
       <h1 class ="titre">Get the temperature in your city</h1>
      <h2 class ="timezone"> </h2>
      <img id="icon" src="#" alt="Weather icon"> 
       <div class="button-center">
       <button id = "temp" class = "btn btn-primary">
    </div>  <!--class = "col-xs-12-->
  </div> <!--class = "row text-center"-->
      </div> <!--class="row"-->
    </div> <!--container-floud-->
              .titre {
  margin-top: 700px;
  margin-bottom: 50px;
#icon {
 margin-top: 0px;
  margin-bottom: 0px;
.button-center {
  margin-bottom: 500px;
               $(document).ready(function() {
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    var latitude = position.coords.latitude;                  var longitude=position.coords.longitude;
 /* Watch this about the cors problem  
 and why adding this '?callback=?'
 and this https://www.sitepoint.com/jsonp-examples/*/   $.getJSON("https://api.darksky.net/forecast/6504ca314b9a9d22da513f6505b71b93/"+latitude+","+longitude+'?callback=?',function(json){
      //* $("#geoloc").html(JSON.stringify(json.currently, null, "\t"));*/
      temp_fer = json.currently.temperature;
        });  //function json and  getJSON
    }); //function(position)
} /*if (navigator.geolocation)*/ 
   /* The explanation  of not having temp as a global variable is that getLocation is an unsynchronized function 
var latitude, 

navigator.geolocation.getCurrentPosition(function(position) {
  latitude = position.coords.latitude;
  longitude = position.coords.longitude;
  console.log(latitude, longitude); // works here
  logThePosition(latitude, longitude);

function logThePosition(latitude, longitude) {
  console.log(latitude, longitude); // works here too

console.log(latitude, longitude); // undefined here
    function weather (temp_fer,json) {
       var iconURL = "";
      switch (json.currently.icon) {
        case "clear-day":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Antu_weather-clear.svg/240px-Antu_weather-clear.svg.png";
        case "clear-night":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Antu_weather-clear-night.svg/240px-Antu_weather-clear-night.svg.png";
        case "rain":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Antu_weather-showers-scattered.svg/240px-Antu_weather-showers-scattered.svg.png";
        case "snow":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Antu_weather-snow-scattered.svg/240px-Antu_weather-snow-scattered.svg.png";
        case "sleet":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Antu_weather-freezing-rain.svg/240px-Antu_weather-freezing-rain.svg.png";
        case "wind":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Emoji_u1f32b.svg/240px-Emoji_u1f32b.svg.png";
        case "fog":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Antu_weather-mist.svg/240px-Antu_weather-mist.svg.png";
        case "cloudy":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Antu_weather-many-clouds.svg/240px-Antu_weather-many-clouds.svg.png";
        case "partly-cloudy-day":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Antu_weather-clouds.svg/240px-Antu_weather-clouds.svg.png";
        case "partly-cloudy-night":
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Antu_weather-clouds-night.svg/240px-Antu_weather-clouds-night.svg.png";
          iconURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/Antu_weather-none-available.svg/240px-Antu_weather-none-available.svg.png";
       $("#icon").attr("src", iconURL);
      temp_cei= Math.round((temp_fer-32)*5/9);
      $("#temp").html(Math.round(temp_cei) +"   ceilsus");
      $("body").css('background-image', 'url("https://ak3.picdn.net/shutterstock/videos/10340813/thumb/1.jpg?i10c=img.resize(height:160)")');
       else if(temp_cei<20){
       $("body").css('background-image', 'url("http://cdn.weatheravenue.com/img/background/background.jpg")');
      else if(temp<30)
      $("body").css('background-image', 'url("http://image.imgpaper.com/-desert-images-1920_1200.jpg")');
      else {
    } //else
      $(".timezone").html(json.timezone)  ;

    } //weather function
   /*fix the temp button and the bootstrap and onclick event  row columns and the background from the old one https://codepen.io/firou1925/pen/BRXrEj*/
   }); //<!--document.ready function-->

  $("#temp").on("click", function(){
      // Only change code below this line.
    if (unite =="cei"){
      $("#temp").html(temp_fer +"  Fahrenheit ");
      $("#temp").html( temp_cei +"  Celsius");
     }); //on click function 

🕑 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.