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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <!-- 
TO DO:
* MOON CHANGING ACCORDING TO PHASE
* FOOTER MODIFY THE MENU CODE TO EXPAND ON THE BOTTOM
* HOW TO ACCESS THE TIME OF DAY FOR THE SEARCHED LOCATION? ...COMPARE SUNSET TIMES?
* TOGGLING THE F & C VALUES, ONLY WORKS FOR THE FIRST SEARCH...
*
-->

<body>
	<div class="header col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div class="title col-xs-6 col-sm-6 col-md-6 col-lg-6">
			<h2><a href="https://www.freecodecamp.com/about" target="blank" class="farts">freeCodeCamp(&#128293;)</a> Local Weather App</h2>
		</div>
		<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
			<div class="search">
				<input class="from-control" id="searchTerm" placeholder="Another Location?" />
				<button class="btn btn-primary" type="button" id="search">submit</button>
			</div>
		</div>
	</div>
	<div class="allOfIt">
		<div class="blocks">
			<div class="iconBlock col-xs-4 col-xs-offset-4 col-sm-4 col-sm-offset-4 col-md-4 col-md-offset-4 col-lg-4 col-lg-offset-4" title="">
			</div>
			<div class="tempBlock col-xs-4 col-xs-offset-4 col-sm-4 col-sm-offset-4 col-md-4 col-md-offset-4 col-lg-4 col-lg-offset-4" title="Change measurement?">
				<center>
					<h1></h1>
					<h4></h4>
					<h3></h3>
					<h5></h5>
				</center>

			</div>


		</div>

		<div class="timeOfDay">
			<div id="day" class="col-xs-8 col-xs-offset-2 col-sm-4 col-sm-offset-4 col-md-4 col-md-offset-4 col-lg-4 col-lg-offset-4">
			</div>
			<div id="night" class="col-xs-8 col-xs-offset-2 col-sm-4 col-sm-offset-4 col-md-4 col-md-offset-4 col-lg-4 col-lg-offset-4">
			</div>
		</div>
	</div>
	<div class="footsy col-xs-12 col-sm-12 col-md-12 col-lg-12">
		Created by me, <a href="http://www.spazcool.com/" target="blank" id="created">Douglas Wright</a>.
	</div>
</body>
              
            
!

CSS

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

.header {
	float: left;
	clear: left;
	background-color: navy;
	background-image: radial-gradient(ellipse farthest-corner at 50em , #00FFFF 0%, rgba(0, 0, 255, 0) 50%, #003366 95%);
	top: 0%;
	min-height: 3em;
	margin-bottom: ;
	text-align: ;
	color: ;
	position: fixed;
	z-index: 5;
	padding-top: 1em;
	padding-bottom: 1em;
	/*width: 100%;
	height: 100%;*/
	/*color: #FFFFFF; */
	/* display: table;*/
	/*overflow: auto;*/
	/*border: 5px pink dotted;*/
}

.farts{
	color: white;
	text-decoration: none;
}
.search {
	float: right;
	margin-top: 2%;
}

.from-control {
	color: black;
}

h1 {
	font-size: 6em;
	text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

h2{
	font-size: 2em;
	
}
h3 {
	font-size: 1em;
	text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
h4 {
	font-size: 6em;
	text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

h5 {
	font-size: 1em;
	text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}


/*WEATHER INFOR*/

.blocks {
	clear: left;
	top: 25%;
	/*border: dotted white 15px;*/
}

.iconBlock {
	position: absolute;
	top: 25%;
	z-index: 2;
	/*border: dotted red 5px;*/
}

.tempBlock {
	position: absolute;
	top: 50%;
	z-index: 3;
	margin-top: 3%;
	min-height: 20px;
	cursor: pointer;
	cursor: hand;
	/*border: dotted blue 5px;*/
}


/*SUN OR MOON*/

.timeOfDay {
	z-index: 0;
	/*border: dotted orange 5px;*/
}

#day {
	top: 25%;
	position: absolute;
	/*border: dotted yellow 5px;*/
}

#night {
	top: 25%;
	position: absolute;
	/*border: dotted white 5px;*/
}

.footsy {
	float: left;
	clear: left;
	background-color: ;
	/*background-image: radial-gradient(ellipse farthest-corner at 1em , #FFFFFF 0%, rgba(0, 0, 255, 0) 0%, #FFFFFF 1000%); */
	bottom: 0%;
	min-height: 3em;
	margin-bottom: ;
	text-align: ;
	color: ;
	position: fixed;
	z-index: 4;
	padding-top: 1em;
	padding-bottom: 1em;
	font-size: 0.75em;
	/*width: 100%;
	height: 100%;*/
	/*color: #FFFFFF; */
	/* display: table;*/
	/*overflow: auto;*/
	/*border: 5px pink dotted;*/
}
              
            
!

JS

              
                	var sunset = 0;
	var sunsetS = 0;
	var myHour = 0;
	$(document).ready(function() {

		//TEXT TOGGLER FOR TEMP VALUE
		$.fn.toggleText = function(t1, t2) {
			if (this.html() == t1) this.html(t2);
			else this.html(t1);
			return this;
		};

		//SEARCH FOR A CITY
		$("#search").click(function() {
			var searchTerm = $("#searchTerm").val();
			var url = "http://api.openweathermap.org/data/2.5/find?q=" + searchTerm + "&appid=adda7e0e1754a7e616e6eed694bcdf0e";
			//GRAB THE COORDS AND RUN IT AGAIN, SOLELY TO ACCESS THE SUNSET VALUE
			$.getJSON(url, function(data3) {
				var lat2 = data3.list[0].coord.lat;
				var long2 = data3.list[0].coord.lon;
				var api2 = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat2 + "&lon=" + long2 + "&appid=adda7e0e1754a7e616e6eed694bcdf0e";
				//LAYERED NICE AND TIGHT
				$.getJSON(api2, function(data4) {
					//WEATHER 
					var weatherType = data4.weather[0].description;
					var weatherIcon = data4.weather[0].icon;
					var weatherId = data4.weather[0].id;
					var windspeed = data4.wind.speed;
					var humidity = data4.main.humidity;
					//TEMP
					var kelvin = data4.main.temp;
					var farenheit = kelvin * 9 / 5 - 459.67;
					var celcius = kelvin - 273.15;
					var deg = String.fromCharCode(176);
					//LOCATION
					var country = data4.sys.country;
					var city = data4.name;
					//TIME DIFFERENCE
					sunsetS = data4.sys.sunset;
					var diffOfUTC = sunset - sunsetS;
					var diffToHour = (diffOfUTC / 60) / 60;
					var searchTime = myHour + diffToHour;
					if (searchTime > 24) {
						searchTime -= 24;
					}
					
					if (5 <= searchTime && searchTime <= 18) {
						$("#night").html("");
				$("#day").html('<img src="http://hayot.tj/images/sun2.jpg" width="100%" height="auto">');
				$("body").css("background-color", "#00BFFF");
				$(".wrapper").css("color", "black");
			} else {
					$("#day").html("");
				$("#night").html('<img src="https://66.media.tumblr.com/a5d8bfa916b298aea1568b6b5c59f720/tumblr_mkfwjeFsim1s5jjtzo1_1280.png" width="100%" height="auto">');
				$("body").css("background-color", "black");
			}
					console.log("diffOfUTC: " + diffOfUTC + " | diffToHour: " + diffToHour + " | searchTime: " + searchTime);
					//TESTING
					//console.log("SEARCHED sunset: " + sunset + " | sunsetS: "+ sunsetS + " a problem of scope...");

					//PUSH THE RELEVANT ICON & TEMP TO THE DIVS
					//MY WEATHER ICONS
					switch (weatherId) {
						//THUNDERSTORMS
						case 200:
						case 201:
						case 202:
						case 210:
						case 211:
						case 212:
						case 221:
						case 230:
						case 231:
						case 232:
							$(".iconBlock").html("<img src= 'http://orig06.deviantart.net/5cd5/f/2016/269/0/e/aze_bluebolt18_cryo_by_spazcool-daixlpk.png' width='100%'>");
							break;

							//RAIN & DRIZZLE
						case 300:
						case 301:
						case 302:
						case 310:
						case 311:
						case 312:
						case 313:
						case 314:
						case 321:
						case 500:
						case 501:
						case 502:
						case 503:
						case 504:
						case 511:
						case 520:
						case 521:
						case 522:
						case 531:
							//MAY NEED SOME FIDDLING FOR SIZE, OPACITY, ETC
							$(".iconBlock").html("<img src= 'http://orig11.deviantart.net/addd/f/2016/288/d/f/rain4_by_spazcool-dal2b5w.png' width='100%'>");
							break;

							//SNOW
						case 600:
						case 601:
						case 602:
						case 611:
						case 612:
						case 615:
						case 616:
						case 620:
						case 621:
						case 622:
							$(".iconBlock").html("<img src= 'http://orig07.deviantart.net/a224/f/2016/288/0/6/snowsssss_by_spazcool-dal2c50.png' width='100%'>");
							break;

							//ATMOSPHERE
						case 701:
						case 711:
						case 721:
						case 731:
						case 741:
						case 751:
						case 761:
						case 762:
						case 771:
						case 781:
							$(".iconBlock").html("<img src= 'http://orig01.deviantart.net/20dd/f/2016/288/b/6/cloud_black_by_spazcool-dal2e8r.png' width='100%'>");
							break;

							//CLOUDY
						case 801:
						case 802:
						case 803:
						case 804:
							$(".iconBlock").html("<img src= 'http://img08.deviantart.net/eb53/i/2016/288/f/6/cloud1_by_spazcool-dal26sj.png' width='100%'>");
							break;

							//WINDY
						case 905:
						case 951:
						case 952:
						case 953:
						case 954:
						case 955:
						case 956:
							$(".iconBlock").html("<img src= 'http://orig13.deviantart.net/b8c0/f/2016/288/6/8/wind_by_spazcool-dal2fwe.png' width='100%'>");
							break;

							//EXTREME
						case 900:
						case 901:
						case 902:
						case 903:
						case 904:
						case 906:
						case 957:
						case 958:
						case 959:
						case 960:
						case 961:
						case 962:
							$(".iconBlock").html("<img src= 'http://orig04.deviantart.net/d5f3/f/2016/288/c/c/tornado_by_spazcool-dal2gl7.png' width='100%'>");
							break;

							//CLEAR SKY OR NON-CODED EVENT
							//WILL NEED TO MODIFY THIS SO THAT THE .attr IS RESTING SOMEWHERE ELSE
						default:
							$(".iconBlock").html("<img src= 'https://upload.wikimedia.org/wikipedia/commons/5/59/Empty.png' width='100%'>");
					}

					$("h1").html("");
					$("h3").html("");
					$("h4").html(farenheit.toFixed(0) + deg + "F");
					$("h5").html(city + ", " + country + "<br><br><i>" + weatherType + "</i>");

					//TOGGLER 
					$("h4").click(function() {
						$(this).toggleText(farenheit.toFixed(0) + deg + "F", celcius.toFixed(0) + deg + "C");
					});

				});
			});
		});

		//GRAB LAT & LONG FROM MACHINE
		//GIVES CURRENT GEOLOCATION DATA FROM THIS IP-API.COM
		$.getJSON("http://ip-api.com/json", function(data2) {
			var lat = data2.lat;
			var long = data2.lon;
			var tZone = data2.timezone;
			var api = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + "&appid=8e072ad976ee4c5d0d633a49e44598ee";

			//GRAB THE INFO FROM OPENWEATHERAPI
			$.getJSON(api, function(data) {
				//WEATHER 
				var weatherType = data.weather[0].description;
				var weatherIcon = data.weather[0].icon;
				var weatherId = data.weather[0].id;
				var windspeed = data.wind.speed;
				var humidity = data.main.humidity;
				//TEMP
				var kelvin = data.main.temp;
				var farenheit = kelvin * 9 / 5 - 459.67;
				var celcius = kelvin - 273.15;
				var deg = String.fromCharCode(176);
				//LOCATION
				var country = data.sys.country;
				var city = data.name;
				sunset = data.sys.sunset;

				//TESTING
				console.log("sunset: " + sunset);
				//PUSH THE RELEVANT ICON & TEMP TO THE DIVS
				//MY WEATHER ICONS

				switch (weatherId) {
					//THUNDERSTORMS
					case 200:
					case 201:
					case 202:
					case 210:
					case 211:
					case 212:
					case 221:
					case 230:
					case 231:
					case 232:
						$(".iconBlock").html("<img src= 'http://orig06.deviantart.net/5cd5/f/2016/269/0/e/aze_bluebolt18_cryo_by_spazcool-daixlpk.png' width='100%'>");
						break;

						//RAIN & DRIZZLE
					case 300:
					case 301:
					case 302:
					case 310:
					case 311:
					case 312:
					case 313:
					case 314:
					case 321:
					case 500:
					case 501:
					case 502:
					case 503:
					case 504:
					case 511:
					case 520:
					case 521:
					case 522:
					case 531:
						//MAY NEED SOME FIDDLING FOR SIZE, OPACITY, ETC
						$(".iconBlock").html("<img src= 'http://orig11.deviantart.net/addd/f/2016/288/d/f/rain4_by_spazcool-dal2b5w.png' width='100%'>");
						break;

						//SNOW
					case 600:
					case 601:
					case 602:
					case 611:
					case 612:
					case 615:
					case 616:
					case 620:
					case 621:
					case 622:
						$(".iconBlock").html("<img src= 'http://orig07.deviantart.net/a224/f/2016/288/0/6/snowsssss_by_spazcool-dal2c50.png' width='100%'>");
						break;

						//ATMOSPHERE
					case 701:
					case 711:
					case 721:
					case 731:
					case 741:
					case 751:
					case 761:
					case 762:
					case 771:
					case 781:
						$(".iconBlock").html("<img src= 'http://orig01.deviantart.net/20dd/f/2016/288/b/6/cloud_black_by_spazcool-dal2e8r.png' width='100%'>");
						break;

						//CLOUDY
					case 801:
					case 802:
					case 803:
					case 804:
						$(".iconBlock").html("<img src= 'http://img08.deviantart.net/eb53/i/2016/288/f/6/cloud1_by_spazcool-dal26sj.png' width='100%'>");
						break;

						//WINDY
					case 905:
					case 951:
					case 952:
					case 953:
					case 954:
					case 955:
					case 956:
						$(".iconBlock").html("<img src= 'http://orig13.deviantart.net/b8c0/f/2016/288/6/8/wind_by_spazcool-dal2fwe.png' width='100%'>");
						break;

						//EXTREME
					case 900:
					case 901:
					case 902:
					case 903:
					case 904:
					case 906:
					case 957:
					case 958:
					case 959:
					case 960:
					case 961:
					case 962:
						$(".iconBlock").html("<img src= 'http://orig04.deviantart.net/d5f3/f/2016/288/c/c/tornado_by_spazcool-dal2gl7.png' width='100%'>");
						break;

						//CLEAR SKY OR NON-CODED EVENT
						//WILL NEED TO MODIFY THIS SO THAT THE .attr IS RESTING SOMEWHERE ELSE
					default:
						$(".iconBlock").html("<img src= 'https://upload.wikimedia.org/wikipedia/commons/5/59/Empty.png' width='100%'>");
				}
				/*$("h4").html("");
				$("h5").html(""); */
				$("h1").html(farenheit.toFixed(0) + deg + "F");
				$("h3").html(city + ", " + country + "<br><br><i>" + weatherType + "</i>");

				//TOGGLER 
				$("h1").click(function() {
						$(this).toggleText(farenheit.toFixed(0) + deg + "F", celcius.toFixed(0) + deg + "C");
					})
					//TESTING
				console.log();

			})

			//CHECK THE TIME ON THE MACHINE FOR THE SUN AND MOON GRAPHICS
			//NEED A WAY TO CHECK FOR THE TIME FOR THE LOCATIONS THAT ARE SEARCHED
			var myDate = new Date();
			var utcHour = myDate.getUTCHours();
			myHour = utcHour - myDate.getTimezoneOffset() / 60;
			//console.log("machine hour: " + myHour);
			//SUN FOR THE DAY AND MOON FOR THE NIGHT
			if (5 <= myHour && myHour <= 18) {
				$("#day").html('<img src="http://hayot.tj/images/sun2.jpg" width="100%" height="auto">');
				$("body").css("background-color", "#00BFFF");
				$(".wrapper").css("color", "black");
			} else {
				$("#night").html('<img src="https://66.media.tumblr.com/a5d8bfa916b298aea1568b6b5c59f720/tumblr_mkfwjeFsim1s5jjtzo1_1280.png" width="100%" height="auto">');
			}
			console.log("LAST LINE - sunset: " + sunset + " | sunsetS: " + sunsetS + " a problem of scope...");
		})

	});
              
            
!
999px

Console