Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 30: | Rivi 30: | ||
jw.obstype = {}; | jw.obstype = {}; | ||
jw.obstypeorder = []; | |||
for ( var oi in jw.obsList ) { | for ( var oi in jw.obsList ) { | ||
| Rivi 63: | Rivi 63: | ||
} | } | ||
jw.obstype[ ot ].catcount++; | |||
jw.obstype[ ot ].catmean = jw.obstype[ ot ].catsum / jw.obstype[ ot ].catcount; | |||
} else { | } else { | ||
jw.obstype[ ot ].catsum += parseInt( data.cat ); | jw.obstype[ ot ].catsum += parseInt( data.cat ); | ||
jw.obstype[ ot ].catcount++; | |||
jw.obstype[ ot ].catmean = jw.obstype[ ot ].catsum / jw.obstype[ ot ].catcount; | |||
} | } | ||
| Rivi 76: | Rivi 76: | ||
jw.obstype[ ot ].sum += data.val; | jw.obstype[ ot ].sum += data.val; | ||
jw.obstype[ ot ].count++; | |||
jw.obstype[ ot ].mean = jw.obstype[ ot ].sum / jw.obstype[ ot ].count; | |||
} | } | ||
| Rivi 87: | Rivi 87: | ||
//out += '<h2 class="h4">Havaintotilanne</h2>'; | //out += '<h2 class="h4">Havaintotilanne</h2>'; | ||
if ( jw.obstypeorder.length > 0 ) { | if ( jw.obstypeorder.length > 0 ) { | ||
out += '<div class="row">'; | |||
for ( var i in jw.obstypeorder ) { | |||
ot = jw.obstypeorder[ i ]; | |||
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;">'; | |||
out += '<button style="Xpadding: 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="' + 'Lukema on havainnon tuoreudella 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.toLocaleString( 'fi' ) + '">'; | |||
out += jw.obstype[ ot ].newest.inRelationToToday(); | |||
out += '< | out += '</button>'; | ||
out += '</div>'; | out += '</div>'; | ||
if ( ot == 'temp' ) { | |||
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;">+' + 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="height: | 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 ]; | bgcolor = icespringbgcolor[ icecatmean ]; | ||
brcolor = icespringbrcolor[ icecatmean ]; | brcolor = icespringbrcolor[ icecatmean ]; | ||
} else { | |||
bgcolor = iceautumnbgcolor[ icecatmean ]; | bgcolor = iceautumnbgcolor[ icecatmean ]; | ||
brcolor = iceautumnbrcolor[ 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 + ';">'; | |||
out += '<div style="height: | if ( icecatmean == 3 ) { | ||
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>'; | |||
} 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 ).toString().replace( '.', ',' ) + '</div>'; | |||
out += '<div style="font-size: 24px; margin-top: -20px;">m</div>'; | |||
out += '<div style="font-size: 36px;">' + Math.round( jw.obstype[ | out += '</div>'; | ||
out += '<div style="font-size: 24px; margin-top: -20px;"> | |||
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>'; | |||
} | } | ||
out += '</div>'; | |||
out += '</div>'; | |||
} | } | ||
out += '</div>'; | |||
} | } | ||
jQuery( '#sub-content-header-container' ).append( out ); | |||
jQuery( '[data-toggle="tooltip"]' ).tooltip( { 'trigger': 'click' } ); | |||
} | |||
} | |||
} | } | ||
</script></includeonly> | </script></includeonly> | ||


