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

              
                <div id='head-margin' style='height:45px;'></div>
<header style='text-align: center; margin-top: 12px;'>
 <h1>Weather In Israel</h1><br>
 <h5 id='error' style='display:none; text-align: center;'>ERROR: Please enable location settings <br> and click on the globe: <a href='https://codepen.io/guys1444/full/wEeoPL' target='_top'><i class="fa fa-globe" aria-hidden="true"></i></a></h5>
 <h2 id='locationName' style='text-align:center;'>By Location</h2>
</header>

<div style='max-width: 620px; margin: auto; margin-top: 15px; margin-bottom: 12px;'>
 <div id='weather-div' class='container' style='display:none; text-align: center'>
  <!-- @ Display None @ -->
  <div class='row'>

   <div class='row col-sm-5' style='margin:auto;'>
    <div id='temp' style='margin:auto;'>
     54F
    </div>
    <div id='high-low-div' style='margin:auto;'>
     <div class='col-sm-12' style='color:rgb(190, 44, 44)'>High<br><span id='high'>60</sapn></div>
	  <div class='col-sm-12' style='color:rgb(44, 117, 190)'>Low<br><span id='low'>50</sapn></div>
	</div>
	  </div>
	  <div class='col-sm-7 row' style='margin:auto; margin-bottom:12px;'>
	  <div style='width: 60%;'><span id='icon-name'>partly-cloudy-day</span><br><br><span id='icon'><i class="wi wi-day-cloudy"></i></span></div>
     <div id='wind' style='width:40%'>Wind Speed<br><span id='wind-speed'>5.5 m/s</span>
      <!-- Wind speed is in si m/s --><br><i class="wi wi-strong-wind"></i><span id='wind-speed'></span></div>
    </div>
   </div>
  </div>
 </div>

 <div id='btn-div' class='row'>
  <div style='margin:auto;'><button onclick="gpsW();" class='btn'>Your Local Weather <i class="fa fa-map-marker" aria-hidden="true"></i>
		</button></div>
  <div id='temp-chng' style='margin:auto; display:none'><button onclick='toggle();' class='btn'>To <span id='C-F'>Fahr </span><i class="fa fa-thermometer-three-quarters" aria-hidden="true"></i>
     </button>
  </div>
 </div>


 <div id='img-container' class='container row' style='margin:auto;'>
  <div>
   <a href='javascript:void(0)' onclick="gpsW(31.768319, 35.21371);"><img src='https://images.freeimages.com/images/large-previews/5da/jerusalem-5-1202452.jpg'>
   </a>
   <h5>Jerusalem</h5></div>
  <div>
   <a href='javascript:void(0)' onclick="gpsW(32.0853, 34.781768);"><img src='https://images.freeimages.com/images/large-previews/f82/tel-aviv-at-the-evening-1636393.jpg'></a>
   <h5>Tel Aviv</h5></div>
  <div>
   <a href='javascript:void(0)' onclick="gpsW(32.7904046, 34.989571);"><img src='https://images.freeimages.com/images/large-previews/77d/bahai-gardens-in-haifa-israel-1441477.jpg'></a>
   <h5>Haifa</h5></div>
	 <div>
   <a href='javascript:void(0)' onclick="gpsW( 29.557669, 34.951925);"><img src='https://images.unsplash.com/photo-1513590558953-0629cf672b7a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc42f2e02ac0a5f38f0468889dc047c1&auto=format&fit=crop&w=1932&q=80'></a>
   <h5>Eilat</h5></div>
 </div>
              
            
!

CSS

              
                * {
	font-family: 'lato', sans-serif;
}

a {
   color: navy;
   text-decoration: none;
}

#weather-div{
	max-width: 550px;
	padding: 5px;
	margin:auto; 
	border-style:solid;
	text-shadow:  0.5px 1px #92939F;
}
#temp{
	text-align:center;
	font-size: 65px;
	text-shadow:  0.5px 2px #92939F;
}

#high-low-div {
	font-size: 15px;
	font-weight: bold;
}

#icon i{
	font-size: 80px;
	text-shadow:  0.5px 5px #92939F;
}

#wind i{
	font-size: 60px;
	text-shadow: 0.5px 3px #92939F;
}

#btn-div {
	text-align: center;
	margin:auto;
	margin-top: 10px;
	margin-bottom: 10px;
	max-width:300px; 
}

.btn:hover {
	opacity: 1;
	font-size: 16.5px;
	box-shadow: 0px 0px 8px 3px rgba(0,0,0,0.4);
}

#img-container {
	max-width: 220px;
	margin:auto; 
}

#img-container div {
	 width: 300px;
 	hight: 300px;
	margin: 1%;
}

#img-container img {
 width: 300px;
 hight: 300px;
	opacity: 0.8;
}

#img-container img:hover {
	opacity: 1;
}

