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

              
                <html>
	<head>
		<title>Hoxtygen Local Weather App</title>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald:300,400,500,600,700|Patua+One">
		<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="newstyle.css">
	</head>

	<body>
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="heading text-center">
						<h1>Local Weather App</h1>
					</div>
				</div>
			</div><!--row ends-->
			<div class="row">
<!--					<h3>Column 1</h3>-->
					<div class="col-md-4">
					<div class="wrapper">
							<div class="info-box center-block update">
								<h2>Weather Update</h2>
							</div>
						</div>
					</div>
					<div class="col-md-4">
						<div class="wrapper">
							<div class="info-box center-block">
								<h3 id="location"></h3>
							</div>
						</div>
					</div>
					<div class="col-md-4">
					<div class="wrapper">
							<div class="info-box center-block display-none">
								<h3>Information Box</h3>
							</div>
						</div><!--wrapper ends-->
					</div>
			</div>
			<div class="row">
					<div class="col-md-4">
						<div class="wrapper">
							<div class="info-box center-block">
								<span id="temperature"></span>
								<button type="button" id="btn">C</button>
							</div>
						</div><!--wrapper ends-->
					</div>
					<div class="col-md-4">
						<div class="wrapper">
							<div class="info-box center-block">
								<h3 id="time">Information Box</h3>
								<!-- <p>Local Time</p> -->
							</div>
						</div><!--wrapper ends-->
					</div>
					<div class="col-md-4">
						<div class="wrapper">
							<div class="info-box center-block">
								<div id="image-container">
									<!-- <img src="#" alt="" id="image"> -->
								</div>
								<h3 id="weather-condition"></h3>
							</div>
						</div><!--wrapper ends-->
					</div>
			</div><!--row ends-->
			<div class="row">
					<div class="col-md-4">
					<div class="wrapper">
							<div class="info-box center-block display-none">
								<h3>Information Box</h3>
							</div>
						</div><!--wrapper ends-->
					</div><!--col-md-4 ends-->
					<div class="col-md-4">
					<div class="wrapper">
							<div class="info-box center-block display-none">
								<h3>Information Box</h3>
							</div>
						</div>
					</div><!--col-md-4 ends-->
					<div class="col-md-4">
					<div class="wrapper">
							<div class="info-box center-block display-none">
								<h3>Information Box</h3>
							</div>
						</div>
					</div><!--col-md-4 ends-->
			</div><!--row ends-->
		</div><!--container ends-->

		<div class="container text-center" id="footer">
			<div class="row text-container">
				<p>Designed by <a href="#">Idowu Wasiu</a></p>
			</div>
		</div>

		<script src="js/newjs.js"></script>

	</body>
</html>
              
            
!

CSS

              
                body 		{
	background:  -moz-linear-gradient( top, #13547a,  #80d0c7);
	background: -webkit-linear-gradient(top, #13547a, #80d0c7);
	background: -o-linear-gradient(top, #13547a, #80d0c7);
	background: linear-gradient(top, #13547a, #80d0c7);
	font-family: "Oswald";
	color: #fff;
}

p 			{
	font-size: 14px;
	line-height: 1.5;
}

.heading {
	font-family: "Patua One";
	padding-top: 10px;
	padding-bottom: 10px;
	
}

.heading h1 {
	font-size: 40px;
	letter-spacing: 2px;
	text-transform: uppercase;
}

.wrapper .center-block span#temperature 		{
	display: inline-block;
	font-size: 30px;
}


/* .wrapper .center-block button 			{
	font-size: 30px;
	background: transparent;
	border: none;
	margin-left: 5px;
	height: 40px;
	width: 40px;
	border-radius: 50%;
	position: absolute;
	top: 47%;
	left: 57%;
} */

button 		{
	border: none;
	padding: 10px;
	background: transparent;
	font-size: 30px;
}

 .wrapper {
	margin-top: 25px;
	padding-top: 8px;
	padding-bottom: 8px;
} 
 
.info-box {
	/* border: 1px solid mediumseagreen; */
	width: 200px;
	height: 200px;
	border-radius: 50%;
	/* background: #00b230; */
	background: #555;
	text-align: center;
	display: flex;
	justify-content: center;
	align-items: center;
}

/* .info-box h3, .info-box h2 {
	padding-top: 80px;
} */

#wrapper 		{
	border: 2px solid magenta;
}

.display-none 			{
	display: none
}

#footer 		{
	width: 100%;
	margin-top: 15px;
}

.text-container 		{
	padding-top: 15px;
	padding-bottom: 15px;
	background-color: #222;
	letter-spacing: 1px;
}

#footer p 			{
	font-size: 16px;
	color: #fff;
}

#footer a 		{
	font-size: 18px;
	color: #60768b;
}


#footer a:hover 			{
	text-decoration: none;
	color: rgba(255, 255, 255, 0.5);
}
              
            
!

JS

              
                window.onload = function () {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
      var longt = position.coords.longitude
      var latt = position.coords.latitude

      var request = new XMLHttpRequest()
      request.open('GET', 'https://fcc-weather-api.glitch.me/api/current?lat=' + latt + '&lon=' + longt, true)
      request.onreadystatechange = function () {
        if (request.readyState === request.DONE && request.status === 200) {
          if (request.responseText) {
            var stringified = JSON.parse(request.responseText)
            console.log(stringified)
            var location = document.getElementById('location')
            location.innerHTML = stringified.name + ', ' + stringified.sys.country
             var img = document.createElement('img')
             img.src = stringified.weather[0].icon
     var src = document.getElementById("image-container");
src.appendChild(img);
            //document.getElementById('image-container').innerHTML = "<img src = 'stringified.weather[0].icon'>"
            var temp = document.getElementById('temperature')
            var temp0 = (stringified.main.temp).toFixed(0) + '&#176;'
            temp.innerHTML = temp0;
            var weatherCondition = document.getElementById('weather-condition')
            weatherCondition.innerHTML = stringified.weather[0].description
            var celsius = (stringified.main.temp).toFixed(0)
            var btn = document.getElementById('btn')
            var temp1 = convertToF(celsius)

            function convertToF (celsius) {
              var fahrenheit
              fahrenheit = (celsius * 9 / 5) + 32
              return fahrenheit + '&#176;'
            }
            convertToF(celsius)

            btn.onclick = function () {
              if (btn.innerText === 'C') {
                btn.innerText = 'F'
                temp.innerHTML = temp1
              } else if (btn.innerText === 'F') {
                btn.innerText = 'C'
                temp.innerHTML = temp0
              } else {
                btn.innerText = 'C'
                temp.innerHTML = temp
              }
            }

          } else {
            console.log("Error: Can't get any data from that source")
          }
        }
      }
      request.send()
    })
  }
}

function showTime () {
  // body...
  var date = new Date()
  var hr = date.getHours()
  var min = date.getMinutes()
  var sec = date.getSeconds()
  var session = 'AM'
  if (hr === 0) {
    hr = 12
  }

  if (hr > 12) {
    hr = hr - 12
    session = 'PM'
  }
  hr = (hr < 10) ? '0' + hr : hr
  min = (min < 10) ? '0' + min : min
  sec = (sec < 10) ? '0' + sec : sec

  var time = hr + ':' + min + ':' + sec + ' ' + session
  document.getElementById('time').innerText = time
  setTimeout(showTime, 1000)
}

showTime()

function convertToF (celsius) {
  var fahrenheit;
  fahrenheit = (celsius * 9 / 5) + 32;
  return fahrenheit;
}

convertToF(30);

              
            
!
999px

Console