Browse Source

Suppression de Yahoo Weather et remplacement par OpenWeatherMap

master
Erase 5 years ago
parent
commit
ecb4dd3d93
34 changed files with 377 additions and 39 deletions
  1. +1
    -0
      dist/config.json
  2. +1
    -1
      dist/css/style.css
  3. BIN
      dist/img/weather/day/clear.png
  4. BIN
      dist/img/weather/day/clouds.png
  5. BIN
      dist/img/weather/day/mist.png
  6. BIN
      dist/img/weather/day/rain.png
  7. BIN
      dist/img/weather/day/snow.png
  8. BIN
      dist/img/weather/day/storm.png
  9. BIN
      dist/img/weather/night/clear.png
  10. BIN
      dist/img/weather/night/clouds.png
  11. BIN
      dist/img/weather/night/mist.png
  12. BIN
      dist/img/weather/night/rain.png
  13. BIN
      dist/img/weather/night/snow.png
  14. BIN
      dist/img/weather/night/storm.png
  15. +1
    -1
      dist/index.html
  16. +334
    -13
      dist/js/script.js
  17. +3
    -3
      gulpfile.js
  18. +1
    -0
      src/config.json
  19. +6
    -7
      src/css/style.css
  20. BIN
      src/img/weather/day/clear.png
  21. BIN
      src/img/weather/day/clouds.png
  22. BIN
      src/img/weather/day/mist.png
  23. BIN
      src/img/weather/day/rain.png
  24. BIN
      src/img/weather/day/snow.png
  25. BIN
      src/img/weather/day/storm.png
  26. BIN
      src/img/weather/night/clear.png
  27. BIN
      src/img/weather/night/clouds.png
  28. BIN
      src/img/weather/night/mist.png
  29. BIN
      src/img/weather/night/rain.png
  30. BIN
      src/img/weather/night/snow.png
  31. BIN
      src/img/weather/night/storm.png
  32. +4
    -1
      src/index.html
  33. +15
    -13
      src/js/app.js
  34. +11
    -0
      src/js/openweather.min.js

+ 1
- 0
dist/config.json View File

