Ero sivun ”Widget:JwObsCharts” versioiden välillä
Järvi-meriwikistä
Rivi 742: | Rivi 742: | ||
} else if ( memo.obscode == 'alg' ) { | } else if ( memo.obscode == 'alg' ) { | ||
+ | |||
+ | var asum = 0; | ||
+ | var ac = 0; | ||
+ | |||
+ | for ( var o in memo.obsesA ) { | ||
+ | asum += memo.obsesA[o].data.val; | ||
+ | ac++; | ||
+ | } | ||
+ | |||
+ | if ( ac > 0 ) { | ||
+ | var aavg = Math.round( asum/ac ); | ||
+ | if ( aavg < 0.5 ) { | ||
+ | astr = 'Ei sinilevää'; | ||
+ | } else if ( aavg < 1.5 ) { | ||
+ | astr = 'Hieman sinilevää'; | ||
+ | } else if ( aavg < 2.5 ) { | ||
+ | astr = 'Runsaasti sinilevää'; | ||
+ | } else { | ||
+ | astr = 'Erittäin runsaasti sinilevää'; | ||
+ | } | ||
+ | } else { | ||
+ | astr = 'Ei tuoreita havaintoja'; | ||
+ | } | ||
memo.widgetEl.html(''); | memo.widgetEl.html(''); | ||
memo.widgetEl.append( '<h3 style="text-align: center; font-size: 100%; margin-top: 0;">Sinilevätilanne</h3>' ); | memo.widgetEl.append( '<h3 style="text-align: center; font-size: 100%; margin-top: 0;">Sinilevätilanne</h3>' ); | ||
memo.widgetEl.append( '<div style="width: 120px; height: 120px; margin: 10px auto; padding: 10px; border-radius: 6px; Xborder: 3px solid rgba( 213, 218, 38, 0.5 );"><svg style="width: 100px; height: 100px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 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="M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.6 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0zm0 79L235.4 187.2c-3.5 7.1-10.2 12.1-18.1 13.3L99 217.9 184.9 303c5.5 5.5 8.1 13.3 6.8 21L171.4 443.7l105.2-56.2c7.1-3.8 15.6-3.8 22.6 0l105.2 56.2L384.2 324.1c-1.3-7.7 1.2-15.5 6.8-21l85.9-85.1L358.6 200.5c-7.8-1.2-14.6-6.1-18.1-13.3L287.9 79z"/></svg></div>'); | memo.widgetEl.append( '<div style="width: 120px; height: 120px; margin: 10px auto; padding: 10px; border-radius: 6px; Xborder: 3px solid rgba( 213, 218, 38, 0.5 );"><svg style="width: 100px; height: 100px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 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="M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.6 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0zm0 79L235.4 187.2c-3.5 7.1-10.2 12.1-18.1 13.3L99 217.9 184.9 303c5.5 5.5 8.1 13.3 6.8 21L171.4 443.7l105.2-56.2c7.1-3.8 15.6-3.8 22.6 0l105.2 56.2L384.2 324.1c-1.3-7.7 1.2-15.5 6.8-21l85.9-85.1L358.6 200.5c-7.8-1.2-14.6-6.1-18.1-13.3L287.9 79z"/></svg></div>'); | ||
− | memo.widgetEl.append( '<p style="text-align: center; Xline-height: 20px;" class="huomio"> | + | memo.widgetEl.append( '<p style="text-align: center; Xline-height: 20px;" class="huomio">' + astr + '</p>' ); |
} | } | ||