Ero sivun ”Widget:JwObsCharts” versioiden välillä
Järvi-meriwikistä
Rivi 680: | Rivi 680: | ||
} else if ( memo.obscode == 'temp' ) { | } else if ( memo.obscode == 'temp' ) { | ||
+ | var tsum = 0; | ||
+ | var tc = 0; | ||
+ | |||
console.log( memo.obsesA ); | console.log( memo.obsesA ); | ||
− | + | ||
+ | for ( var o in memo.obsesA ) { | ||
+ | tsum += memo.obsesA[o].data.val; | ||
+ | tc++: | ||
+ | console.log( tsum ); | ||
+ | } | ||
+ | |||
+ | var tavg = Math.round( tsum/tc*10 ) / 10; | ||
+ | |||
memo.widgetEl.html(''); | memo.widgetEl.html(''); | ||
− | memo.widgetEl.append( '<p style="text-align: center; line-height: 20px;" class="huomio">Ei tuoreita havaintoja</p>' ); | + | if ( tc > 0 ) { |
+ | memo.widgetEl.append( '<p style="text-align: center; line-height: 20px;" class="huomio">' + tavg.toString().replace( '.', ',' ) + ' °C</p>' ); | ||
+ | } else { | ||
+ | memo.widgetEl.append( '<p style="text-align: center; line-height: 20px;" class="huomio">Ei tuoreita havaintoja</p>' ); | ||
+ | } | ||
memo.widgetEl.append( '<div style="width: 100px; height: 100px; margin: 0 auto;"><svg style="width: 100px; height: 100px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M160 64c-26.5 0-48 21.5-48 48V276.5c0 17.3-7.1 31.9-15.3 42.5C86.2 332.6 80 349.5 80 368c0 44.2 35.8 80 80 80s80-35.8 80-80c0-18.5-6.2-35.4-16.7-48.9c-8.2-10.6-15.3-25.2-15.3-42.5V112c0-26.5-21.5-48-48-48zM48 112C48 50.2 98.1 0 160 0s112 50.1 112 112V276.5c0 .1 .1 .3 .2 .6c.2 .6 .8 1.6 1.7 2.8c18.9 24.4 30.1 55 30.1 88.1c0 79.5-64.5 144-144 144S16 447.5 16 368c0-33.2 11.2-63.8 30.1-88.1c.9-1.2 1.5-2.2 1.7-2.8c.1-.3 .2-.5 .2-.6V112zM208 368c0 26.5-21.5 48-48 48s-48-21.5-48-48c0-20.9 13.4-38.7 32-45.3V208c0-8.8 7.2-16 16-16s16 7.2 16 16V322.7c18.6 6.6 32 24.4 32 45.3z"/></svg></div>'); | memo.widgetEl.append( '<div style="width: 100px; height: 100px; margin: 0 auto;"><svg style="width: 100px; height: 100px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M160 64c-26.5 0-48 21.5-48 48V276.5c0 17.3-7.1 31.9-15.3 42.5C86.2 332.6 80 349.5 80 368c0 44.2 35.8 80 80 80s80-35.8 80-80c0-18.5-6.2-35.4-16.7-48.9c-8.2-10.6-15.3-25.2-15.3-42.5V112c0-26.5-21.5-48-48-48zM48 112C48 50.2 98.1 0 160 0s112 50.1 112 112V276.5c0 .1 .1 .3 .2 .6c.2 .6 .8 1.6 1.7 2.8c18.9 24.4 30.1 55 30.1 88.1c0 79.5-64.5 144-144 144S16 447.5 16 368c0-33.2 11.2-63.8 30.1-88.1c.9-1.2 1.5-2.2 1.7-2.8c.1-.3 .2-.5 .2-.6V112zM208 368c0 26.5-21.5 48-48 48s-48-21.5-48-48c0-20.9 13.4-38.7 32-45.3V208c0-8.8 7.2-16 16-16s16 7.2 16 16V322.7c18.6 6.6 32 24.4 32 45.3z"/></svg></div>'); | ||
memo.widgetEl.append( '<p style="text-align: center; line-height: 20px;" class="huomio">Pintaveden lämpötila</p>' ); | memo.widgetEl.append( '<p style="text-align: center; line-height: 20px;" class="huomio">Pintaveden lämpötila</p>' ); |