Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 85: | Rivi 85: | ||
if ( typeof data.inreltodateavg != 'undefined' ) { | if ( typeof data.inreltodateavg != 'undefined' ) { | ||
jw.obstype[ot].mean = data.inreltodateavg; | jw.obstype[ot].mean = data.inreltodateavg; | ||
jw.obstype[ot].type = 'inreltodateavg'; | |||
} else if ( typeof data.inreltomwl != 'undefined' ) { | } else if ( typeof data.inreltomwl != 'undefined' ) { | ||
jw.obstype[ot].mean = data.inreltomwl; | jw.obstype[ot].mean = data.inreltomwl; | ||
jw.obstype[ot].type = 'inreltomwl'; | |||
} else { | } else { | ||
jw.obstype[ot].mean = null; | jw.obstype[ot].mean = null; | ||
jw.obstype[ot].type = 'none'; | |||
} | } | ||
} else { | } else { | ||
| Rivi 112: | Rivi 115: | ||
for ( var i in jw.obstypeorder ) { | for ( var i in jw.obstypeorder ) { | ||
ot = jw.obstypeorder[ i ]; | ot = jw.obstypeorder[ i ]; | ||
if ( ot != 'level' || jw.obstype[ot].type != 'none' ) { | |||
if ( jw.obstype[ ot ].obses.length > 1 | out += '<div class="col col-6 col-sm-3 col-md-2 text-center">'; | ||
out += '<div style="height: 40px; display: flex; justify-content: center; align-items: center; flex-direction: column;">'; | |||
if ( jw.obstype[ ot ].obses.length > 1 ) { | |||
if ( ot == 'temp' ) { | |||
tooltip = 'Pintaveden lämpötila on painotettu keskiarvo viimeisen 7 vuorokauden aikana järvelle tallennetuista havainnoista. Näitä havaintoja on yhteensä ' + jw.obstype[ ot ].obses.length + ' kpl, joista uusin on tehty ' + jw.obstype[ ot ].newest.inRelationToToday() + '.'; | |||
} else if ( ot == 'alg' ) { | |||
tooltip = 'sinilevätilanne on painotettu keskiarvo viimeisen 7 vuorokauden aikana järvelle tallennetuista havainnoista. Näitä havaintoja on yhteensä ' + jw.obstype[ ot ].obses.length + ' kpl, joista uusin on tehty ' + jw.obstype[ ot ].newest.inRelationToToday() + '.'; | |||
} else if ( ot == 'ice' ) { | |||
tooltip = 'Jäätilanne on painotettu keskiarvo viimeisen 14 vuorokauden aikana järvelle tallennetuista havainnoista. Näitä havaintoja on yhteensä ' + jw.obstype[ ot ].obses.length + ' kpl, joista uusin on tehty ' + jw.obstype[ ot ].newest.inRelationToToday() + '.'; | |||
} else if ( ot == 'level' ) { | |||
tooltip = 'Vedenpinnan korkeus on painotettu keskiarvo viimeisen 7 vuorokauden aikana järvelle tallennetuista havainnoista. Näitä havaintoja on yhteensä ' + jw.obstype[ ot ].obses.length + ' kpl, joista uusin on tehty ' + jw.obstype[ ot ].newest.inRelationToToday() + '.'; | |||
} else if ( ot == 'secchi' ) { | |||
tooltip = 'Näkösyvyys on painotettu keskiarvo viimeisen kuukauden aikana järvelle tallennetuista havainnoista. Näitä havaintoja on yhteensä ' + jw.obstype[ ot ].obses.length + ' kpl, joista uusin on tehty ' + jw.obstype[ ot ].newest.inRelationToToday() + '.'; | |||
} | |||
} else { | |||
if ( ot == 'temp' ) { | |||
tooltip = 'Tämä on tuorein havainto pintaveden lämpötilasta viimeisen 7 vuorokauden ajalta. Havainto on tehty ' + jw.obstype[ ot ].newest.toLocaleString( 'fi' ).replace( ' klo 0.00.00', '' ) + '.'; | |||
} else if ( ot == 'alg' ) { | |||
tooltip = 'Tämä on tuorein havainto sinilevätilanteesta viimeisen 7 vuorokauden ajalta. Havainto on tehty ' + jw.obstype[ ot ].newest.toLocaleString( 'fi' ).replace( ' klo 0.00.00', '' ) + '.'; | |||
} else if ( ot == 'ice' ) { | |||
tooltip = 'Tämä on tuorein havainto jäätilanteesta viimeisen 14 vuorokauden ajalta. Havainto on tehty ' + jw.obstype[ ot ].newest.toLocaleString( 'fi' ).replace( ' klo 0.00.00', '' ) + '.'; | |||
} else if ( ot == 'level' ) { | |||
tooltip = 'Tämä on tuorein havainto vedenpinnan korkeudesta viimeisen 7 vuorokauden ajalta. Havainto on tehty ' + jw.obstype[ ot ].newest.toLocaleString( 'fi' ).replace( ' klo 0.00.00', '' ) + '.'; | |||
} else if ( ot == 'secchi' ) { | |||
tooltip = 'Tämä on tuorein havainto näkösyvyydestä viimeisen kuukauden ajalta. Havainto on tehty ' + jw.obstype[ ot ].newest.toLocaleString( 'fi' ).replace( ' klo 0.00.00', '' ) + '.'; | |||
} | |||
} | } | ||
out += '<button style="padding: 0 0.25em; font-size: 14px; margin-bottom: 3px;" type="button" class="btn btn-secondary btn-info" data-toggle="tooltip" data-placement="top" data-trigger="click" title="' + tooltip + '">'; | |||
out += jw.obstype[ ot ].newest.inRelationToToday().replace( 'päivää', 'vrk' ); | |||
out += '</button>'; | |||
out += '</div>'; | |||
if ( ot == 'temp' ) { | |||
var tempcolor = [ 'var( --syke-blue)', 'var( --syke-yellow)', 'var( --syke-red)' ]; | |||
var tempval = Math.round( jw.obstype[ ot ].mean ); | |||
var tempcat = Math.min( 2, Math.floor( 3 * tempval / 30 ) ); | |||
out += '<div style="width: 84px; height: 84px; margin: auto; border-radius: 50%; display: flex; justify-content: center; align-items: center; flex-direction: column; background-color: none;">'; | |||
out += '<div style="font-size: 44px; color: ' + tempcolor[ tempcat ] + '">+' + Math.round( jw.obstype[ ot ].mean ) + '°</div>'; | |||
out += '</div>'; | |||
out += '<div style="height: 60px; display: flex; justify-content: center; align-items: center; flex-direction: column;">'; | |||
out += '<span class="h6" style="margin: 0;">Pintaveden<br />lämpötila</span>'; | |||
out += '</div>'; | |||
} else if ( ot == 'alg' ) { | |||
var algmean = Math.round( jw.obstype[ ot ].mean ); | |||
var algtxt = [ 'Ei sinilevää', 'Hieman<br />sinilevää', 'Runsaasti<br />sinilevää', 'Erit. runsaasti<br />sinilevää' ]; | |||
var algcolor = [ '#308fb3', '#8db335', '#f1cb00', '#ce0000' ]; | |||
out += '<div style="width: 84px; height: 84px; margin: auto; border-radius: 50%; font-size: 44px; display: flex; justify-content: center; align-items: center; flex-direction: column; background-color: ' + algcolor[ algmean ] + ';">'; | |||
out += '</div>'; | |||
out += '<div style="height: 60px; display: flex; justify-content: center; align-items: center; flex-direction: column;">'; | |||
out += '<span class="h6" style="margin: 0;">' + algtxt[ algmean ] + '</span>'; | |||
out += '</div>'; | |||
} else if ( ot == 'ice' ) { | |||
icecatmean = Math.round( jw.obstype[ ot ].catmean ); | |||
icetxt = [ 'Ei jäätä', 'Osittain jäässä', 'Yhtenäinen jääpeite' ]; | |||
iceautumnbgcolor = [ '#64c1cb', '#64c1cb', '#fff' ]; | |||
icespringbgcolor = [ '#64c1cb', '#fff', '#fff' ]; | |||
iceautumnbrcolor = [ '#64c1cb', '#fff', '#fff' ]; | |||
icespringbrcolor = [ '#64c1cb', '#64c1cb', '#fff' ]; | |||
if ( now.getMonth() > 2 && now.getMonth() < 7 ) { | |||
bgcolor = icespringbgcolor[ icecatmean ]; | |||
brcolor = icespringbrcolor[ icecatmean ]; | |||
} else { | |||
bgcolor = iceautumnbgcolor[ icecatmean ]; | |||
brcolor = iceautumnbrcolor[ icecatmean ]; | |||
} | |||
out += '<div style="width: 84px; height: 84px; margin: auto; border-radius: 50%; display: flex; justify-content: center; align-items: center; flex-direction: column; border: 10px solid ' + brcolor + '; background-color: ' + bgcolor + ';">'; | |||
if ( icecatmean == 2 ) { | |||
out += '<div style="font-size: 36px;">' + Math.round( jw.obstype[ 'ice' ].mean ) + '</div>'; | |||
out += '<div style="font-size: 24px; margin-top: -20px;">cm</div>'; | |||
} | |||
out += '</div>'; | |||
out += '<div style="height: 60px; display: flex; justify-content: center; align-items: center; flex-direction: column;">'; | |||
out += '<span class="h6" style="margin: 0;">' + icetxt[ icecatmean ] + '</span>'; | |||
out += '</div>'; | out += '</div>'; | ||
} else if ( ot == 'secchi' ) { | |||
out += '<div style="width: 84px; height: 84px; margin: auto; border-radius: 50%; display: flex; justify-content: center; align-items: center; flex-direction: column; background-color: none;">'; | |||
out += '<div style="font-size: 36px;">' + ( Math.round( jw.obstype[ ot ].mean * 10 ) / 10 ).toFixed(1).toString().replace( '.', ',' ) + '</div>'; | |||
out += '<div style="font-size: 24px; margin-top: -20px;">m</div>'; | |||
out += '</div>'; | |||
out += '<div style="height: 60px; display: flex; justify-content: center; align-items: center; flex-direction: column;">'; | |||
out += '<span class="h6" style="margin: 0;">' + 'Näkösyvyys' + '</span>'; | |||
out += '</div>'; | |||
} else if ( ot == 'level' ) { | |||
//console.log( jw ); | |||
out += '<div style="width: 84px; height: 84px; margin: auto; border-radius: 50%; display: flex; justify-content: center; align-items: center; flex-direction: column; background-color: none;">'; | |||
out += '<div style="font-size: 36px;">' + jw.obstype[ ot ].mean.toLocaleString( 'fi-FI', { signDisplay: 'always' } ) + '</div>'; | |||
out += '<div style="font-size: 24px; margin-top: -20px;">cm</div>'; | |||
out += '</div>'; | |||
out += '<div style="height: 60px; display: flex; justify-content: center; align-items: center; flex-direction: column;">'; | |||
out += '<span class="h6" style="margin: 0;">' + 'Vedenpinta korkea' + '</span>'; | |||
out += '</div>'; | |||
} | |||
out += '</div>'; | |||
out += '</div>'; | |||
} | } | ||
} | } | ||


