Weather
How do I make an weather?
What is a weather? How do you make a weather? This script and codes were developed by Steven on 31 July 2022, Sunday.
Weather - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Weather</title> <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container text-center outercontainer"> <h1 class="title">Volv Zipline</h1> <h3 class="title sub">Local Weather</h2> <div class="well main" style="width:90%; margin:auto;"> <ul class="list-inline topline"> <li class="icon">Icon</li> <li class=" temp"data-toggle="tooltip" title="Convert">Temp</li> </ul> <ul class="list-inline bottomline"> <li class ="detailbox loc">Loc</li> <li class ="detailbox sky">Sky</li> <li class ="detailbox wind">Wind</li> </ul> <div id="citation"><cite><a href="http://www.icndb.com/">http://www.icndb.com/</a></cite></div> </div>
<div class="error"></div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Weather - Script Codes CSS Codes
body { background: center fixed; background-color: #e0e0e0;; background-repeat: no-repeat; background-size: cover;
}
.outercontainer { width:90%;
}
h1, h3 { color: white; font-weight: bold;
}
.main { margin-top: 20px!important; border-radius: 10px; background: rgba(100, 100, 255, 0.8); max-width: 800px!important; min-width: 250px; margin-bottom:100px!important;
}
topline {
}
.temp { font-size:40px; color:black
}
.temp:hover { color:rgba(200, 150, 000, 1); box-shadow: 1px 1px 1px 1px black;
}
.temp:active { box-shadow: 1px 1px 1px 1px silver;
}
.icon {
}
.tmppic { height: 70px; margin-bottom:10px;
}
.bottomline { margin-top: -10px;
}
.detailbox { background: rgba(200, 200, 200, .6); border:solid none; border-radius:50px; padding:10px 30px 10px 30px!important; box-shadow: 5px 5px 10px 1px rgba(0,0,0,0.3); margin-bottom:10px; font-size:18px;
}
.loc { text-align: left;
}
#citation { padding-top:0px; padding-bottom:0px; margin-bottom:-15px; margin-top:0px; font-size:12px; text-align: right; opacity: 0.5; color:black;
}
#citation a { color:black; font-weight:bold;
}
#error { color:white; font-size:30px;
}
Weather - Script Codes JS Codes
$(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip();
});
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { //Success getWeather(position.coords["latitude"], position.coords["longitude"]); }, function(pos) { //Error $("#error").html("Geolocate - FAIL<br>Using lat - 55.867674, long - -3.682519"); getWeather(55.867674, -3.682519); //Sunny Sunny Whitburn });
}
var weatherText = "";
var temp = 0;
var unit = "C";
var timeSearchString = "";
function getWeather(lat_in, long_in) { var api_key = "bc64c8986f8de2a1383b606993328a02"; //Dont Steal plz k thx var weatherAPI = "http://api.openweathermap.org/data/2.5/weather?callback=?" weatherGET = $.getJSON(weatherAPI, { appid: api_key, lat: lat_in, lon: long_in, units: "metric" }) .done(function(data) { var resultString = ""; for (k in data) { // Debug String of object. if (data[k]) //Rest are null I checked. resultString += "<b>" + k + "</b>" + ": " + data[k] + "<br>"; } //$("#images").html(resultString); //Debug var theWeather = { humidity: data.main.humidity, pressure: data.main.pressure, temp: data.main.temp, name: data.name, //(whitburn) country: data.sys.country, //(GB) sunrise: data.sys.sunrise, sunset: data.sys.sunset, description: data.weather[0].description, //Broken Clouds, icon: "http://openweathermap.org/img/w/" + data.weather[0].icon + ".png", id: data.weather[0].id, //803? main: data.weather[0].main, //Clouds deg: data.wind.deg, speed: data.wind.speed, update: data.dt }; console.log(theWeather.sunrise, " - ", theWeather.sunset); var curHour = new Date().getHours(); var sunriseHour = new Date(theWeather.sunrise*1000).getHours(); var sunsetHour = new Date(theWeather.sunset*1000).getHours(); console.log ("curHour - " +curHour+ ", sunriseHour - ", +sunriseHour+ ", sunsetHour - " +sunsetHour); if (curHour > sunriseHour && curHour < sunsetHour) { console.log("Using day"); timeSearchString = "sunrise morning"; $(".main").css("background", "rgba(100, 100, 255, 0.8)"); } if (curHour < sunriseHour || curHour > sunsetHour){ console.log("Using night"); timeSearchString = "night"; $(".main").css("background", "rgba(50, 50, 255, .9)"); } if (curHour == sunriseHour || curHour == sunriseHour+1 || curHour == sunriseHour-1) { console.log("Using sunrise"); timeSearchString = "dawn sunrise"; $(".main").css("background", "rgba(100, 100, 255, 0.8)"); } if (curHour == sunsetHour || curHour == sunsetHour+1 || curHour == sunsetHour-1) { console.log("Using dusk sunset"); timeSearchString = "dusk sunset"; $(".main").css("background", "rgba(100, 100, 255, 0.8)"); } timeSearchString += " epic scene"; var bearings = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"]; var bearing = bearings[Math.floor(data.wind.deg / (360 / 8))]; $(".icon").html("<img class='tmppic' src='" + theWeather.icon + "' alt='" + theWeather.description + "'>"); $(".temp").html(Math.floor(theWeather.temp) + "°C"); $(".sky").html(theWeather.description.split(" ").map(CamelCase).join(" ")); $(".wind").html(bearing + " " + Math.floor(theWeather.speed) + " Knots"); $(".loc").html(theWeather.name + ", " + theWeather.country); temp = theWeather.temp; weatherText = theWeather.description.toString(); doBackground(); });
}
function CamelCase(str) { return str[0].toUpperCase() + str.slice(1);
}
function doBackground() { var accountKey = "y/SXvpabxaJnY/d0/MMMGcWiWxKWwlTTFDeh9c9FDG0="; //Secret var accountKeyEncoded = btoa(":" + accountKey); var requestStr = "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%27" + encodeURI(weatherText+ " " +timeSearchString) + "%27&ImageFilters=%27Style%3Aphoto%27&$top=50&$format=json"; function setHeader(xhr) { xhr.setRequestHeader('Authorization', "Basic " + accountKeyEncoded); } $.ajax({ url: requestStr, timeout: 3000, beforeSend: setHeader, error: doBackground }) .done(function(data, textStatus, xhr) { // .FileSize. In Bytes //Remove headers xhr.setRequestHeader("Authorization", ""); pickImage(); function pickImage() { do { var which = Math.floor(Math.random() * 50); var url = data.d.results[which].MediaUrl; var fileSize = Math.floor(data.d.results[which].FileSize/1024); if (fileSize > 1000) { console.log("Rejected - too big -> "+fileSize+ "Kb" + which + " - " + url); } } while (fileSize > 1000); loadImage(url, which); }; function loadImage(url, which) { var img = new Image(); img.onload = function() { console.log("Load pic " +which+ " - " +url); $("body").css("background-image", "url(" + url + ")"); $("#citation").html("<cite><a href='" + url + "'>Background Source</a></cite>"); }; img.onerror = function() { console.log("Image loading failed - " +which+ " - " +url); pickImage(); } //Try given pic img.src = url;
}
console.log(data);
}); $(".temp").on("click", function() { if (unit == "C") { // Do farenheit conversion temp = ((9 / 5) * temp) + 32; $(".temp").html(Math.floor(temp) + "°F"); unit = "F"; } else { // To Celsius temp = (temp - 32) * (5 / 9); $(".temp").html(Math.floor(temp) + "°C"); unit = "C"; } });
}
Developer | Steven |
Username | volv |
Uploaded | July 31, 2022 |
Rating | 3 |
Size | 4,445 Kb |
Views | 58,696 |
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 |
JSRange | 3,245 Kb |
Midas Gift Rolls - Updating | 2,897 Kb |
Zelda | 15,850 Kb |
Twitch Status | 4,190 Kb |
WK 15 Exercises | 9,460 Kb |
Midas Odds | 6,237 Kb |
Recursive Multiplication | 2,119 Kb |
A Pen by Steven | 2,755 Kb |
Closure Example | 2,443 Kb |
Reddit Spoiler Markdown | 2,077 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 |
Banner Ad | Raquellorenzana | 4,172 Kb |
Scroll to top button | DominicFrancois | 3,743 Kb |
Scrolling Horizontal Isotope | Bramus | 2,017 Kb |
Mandelbrot Fractal | _Billy_Brown | 2,706 Kb |
Parallax with only CSS | Thulioph | 2,297 Kb |
Full page table inside the grid | Twikito | 1,864 Kb |
RWD Conversion Practice | Jxqr97 | 2,743 Kb |
Automatic scroll | Skeurentjes | 4,042 Kb |
HTML5 Breakout | Jaysalvat | 4,873 Kb |
GrcJS | Vino6 | 2,047 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!