Local Weather
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 - 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); }) }) })
});
Developer | Jimmy Lin |
Username | odylic |
Uploaded | December 11, 2022 |
Rating | 3 |
Size | 2,560 Kb |
Views | 4,048 |
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!
Name | Size |
TwitchTV JSON API 2 | 2,691 Kb |
Random Quote Generator | 2,674 Kb |
Calculator | 2,544 Kb |
Tic Tac Toe Game | 2,701 Kb |
Twitch JSON API | 2,556 Kb |
Portfolio Trial 1 | 3,730 Kb |
RPG Style Text Dialogue | 2,635 Kb |
Firefly tribute | 2,476 Kb |
Pomodoro Clock | 2,384 Kb |
Simon Game | 3,485 Kb |
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!
Name | Username | Size |
Two joint circles - One element | Berdejitendra | 1,704 Kb |
Responsive Pricing Table | Jeremycaris | 2,690 Kb |
Gulpfile | Aimhigherwebdesign-amy | 1,765 Kb |
SVG Animation | Pollardld | 3,133 Kb |
Faux column absolute wrapper | Yurimorini | 1,823 Kb |
Apple website | Jds317 | 1,835 Kb |
Simple Weather App | Cmwebby | 0 Kb |
Css3 only dropdown menu | Riogrande | 2,519 Kb |
Simple Buttons | Haydenmills | 1,750 Kb |
A Pen by Rob Levin | Roblevin | 2,787 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!