#img-container h5 {
	text-align: center;
}


              
            
!

JS

              
                /*
Notes:
Implement search bar
improve opening animations
Improve w/ lovations that show invalid adress
*/

// </> Convert To Fahrenheit & Toggle
var fahrIsOn = flase;
var tempVal;
var highVal;
var lowVal;
var windVal;
function toggle() {
	fahrIsOn = !fahrIsOn;
	if (fahrIsOn === true) {
		//Turns To Fahrenheit
		document.getElementById("C-F").innerHTML = "Cels ";
		document.getElementById("temp").innerHTML = CF(tempVal, fahrIsOn);
		document.getElementById("high").innerHTML = CF(highVal, fahrIsOn);
		document.getElementById("low").innerHTML = CF(lowVal, fahrIsOn);
	} else {
		//Turns To Celsius
		document.getElementById("C-F").innerHTML = "Fahr ";
		document.getElementById("temp").innerHTML = CF(tempVal, fahrIsOn);
		document.getElementById("high").innerHTML = CF(highVal, fahrIsOn);
		document.getElementById("low").innerHTML = CF(lowVal, fahrIsOn);
	}
}
function CF(temp, toF) {
	if (toF === true) {
		return Math.round(temp * 1.8 + 32) + "F";
	} else {
		return Math.round(temp) + "C";
	}
}

// </> Icons
var icons = {
	"clear-day": '<i class="wi wi-day-sunny"></i>',
	"clear-night": '<i class="wi wi-night-clear"></i>',
	rain: '<i class="wi wi-raindrops"></i>',
	snow: '<i class="wi wi-snowflake-cold"></i>',
	sleet: '<i class="wi wi-sleet"></i>',
	wind: '<i class="wi wi-strong-wind"></i>',
	fog: '<i class="wi wi-fog"></i>',
	cloudy: '<i class="wi wi-cloudy"></i>',
	"partly-cloudy-day": '<i class="wi wi-day-cloudy"></i>',
	"partly-cloudy-night": '<i class="wi wi-night-partly-cloudy"></i>'
};

// </> Function taking lat and long output weather info
function gpsW(lati, long) {
	// Google Reverse Geocoding
	function revGeo(a, b) {
		$.ajax({
			url: "https://maps.googleapis.com/maps/api/geocode/json?latlng=" +
				a +
				"," +
				b +
				"&key=AIzaSyBaqMJdkuOQ_8LVjJ6iLR393y-Av3anpyc",
			data: { result_type: "locality" },
			success: function(data) {
				var cityName = data.results[0].formatted_address;
				document.getElementById("locationName").innerHTML = cityName;
				console.log(cityName);
			}
		});
	}
	// DarkSky API
	function darkSky(x, y) {
		$.ajax({
			dataType: "jsonp",
			type: "GET",
			url: "https://api.darksky.net/forecast/357192f319bab866a1137185c69596cb/" +
				x +
				"," +
				y,
			data: {
				exclude: "hourly, minutely, flags, alerts",
				units: "si"
			},
			success: function(result) {
				console.log(result);
				$("#error").hide(750);
				$("#weather-div").fadeIn(2500);
				$("#temp-chng").show(750);
				$('#head-margin').hide(1500);
				var current = result.currently;
				tempVal = current.temperature;
				highVal = result.daily.data[0].temperatureMax;
				lowVal = result.daily.data[0].temperatureMin;
				// console.log(result.currently);
				// console.log(result.daily.data[0]);
				document.getElementById("temp").innerHTML = CF(current.temperature, fahrIsOn);
				document.getElementById("high").innerHTML = CF(result.daily.data[0].temperatureMax, fahrIsOn);
				document.getElementById("low").innerHTML = CF(result.daily.data[0].temperatureMin, fahrIsOn);
				document.getElementById('icon-name').innerHTML = current.icon;
				document.getElementById("icon").innerHTML = icons[current.icon];
				document.getElementById('wind-speed').innerHTML = current.windSpeed + ' m/s'; // call function
			}
		});
	}
	// GPS request
	if (lati === undefined || long === undefined) {
		navigator.geolocation.getCurrentPosition(
			function(x) {
				lati = x.coords.latitude;
				long = x.coords.longitude;
				// console.log(lati, long);
				darkSky(lati, long);
				revGeo(lati, long);
			},
			function(error) {
				$.ajax({  //ip based location tracking
					dataType: "json",
					type: "GET",
					url: "http://ip-api.com/json",
					data: {},
					success: function(ip) {
						lati = ip.lat;
						long = ip.lon;
						console.log(ip);
						darkSky(lati, long);
						revGeo(lati, long);
					}
				});
				$("#error").show(1000); //show error in header
			}
		);
	} else {
		// console.log(lati, long);
		darkSky(lati, long);
		revGeo(lati, long);
	}
}

              
            
!
999px

Console