Ero sivun ”Widget:JwCurrentCharts” versioiden välillä
Järvi-meriwikistä
Rivi 602: | Rivi 602: | ||
var tsum = 0; | var tsum = 0; | ||
var tc = 0; | var tc = 0; | ||
+ | var tcsum = 0; | ||
for ( var o in memo.obsesA ) { | for ( var o in memo.obsesA ) { | ||
tw = ( 7 - Math.round( ( today.getTime() - memo.obsesA[o].obsdatetime.getTime() ) / ( 24*60*60*1000 ) ) ); | tw = ( 7 - Math.round( ( today.getTime() - memo.obsesA[o].obsdatetime.getTime() ) / ( 24*60*60*1000 ) ) ); | ||
tsum += memo.obsesA[o].data.val * tw; | tsum += memo.obsesA[o].data.val * tw; | ||
− | + | tcsum = tcsum + tw; | |
+ | tc++; | ||
} | } | ||
− | if ( tc > 0 ) { | + | if ( tc > 0 ) { |
− | tavg = Math.round( tsum/ | + | tavg = Math.round( tsum/tcsum*10 ) / 10; |
tstr = tavg.toString().replace( '.', ',' ) + ' °C'; | tstr = tavg.toString().replace( '.', ',' ) + ' °C'; | ||
if ( tc == 1 ) { | if ( tc == 1 ) { | ||
tstr += '<br /><span>(' + memo.obsesA[0].obsdatetime.inRelationToToday(memo.lang).toLowerCase() + ')</span>'; | tstr += '<br /><span>(' + memo.obsesA[0].obsdatetime.inRelationToToday(memo.lang).toLowerCase() + ')</span>'; | ||
+ | } else { | ||
+ | //tstr += '<br /><span>(' + tc.toString() + ' havaintoa)</span>'; | ||
} | } | ||
up = Math.round( (tavg/33)*50 ); | up = Math.round( (tavg/33)*50 ); |