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

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

              
                <!-- Scripts Needed-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"  crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<br>
  <div class="container">
    <div class="row">
      <div class="col-sm">
        <header class="col-sm text-center">
          <h1> Zalmez Weather app</h1>
        </header>
      </div>
    </div>
  </div>
<br>
<br>
<br
  <div class="container">
    <div class="row col-sm">
        <div class="col-sm"></div>
      <div class="col-sm center"  id="weather-card">
								<h3 class="text-center" id="temp"></h3>
								<h3 class="text-center" id="city"></h3> 
								<h3 id="country"></h3>
        <h3 class="text-center" id="weatherIcon"></h3>
								<img id="desc" src=""></img>
					<button type="button" class="btn btn-primary" id="swaptemp">Swap temperature unit</button>
      </div>
    <div class="col-sm"></div>
      <div>

      </div>
    </div>
  </div>
              
            
!

CSS

              
                body{
	color: white;
	background-color: darkblue;
}

#weather-card{
	background-color: #b9baad;
	align-content: center;
}

.transparent{
	background-color: transparent;
}
              
            
!

JS

              
                var api = "https://fcc-weather-api.glitch.me/api/current?";
var lat, lon;
var currentTempInCelcius;
var currentTempInFarenheit;
var tempUnit = "C";


$( document ).ready(function(){
	//console.log("Ready")
	if(navigator.geolocation){
		navigator.geolocation.getCurrentPosition(function(position){
			var currentPosition = position;
			var lat = currentPosition.coords.latitude;
			var lon = currentPosition.coords.longitude;
			getCurrentWeather(lat, lon);
		});
	}else{
		console.log("OOOPPS! Something went wrong! Location was not shared or the browser does not support geolocation");
	}
})

function getCurrentWeather(lat, lon){
	//console.log("Getting current weather");
	lat = Math.floor(lat);
	lon = Math.floor(lon);
	var weatherLink = api + "lon=" + lon + "&lat=" + lat;
	//console.log(weatherLink)
		$.ajax({
		url: weatherLink, success: function(result){
			currentTempInCelcius = result.main.temp;
			currentTempInFarenheit = currentTempInCelcius * 9 / 5 + 32;
			if(tempUnit == "F"){
				$("temp").text(Math.floor(currentTempInFerenheit + tempUnit));
			}else[]
			$("#city").text(result.name + ", " + result.sys.country);
			//$("#country").text("" + result.sys.country);
			$("#temp").text(Math.floor(result.main.temp) + tempUnit);
			//$("tempunit").text(tempUnit);
			$("desc").attr("src", url(results.weather[0].icon));
			//console.log("weather recived");
		}
	});

	$ ("#swaptemp").click(function(){
			if(tempUnit == "C"){
					tempUnit = "F";
			}else{
					tempUnit = "C";
			}
			/*if(navigator.geolocation){
					navigator.geolocation.getCurrentPosition(function(position){
					var currentPosition = position;
					var lat = currentPosition.coords.latitude;
					var lon = currentPosition.coords.longitude;
					getCurrentWeather(lat, lon);
				});
			}else{
				console.log('OOOPPS! Something went wrong! Location was not shared or the browser does not support geolocation');
			}*/
	});
	
}
              
            
!
999px

Console