Local Weather

Developer
Size
2,560 Kb
Views
4,048

How do I make an local weather?

What is a local weather? How do you make a local weather? This script and codes were developed by Jimmy Lin on 11 December 2022, Sunday.

Local Weather Previews

Local Weather - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Local Weather</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
<body> <div id="header"> <h1 class="text-center title"> Local Weather</h1> <div class="left"> <h2 class="text-center" id="currentLocation">Getting location...</h2> </div> <div id="container"> <h2 class="text-center content-title" id="currentTemp">... </h2> <h6 class="text-center"><a href="#" id="toggle">Toggle C/F</a></h6> <div class="content-body"> <p class="text-center" id='high-low'></p> <p class="text-center" id='currentWeather'>...</p> </div>
</div>
</body> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Local Weather - Script Codes CSS Codes

.title { font-family: lobster; font-size: 50px;
}
#container { margin-left:auto; margin-right:auto; border-style: solid; width:25%; border-color: grey;
}
body { font-family: Times;
}
p{ font-size:30px;
}
h6{ font-size:20px;
}

Local Weather - Script Codes JS Codes

//May work better in Safari in pulling the ipinfo.io
var API_KEY = "7c9a747b87d4de4adb63faae45e47e53";
var cel = false;
var wd;
function displayTemp(fTemp, c){ if(c) return Math.round((fTemp-32)*(5/9))+ " C"; return Math.round(fTemp)+ " F"
}
function render(wd, cel){ var currentLocation = wd.name; var currentWeather = wd.weather[0].description; var currentTemp = displayTemp(wd.main.temp, cel); var high = displayTemp(wd.main.temp_max, cel); var low = displayTemp(wd.main.temp_min, cel); var icon = wd.weather[0].icon; $('currentTemp').prepend('<div>this is prepended</div>') $('#currentLocation').html(currentLocation); $('#currentTemp').html(currentTemp); $("#currentWeather").html(currentWeather); $('#high-low').html(high+ " / " + low); var iconSrc = "http://openweathermap.org/img/w/"+ icon+ ".png"; $('#currentTemp').prepend('<img src="'+iconSrc+ '">');
}
$(function(){ var loc; $.getJSON('http://ipinfo.io', function(d){ console.log("Assigning Data") loc = d.loc.split(","); console.log(loc); $.getJSON('http://api.openweathermap.org/data/2.5/weather?units=imperial&lat='+ loc[0] + '&lon=' +loc[1]+'&APPID=' +API_KEY, function(apiData){ wd = apiData; render(apiData, cel); $('#toggle').click(function(){ cel = !cel; render(wd,cel); }) }) })
});
Local Weather - Script Codes
Local Weather - Script Codes
Home Page Home
Developer Jimmy Lin
Username odylic
Uploaded December 11, 2022
Rating 3
Size 2,560 Kb
Views 4,048
Do you need developer help for Local Weather?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Jimmy Lin (odylic) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!