@ -1,6 +1,7 @@
{
"unsplashCollectionID": 1053828,
"defaultWeatherLocation": "Paris",
"WeatherKey": "c9d49310f8023ee2617a7634de23c2aa",
"defaultSearchBaseURL": "https://encrypted.google.com/search?q=",
"commands" : [
{ "key": "s", "name": "Shaarlo", "url": "https://www.shaarlo.fr", "search": "/index.php?from=20130000&to=90130000&q=" },


+ 1
- 1
dist/css/style.css
File diff suppressed because it is too large
View File


BIN
dist/img/weather/day/clear.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.6 KiB

BIN
dist/img/weather/day/clouds.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.4 KiB

BIN
dist/img/weather/day/mist.png View File

Before After
Width: 81  |  Height: 78  |  Size: 815 B

BIN
dist/img/weather/day/rain.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.7 KiB

BIN
dist/img/weather/day/snow.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.0 KiB

BIN
dist/img/weather/day/storm.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.3 KiB

BIN
dist/img/weather/night/clear.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.2 KiB

BIN
dist/img/weather/night/clouds.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.4 KiB

BIN
dist/img/weather/night/mist.png View File

Before After
Width: 81  |  Height: 78  |  Size: 815 B

BIN
dist/img/weather/night/rain.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.7 KiB

BIN
dist/img/weather/night/snow.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.0 KiB

BIN
dist/img/weather/night/storm.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.3 KiB

+ 1
- 1
dist/index.html View File

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="robots" content="noindex"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="x-ua-compatible" content="ie=edge"><title>Nouvel onglet</title><link rel="shortcut icon" href="favicon.ico?1.1" type="image/x-icon"><link rel="icon" href="favicon.ico?1.1" type="image/x-icon"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300:latin"><link rel="stylesheet" href="css/style.css"></head><body><div id="wrapper"><div class="box"><time class="time" id="js-time"></time><br><span id="quotes"></span><br><span id="weather"></span><br><form class="search" id="js-search" autocomplete="off"><input class="search-text" id="js-search-text" type="text" autofocus></form><pre class="help" id="js-help"></pre></div><div class="grid"></div><form id="addLinkForm"><div><label for="titre">Titre du lien</label> <input type="text" id="titre" value=""></div><div><label for="cible">Cible du lien</label> <input type="text" id="cible" value=""></div><input type="submit" value="Ajouter"></form></div><script src="js/script.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="robots" content="noindex"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="x-ua-compatible" content="ie=edge"><title>Nouvel onglet</title><link rel="shortcut icon" href="favicon.ico?1.1" type="image/x-icon"><link rel="icon" href="favicon.ico?1.1" type="image/x-icon"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300:latin"><link rel="stylesheet" href="css/style.css"></head><body><div id="wrapper"><div class="box"><time class="time" id="js-time"></time><br><span id="quotes"></span><br><span id="weather-wrapper"><img src="" class="weather-icon" alt="Weather Icon"> <span id="weather"></span></span><br><form class="search" id="js-search" autocomplete="off"><input class="search-text" id="js-search-text" type="text" autofocus></form><pre class="help" id="js-help"></pre></div><div class="grid"></div><form id="addLinkForm"><div><label for="titre">Titre du lien</label> <input type="text" id="titre" value=""></div><div><label for="cible">Cible du lien</label> <input type="text" id="cible" value=""></div><input type="submit" value="Ajouter"></form></div><script src="js/script.js"></script></body></html>

+ 334
- 13
dist/js/script.js
File diff suppressed because it is too large
View File


+ 3
- 3
gulpfile.js View File

@ -52,9 +52,7 @@ gulp.task('styles', function () {
// Gulp task to minify JavaScript files
gulp.task('scripts', function() {
return gulp.src(['src/js/jquery-1.12.0.min.js', 'src/js/jquery-ui.min.js', 'src/js/jquery.simpleWeather.min.js', 'src/js/jstorage.min.js', 'src/js/alertify.min.js', 'src/js/app.js'])
// Minify the file
.pipe(uglify())
return gulp.src(['src/js/jquery-1.12.0.min.js', 'src/js/jquery-ui.min.js', 'src/js/openweather.min.js', 'src/js/jstorage.min.js', 'src/js/alertify.min.js', 'src/js/app.js'])
.pipe(concat('script.js'))
// Output
.pipe(gulp.dest('./dist/js'))
@ -75,6 +73,8 @@ gulp.task('clean', () => del(['dist']));
gulp.task('copy', function(){
gulp.src(['./src/fonts/*']).pipe(gulp.dest('./dist/fonts/'));
gulp.src(['./src/favicon.ico*']).pipe(gulp.dest('./dist/'));
gulp.src(['./src/img/weather/day/*']).pipe(gulp.dest('./dist/img/weather/day/'));
gulp.src(['./src/img/weather/night/*']).pipe(gulp.dest('./dist/img/weather/night/'));
gulp.src(['./src/config.json*']).pipe(gulp.dest('./dist/'));
});


+ 1
- 0
src/config.json View File

@ -1,6 +1,7 @@
{
"unsplashCollectionID": 1053828,
"defaultWeatherLocation": "Paris",
"WeatherKey": "c9d49310f8023ee2617a7634de23c2aa",
"defaultSearchBaseURL": "https://encrypted.google.com/search?q=",
"commands" : [
{ "key": "s", "name": "Shaarlo", "url": "https://www.shaarlo.fr", "search": "/index.php?from=20130000&to=90130000&q=" },


+ 6
- 7
src/css/style.css View File

@ -66,15 +66,14 @@ input:focus {
#quotes {
font-weight: bold;
font-size:2em;
}
#weather {
color: #999999;
font-size:4em;
}
.weatherinfo{
font-size:2rem;
#weather-wrapper{
margin:15px 0 0;
display: block;
font-size:2em;
font-weight: bold;
}
#wrapper {


BIN
src/img/weather/day/clear.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.6 KiB

BIN
src/img/weather/day/clouds.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.4 KiB

BIN
src/img/weather/day/mist.png View File

Before After
Width: 81  |  Height: 78  |  Size: 815 B

BIN
src/img/weather/day/rain.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.7 KiB

BIN
src/img/weather/day/snow.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.0 KiB

BIN
src/img/weather/day/storm.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.3 KiB

BIN
src/img/weather/night/clear.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.2 KiB

BIN
src/img/weather/night/clouds.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.4 KiB

BIN
src/img/weather/night/mist.png View File

Before After
Width: 81  |  Height: 78  |  Size: 815 B

BIN
src/img/weather/night/rain.png View File

Before After
Width: 81  |  Height: 78  |  Size: 1.7 KiB

BIN
src/img/weather/night/snow.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.0 KiB

BIN
src/img/weather/night/storm.png View File

Before After
Width: 81  |  Height: 78  |  Size: 2.3 KiB

+ 4
- 1
src/index.html View File

@ -22,7 +22,10 @@
<br>
<span id="quotes"></span>
<br>
<span id="weather"></span>
<span id="weather-wrapper">
<img src="" class="weather-icon" alt="Weather Icon" />
<span id="weather"></span>
</span>
<br>
<form class="search" id="js-search" autocomplete="off">
<input class="search-text" id="js-search-text" type="text" autofocus>


+ 15
- 13
src/js/app.js View File

@ -1,5 +1,6 @@
var unsplashCollectionID = 1053828;
var defaultWeatherLocation = 'Paris';
var WeatherKey = 'c9d49310f8023ee2617a7634de23c2aa'; //~ Go to https://openweathermap.org/api
var defaultSearchBaseURL = 'https://encrypted.google.com/search?q=';
var commands = [
{ "key": "s", "name": "Shaarlo", "url": "https://www.shaarlo.fr", "search": "/index.php?from=20130000&to=90130000&q=" },
@ -27,20 +28,21 @@ var messages = [
},
];
function loadWeather(location, woeid) {
$.simpleWeather({
location: location,
woeid: woeid,
unit: 'c',
success: function (weather) {
var html = '<i class="icon-'+weather.code+'"></i><div class="weatherinfo">'+weather.temp+'&deg;'+weather.units.temp+'</div>';
html += ''+weather.city+', '+weather.region+'';
function loadWeather(location, key) {
$('#weather').openWeather({
key: key,
city: location,
lang: 'fr',
units: 'c',
iconTarget: '.weather-icon',
customIcons: 'img/weather/',
success: function(weather) {
var html = '<div class="weatherinfo">'+weather.temperature.current+'</div>';
html += ''+weather.city;
$("#weather").html(html);
},
error: function (error) {
console.log(error);
$("#weather").html('<p>' + error + '</p>');
error: function(data) {
}
});
}
@ -172,7 +174,7 @@ $(function() {
$('#quotes').text(timedQuotes());
loadWeather(defaultWeatherLocation, '');
loadWeather(defaultWeatherLocation, WeatherKey);
loadLinks();
});


+ 11
- 0
src/js/openweather.min.js View File

@ -0,0 +1,11 @@
/*!
Name: Open Weather
Dependencies: jQuery, OpenWeatherMap API
Author: Michael Lynch
Author URL: http://michaelynch.com
Date Created: August 28, 2013
Licensed under the MIT license
*/
!function(t){t.fn.openWeather=function(e){if(!this.length)return this;const n=t(this);this.settings={},this.settings=t.extend({},{descriptionTarget:null,maxTemperatureTarget:null,minTemperatureTarget:null,windSpeedTarget:null,humidityTarget:null,sunriseTarget:null,sunsetTarget:null,placeTarget:null,iconTarget:null,customIcons:null,units:"c",city:null,lat:null,lng:null,key:null,lang:"en",success:function(){},error:function(t){}},e);const r=this.settings,i=function(t){const e=new Date(1e3*t);let n=e.getHours();if(n>12){n=12-(24-n)}let r=e.getMinutes();return(r=r.toString()).length<2&&(r=0+r),n+":"+r};let a,l,s,u,o="//api.openweathermap.org/data/2.5/weather?lang="+r.lang;null!=r.city?o+="&q="+r.city:null!=r.lat&&null!=r.lng&&(o+="&lat="+r.lat+"&lon="+r.lng),null!=r.key&&(o+="&appid="+r.key),t.ajax({type:"GET",url:o,dataType:"jsonp",success:function(e){if(e){if("f"==r.units?(l=Math.round(1.8*(e.main.temp-273.15)+32)+"°F",s=Math.round(1.8*(e.main.temp_min-273.15)+32)+"°F",u=Math.round(1.8*(e.main.temp_max-273.15)+32)+"°F"):(l=Math.round(e.main.temp-273.15)+"°C",s=Math.round(e.main.temp_min-273.15)+"°C",u=Math.round(e.main.temp_max-273.15)+"°C"),a={city:`${e.name}, ${e.sys.country}`,temperature:{current:l,min:s,max:u,units:r.units.toUpperCase()},description:e.weather[0].description,windspeed:`${Math.round(e.wind.speed)} Mps`,humidity:`${e.main.humidity}%`,sunrise:`${i(e.sys.sunrise)} AM`,sunset:`${i(e.sys.sunset)} PM`},n.html(l),null!=r.minTemperatureTarget&&t(r.minTemperatureTarget).text(s),null!=r.maxTemperatureTarget&&t(r.maxTemperatureTarget).text(u),t(r.descriptionTarget).text(a.description),null!=r.iconTarget&&null!=e.weather[0].icon){let n;if(null!=r.customIcons){const t=e.weather[0].icon;let i,a;i=-1!=t.indexOf("d")?"day":"night","01d"!=t&&"01n"!=t||(a="clear"),"02d"!=t&&"02n"!=t&&"03d"!=t&&"03n"!=t&&"04d"!=t&&"04n"!=t||(a="clouds"),"09d"!=t&&"09n"!=t&&"10d"!=t&&"10n"!=t||(a="rain"),"11d"!=t&&"11n"!=t||(a="storm"),"13d"!=t&&"13n"!=t||(a="snow"),"50d"!=t&&"50n"!=t||(a="mist"),n=`${r.customIcons}${i}/${a}.png`}else n=`http://openweathermap.org/img/w/${e.weather[0].icon}.png`;t(r.iconTarget).attr("src",n)}null!=r.placeTarget&&t(r.placeTarget).text(a.city),null!=r.windSpeedTarget&&t(r.windSpeedTarget).text(a.windspeed),null!=r.humidityTarget&&t(r.humidityTarget).text(a.humidity),null!=r.sunriseTarget&&t(r.sunriseTarget).text(a.sunrise),null!=r.sunsetTarget&&t(r.sunsetTarget).text(a.sunset),r.success.call(this,a)}},error:function(t,e,n){r.error.call(this,{error:e})}})}}(jQuery);

Loading…
Cancel
Save