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 |
Pomodoro Clock | 2,384 Kb |
Firefly tribute | 2,476 Kb |
RPG Style Text Dialogue | 2,635 Kb |
Mark Down Previewer | 3,062 Kb |
Twitch JSON API | 2,556 Kb |
Wikipedia Viewer | 2,333 Kb |
Local Weather | 2,560 Kb |
Random Quote Generator | 2,674 Kb |
Simon Game | 3,485 Kb |
TwitchTV JSON API 2 | 2,691 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 |
CSS Grid Overlay | Cliffpyles | 3,090 Kb |
Weather App | OmranAbazid | 2,596 Kb |
IbrahimJabbari-Effect21 | Ibrahimjabbari | 1,882 Kb |
Donut Chart example - MorrisJS | Capelo | 2,385 Kb |
Twinkling Stars | Ripley6811 | 2,750 Kb |
Scroll to top button | DominicFrancois | 3,743 Kb |
A Pen by Markku Lehmonen | SharpDal | 7,804 Kb |
A cube | KyleDavidE | 18,627 Kb |
Pattern lab logo | TimPietrusky | 3,666 Kb |
Personal Website Redesign v2.0 | DevItWithDavid | 5,168 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!