Local Weather
How do I make an local weather?
FreeCodeCamp: Local Weather App. What is a local weather? How do you make a local weather? This script and codes were developed by DannyCoder on 05 November 2022, Saturday.
Local Weather - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Local Weather</title> <link href='https://fonts.googleapis.com/css?family=Roboto:400,100,900,300,500' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Fredoka+One' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css">
<link href='https://fonts.googleapis.com/css?family=Fredoka+One' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <body class="sunny">
<div class="container text-center vcenter">
<h1> Local Weather</h1>
<div class="panel panel-default"> <div class="panel-body"> <div class="row"> <div class="col-md-6 text-left"> <h3 id="city"><i class="fa fa-map-marker"></i> <span>Boston, MA</span></h3> </div> <div class="col-md-6 text-right temp-switch"> <h3><input id="switch-temp" type="checkbox" data-off-color="info" data-on-color="default" data-label-text="<i class='wi wi-thermometer'></i>" data-label-icon="<i class='wi wi-celsius'></i>" data-on-text="<i class='wi wi-fahrenheit'></i>" data-off-text="<i class='wi wi-celsius'></i>" /></h3> </div> </div> <hr> <div id="display"> <div class="row"> <div class="col-md-6" id="weather-icon-display"> <div id="weather-icon"><i class="wi wi-sleet"></i></div> </div> <div class="col-md-6" id="temperature"> <h4>Today</h4> <p><span id="temp">73</span><sup>°<span id="metric">F</span></sup></p> <h5>High: <span id="temp-max">26</span> / Low: <span id="temp-min">12</span></h5> </div> </div> </div> <hr id="hr-bottom"> <div class="row" id="weather-condition"> <div class="col-md-2 col-md-offset-1"> <h6><i class="wi wi-cloud"></i></h6> <p id="condition">Sunny</p> </div> <div class="col-md-2"> <h6><i class="wi wi-humidity"></i></h6> <p id="humidity">10%</p> </div> <div class="col-md-2"> <h6><i class="wi wi-strong-wind"></i></h6> <p id="wind">windy 20 NE</p> </div> <div class="col-md-2"> <h6><i class="wi wi-barometer"></i></h6> <p id="hpa">10 psi</p> </div> <div class="col-md-2"> <h6><i class="wi wi-showers"></i></h6> <p id="prec">10%</p> </div> </div> <hr> </div><!--/.panel-body-->
</div> <footer id="footer"> <p>© FreeCodeCamp - 2015 | User: DannyCoder | Photo Credit: Respective Owners on Flickr.com</p> </footer>
</div> <!-- /container --> <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='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Local Weather - Script Codes CSS Codes
/* bootstrap-switch - v3.3.2*/
.bootstrap-switch{display:inline-block;direction:ltr;cursor:pointer;border-radius:4px;border:1px solid #ccc;position:relative;text-align:left;overflow:hidden;line-height:8px;z-index:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.bootstrap-switch .bootstrap-switch-container{display:inline-block;top:0;border-radius:4px;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on,.bootstrap-switch .bootstrap-switch-label{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block!important;height:100%;padding:6px 12px;font-size:14px;line-height:20px}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on{text-align:center;z-index:1}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary{color:#fff;background:#337ab7}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info{color:#fff;background:#5bc0de}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success{color:#fff;background:#5cb85c}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning{background:#f0ad4e;color:#fff}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger{color:#fff;background:#d9534f}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default{color:#000;background:#eee}.bootstrap-switch .bootstrap-switch-label{text-align:center;margin-top:-1px;margin-bottom:-1px;z-index:100;color:#333;background:#fff}.bootstrap-switch .bootstrap-switch-handle-on{border-bottom-left-radius:3px;border-top-left-radius:3px}.bootstrap-switch .bootstrap-switch-handle-off{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch input[type=radio],.bootstrap-switch input[type=checkbox]{position:absolute!important;top:0;left:0;margin:0;z-index:-1;opacity:0;filter:alpha(opacity=0)}.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label{padding:1px 5px;font-size:12px;line-height:1.5}.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label{padding:5px 10px;font-size:12px;line-height:1.5}.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label{padding:6px 16px;font-size:18px;line-height:1.3333333}.bootstrap-switch.bootstrap-switch-disabled,.bootstrap-switch.bootstrap-switch-indeterminate,.bootstrap-switch.bootstrap-switch-readonly{cursor:default!important}.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label{opacity:.5;filter:alpha(opacity=50);cursor:default!important}.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container{-webkit-transition:margin-left .5s;-o-transition:margin-left .5s;transition:margin-left .5s}.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on{border-radius:0 3px 3px 0}.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off{border-radius:3px 0 0 3px}.bootstrap-switch.bootstrap-switch-focused{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label{border-bottom-left-radius:3px;border-top-left-radius:3px}
//Custom CSS
html, body { height: 100%;
}
body { background-color: #000000; font-family: 'Roboto', sans-serif; color: rgba(255,255, 255, 0.8);
}
body.sunny { background: url(https://res.cloudinary.com/dannycoder/image/upload/v1450159982/sunny_taoiok.jpg) fixed center bottom no-repeat;
}
body.night { background: url(https://res.cloudinary.com/dannycoder/image/upload/v1450159982/night_obgscx.jpg) fixed center bottom no-repeat;
}
body.rainy { background: url(https://res.cloudinary.com/dannycoder/image/upload/v1450159983/rainy_fx8qwt.jpg) fixed center bottom no-repeat;
}
body.snow { background: url(https://res.cloudinary.com/dannycoder/image/upload/v1450159983/snow_omwufo.jpg) fixed center bottom no-repeat;
}
body.mist { background: #000000 url(https://res.cloudinary.com/dannycoder/image/upload/v1450159982/mist_q624to.jpg) fixed center bottom no-repeat;
}
.container { max-width: 900px; max-width: none !important; width: 900px;
}
h1 { font-size: 62px; line-height: 62px; vertical-align: middle; font-weight: 200; margin-top: 100px; margin-bottom: 20px; text-transform:capitalize; color: white;
}
h1 .title { font-size: 60px; line-height: 80px; vertical-align: middle; color: #2c3e50; font-family: 'Roboto', sans-serif; font-weight: 500;
}
hr { margin-top: 3px; border-width: 1px 0; //border-color: #EEEEEE -moz-use-text-color #FFFFFF; //border-color: #888485; border-color: white;
}
hr#hr-bottom { margin-top: 0px; margin-bottom: 5px;
}
.panel { -webkit-box-shadow: -1px 2px 8px 0px rgba(0,0,0,0.3); -moz-box-shadow: -1px 2px 8px 0px rgba(0,0,0,0.3); box-shadow: -1px 2px 8px 0px rgba(0,0,0,0.3); //background-color: #00a6a7; background-color: RGBA(0, 0, 0, 0.3);
}
.panel-body { position: relative; margin-right: 20px; margin-left: 20px; padding-top: 5px;
}
.vcenter { display: block; vertical-align: middle; float: none;
}
#weather-icon-display { height: 307px; line-height: 307px;
}
#weather-icon { font-size: 180px; vertical-align: middle; display: inline-block; margin-top: -100px;
}
#temperature h4 { text-align: left; font-size: 32px; font-weight: 400;
}
#temperature p { text-align: left; font-size: 150px;
}
#temperature p { font-size: 300px; margin-top: -10px; margin-left: -10px; margin-bottom: 0; text-align: left; font-weight: 500; line-height: 230px;
}
#temperature p sup { vertical-align: baseline; position: relative; top: -185px; line-height: 0; font-size: 40px; font-weight: 400;
}
#temperature h5 { text-align: left; font-size: 16px; margin-bottom: 10px; margin-top: 0; font-weight: 300;
}
#weather-condition h6 { font-size: 36px; margin-bottom: 2px;
}
#weather-condition p { margin-bottom: 3px; font-size: 14px; font-weight: 400;
}
#condition { text-transform: capitalize;
}
.temp-switch input { font-size: 100px;
}
#city, h6 { color: white;
}
#footer { font-size: 10px; text-transform: capitalize; color: rgba(255,255,255, 0.4)
}
Local Weather - Script Codes JS Codes
$(window).load(function () { //Set default input values on page load //Default coordinates set to Boston, US var openWeatherMapAPI = "http://api.openweathermap.org/data/2.5/weather?lat=42.36&lon=-71.06&units=imperial&appid=ca6ff81b256ad199b3de759c58de182b", $temp = $("#temp"), $tempMax = $("#temp-max"), $tempMin = $("#temp-min"), temp = 72, tempMax = 81, tempMin = 64, weatherId = 800; if(navigator.geolocation){ navigator.geolocation.getCurrentPosition(function(position){ openWeatherMapAPI = "http://api.openweathermap.org/data/2.5/weather?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude + "&units=imperial&appid=ca6ff81b256ad199b3de759c58de182b"; //only calls API if geolocation is enabled fetchWeather(openWeatherMapAPI); });
} //initialize temperature switch $("#switch-temp").bootstrapSwitch(); //Fetch Weather from OpenWeatherMap by Geografic Coordinates //api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon} function fetchWeather(API) { $.getJSON(API, function(json){ $temp.html(parseInt(json.main.temp)); $tempMax.html(parseInt(json.main.temp_max)); $tempMin.html(parseInt(json.main.temp_min)); $("#city span").html(json.name + ", " + json.sys.country); $("#condition").html(json.weather[0].description); $("#humidity").html(json.main.humidity + "%"); $("#wind").html(json.wind.speed + " mph"); $("#hpa").html(json.main.pressure + " hPa"); $("#prec").html(json.clouds.all + " %"); weatherId = json.weather[0].id; //change Background if(weatherId >= 200 && weatherId < 550){ //rainy bg $('body').removeClass('sunny').addClass('rainy'); } else if (weatherId >= 600 && weatherId < 700){ //snow $('body').removeClass('sunny').addClass('snow'); } else if (weatherId >= 700 && weatherId < 800){ //mist smoke $('body').removeClass('sunny').addClass('snow'); } else { //keep the default console.log("BG image set to default"); //TODO: Change BG based on time } $("#weather-icon i").removeClass('wi-sleet').addClass('wi-owm-' + weatherId); //init temperature variables temp = $temp.html(); tempMax = $tempMax.html(); tempMin = $tempMin.html(); }); } $("#switch-temp").on('switchChange.bootstrapSwitch', function(event, state) { if(state){ $temp.html(toCelsius(temp)); $tempMax.html(toCelsius(tempMax)); $tempMin.html(toCelsius(tempMin)); $("#metric").html("C"); } else { $temp.html(temp); $tempMax.html(tempMax); $tempMin.html(tempMin); $("#metric").html("F"); } }); function toCelsius(f){ return parseInt((5 / 9) * (f - 32)); }
});
Developer | DannyCoder |
Username | DannyCoder |
Uploaded | November 05, 2022 |
Rating | 3.5 |
Size | 5,410 Kb |
Views | 14,168 |
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 |
Calculator | 4,185 Kb |
A Pen by DannyCoder | 1,518 Kb |
Palindromes | 1,532 Kb |
Twitch Streamers | 4,997 Kb |
Personal Portfolio Webpage | 3,157 Kb |
Pomodoro Clock | 4,639 Kb |
CamperNews | 5,543 Kb |
Zipline Random Quote Machine | 4,902 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 |
3D-box | Parthviroja | 2,346 Kb |
Collapsing Widget | Er40 | 4,279 Kb |
Icosahedron - rendered in 2D | Bolloxim | 4,246 Kb |
Em Test | Rodesco | 1,784 Kb |
GLSL Hills | Ykob | 6,991 Kb |
A Pen by Adrien Clerbois | AClerbois | 6,501 Kb |
CSS Hover Effects | Alen | 3,613 Kb |
Transition | Shayhowe | 1,632 Kb |
Experiment - SCSS SVG Background Image with Variables | See8ch | 3,270 Kb |
Plotting Points with D3.js | Laurakelly | 31,996 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!