Ei muokkausyhteenvetoa Merkkaus: Palautettu |
Ei muokkausyhteenvetoa |
||
| (54 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
| Rivi 83: | Rivi 83: | ||
memo.title = jQuery( this ).attr( 'data-title' ); if ( typeof memo.title == 'undefined' ) { memo.title = i18n[ memo.obscode ][ 'title' ][ memo.lang ]; } | memo.title = jQuery( this ).attr( 'data-title' ); if ( typeof memo.title == 'undefined' ) { memo.title = i18n[ memo.obscode ][ 'title' ][ memo.lang ]; } | ||
memo.info = jQuery( this ).attr( 'data-info' ); if ( typeof memo.info == 'undefined' ) { memo.info = ""; } | memo.info = jQuery( this ).attr( 'data-info' ); if ( typeof memo.info == 'undefined' ) { memo.info = ""; } | ||
if ( typeof jQuery( this ).attr( 'data-info-addsite' ) != 'undefined' ) { memo.addsitetoinfo = ( jQuery( this ).attr( 'data-info-addsite' ) == 'true' ); } else { memo.addsitetoinfo = false; }; | |||
memo.caption = jQuery( this ).attr( 'data-caption' ); if ( typeof memo.caption == 'undefined' ) { memo.caption = ""; } | memo.caption = jQuery( this ).attr( 'data-caption' ); if ( typeof memo.caption == 'undefined' ) { memo.caption = ""; } | ||
if ( typeof jQuery( this ).attr( 'data-jw-summerwinter' ) != 'undefined' ) { memo.summerwinter = ( jQuery( this ).attr( 'data-jw-summerwinter' ) == 'true' ); } else { memo.summerwinter = false; }; | if ( typeof jQuery( this ).attr( 'data-jw-summerwinter' ) != 'undefined' ) { memo.summerwinter = ( jQuery( this ).attr( 'data-jw-summerwinter' ) == 'true' ); } else { memo.summerwinter = false; }; | ||
| Rivi 99: | Rivi 100: | ||
memo.divide = '-'; | memo.divide = '-'; | ||
}; | }; | ||
if ( typeof jQuery( this ).attr( 'data-jw-divide-if-obses' ) != 'undefined' ) { | if ( typeof jQuery( this ).attr( 'data-jw-divide-if-obses' ) != 'undefined' ) { | ||
memo.divideCond = parseInt( jQuery( this ).attr( 'data-jw-divide-if-obses' ) ); | memo.divideCond = parseInt( jQuery( this ).attr( 'data-jw-divide-if-obses' ) ); | ||
} else { | } else { | ||
memo.divideCond = | memo.divideCond = 20; | ||
}; | }; | ||
| Rivi 122: | Rivi 123: | ||
memo.startDate = '1800-01-01'; | memo.startDate = '1800-01-01'; | ||
} | } | ||
memo.service = jQuery( this ).attr( 'data-coo311-service_code' ); | memo.service = jQuery( this ).attr( 'data-coo311-service_code' ); | ||
| Rivi 135: | Rivi 135: | ||
memo.widgetEl.css( 'position', 'relative' ); | memo.widgetEl.css( 'position', 'relative' ); | ||
memo.widgetEl.css( 'margin-bottom', '0.5em' ); | //memo.widgetEl.css( 'margin-bottom', '0.5em' ); | ||
// add loader animation | // add loader animation | ||
| Rivi 145: | Rivi 145: | ||
// add chart container | // add chart container | ||
memo.widgetEl.append( '<div class="card JwCard | memo.widgetEl.append( '<div class="card JwCard Xmb-2" style="position: relative; width: 100%; height: 100%;"><div class="card-header" style="min-height: 49px;"></div><div class="card-body p-2" style="position: relative; width: 100%; height: 100%;"><div class="chart-container" style="position: relative; z-index: 110; width: 100%; height: 100%;"></div></div><div class="card-footer"></div>' ); | ||
memo.chartEl = jQuery( this ).find( '.chart-container' ); | memo.chartEl = jQuery( this ).find( '.chart-container' ); | ||
memo.chartEl.css( 'height', memo.height + 'px' ); | memo.chartEl.css( 'height', memo.height + 'px' ); | ||
| Rivi 163: | Rivi 163: | ||
// add fullscreen button | // add fullscreen button | ||
memo.headerEl.append( '<div class="obschartbutton fullscreen-button" style="display: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton fullscreen-button" style="display: none; margin-left: 10px; float: right; font-size: 18.72px;"><button title="' + i18n['fullscreen'][memo.lang] + '" style=""><i class="fas fa-expand"></i></button></div>' ); | ||
memo.fullscreenEl = jQuery( this ).find( '.fullscreen-button' ); | memo.fullscreenEl = jQuery( this ).find( '.fullscreen-button' ); | ||
| Rivi 202: | Rivi 202: | ||
}); | }); | ||
// add edit button | // add edit button | ||
if ( memo.editUrl != '-' ) { | if ( memo.editUrl != '-' ) { | ||
memo.headerEl.append( '<div class="obschartbutton edit-button" style="Xdisplay: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton edit-button" style="Xdisplay: none; margin-left: 10px; float: right; font-size: 18.72px;"><button title="' + i18n['edit'][memo.lang] + '" style=""><i class="fas fa-edit"></i></button></div>' ); | ||
memo.editEl = jQuery( this ).find( '.edit-button' ); | memo.editEl = jQuery( this ).find( '.edit-button' ); | ||
memo.editEl.on( 'click', function() { window.location.href = memo.editUrl; }); | memo.editEl.on( 'click', function() { window.location.href = memo.editUrl; }); | ||
| Rivi 211: | Rivi 211: | ||
// add download data button | // add download data button | ||
if ( memo.download ) { | if ( memo.download ) { | ||
memo.headerEl.append( '<div class="obschartbutton download-button" style="display: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton download-button" style="display: none; margin-left: 10px; float: right; font-size: 18.72px;"><button title="' + i18n['download'][memo.lang] + '" style=""><i class="fas fa-download"></i></button></div>' ); | ||
memo.downloadEl = jQuery( this ).find( '.download-button' ); | memo.downloadEl = jQuery( this ).find( '.download-button' ); | ||
| Rivi 352: | Rivi 352: | ||
// add show site link button | // add show site link button | ||
if ( memo.showlink ) { | if ( memo.showlink ) { | ||
memo.headerEl.append( '<div class="obschartbutton sitelink-button" style="display: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton sitelink-button" style="display: none; margin-left: 10px; float: right; font-size:18.72px;"><button title="' + i18n['sitelink'][memo.lang] + '" style="width: 24px; height: 24px; padding: 0; margin: 0; background: none; border: none; "><i class="fas fa-map-marked"></i></button></div>' ); | ||
memo.sitelinkEl = jQuery( this ).find( '.sitelink-button' ); | memo.sitelinkEl = jQuery( this ).find( '.sitelink-button' ); | ||
memo.sitelinkEl.on( 'click', function() { | memo.sitelinkEl.on( 'click', function() { | ||
| Rivi 516: | Rivi 516: | ||
// create addinfo | // create addinfo | ||
obs.addInfo = ""; | obs.addInfo = ""; | ||
if ( !!obs.media_url ) { | if ( !!obs.media_url ) { | ||
obs.img = new Image(); | obs.img = new Image(); | ||
obs.img.src = obs.media_url; | obs.img.src = obs.media_url; | ||
obs.addInfo = '<img style=" | obs.addInfo = '<img style="object-fit: cover; width: 200px; height: 200px; margin: 5px 0 8px 0;" src="' + obs.media_url + '" />'; | ||
} | } | ||
if ( !!obs.printouts[ 'Lisätiedot' ][0] ) { | if ( !!obs.printouts[ 'Lisätiedot' ][0] ) { | ||
| Rivi 579: | Rivi 579: | ||
// create popup for obs | // create popup for obs | ||
obs.popup = '<div style="padding: 8px;">'; | obs.popup = '<div style="padding: 8px; white-space: normal;">'; | ||
obs.popup += '<div>'; | obs.popup += '<div>'; | ||
| Rivi 591: | Rivi 591: | ||
obs.popup += '(' + obs.obsdatetime.inRelationToToday(memo.lang) + ')'; | obs.popup += '(' + obs.obsdatetime.inRelationToToday(memo.lang) + ')'; | ||
obs.popup += '</div>'; | obs.popup += '</div>'; | ||
if (!!obs.addInfo) { | if (!!obs.addInfo) { | ||
| Rivi 668: | Rivi 668: | ||
for ( var dv in memo.depthsO[ di ].values ) { | for ( var dv in memo.depthsO[ di ].values ) { | ||
memo.depthsO[ di ]['valstrings'].push( memo.depthsO[ di ].values[ dv ].toString().replace( '.', ',' ) ); | memo.depthsO[ di ]['valstrings'].push( memo.depthsO[ di ].values[ dv ].toString().replace( '.', ',' ) ); | ||
} | } | ||
| Rivi 687: | Rivi 686: | ||
if ( depthcats[0] == 'surface' ) { | if ( depthcats[0] == 'surface' ) { | ||
memo.title = memo.title.replace( ' | memo.title = memo.title.replace( '[D]', '(' + i18n[ 'surface' ][ memo.lang ] + ')' ); | ||
} else if ( depthcats[0] == 'bottom' ) { | } else if ( depthcats[0] == 'bottom' ) { | ||
memo.title = memo.title.replace( ' | memo.title = memo.title.replace( '[D]', '(' + i18n[ 'bottom' ][ memo.lang ] + ')' ); | ||
} | } | ||
} else if ( depthcats.length == 2 ) { | } else if ( depthcats.length == 2 ) { | ||
| Rivi 725: | Rivi 724: | ||
memo.options.vAxis.viewWindow.min = 0; | memo.options.vAxis.viewWindow.min = 0; | ||
} else { | } else { | ||
memo.options.vAxis.viewWindow.min = memo.obsMinValue; | // memo.options.vAxis.viewWindow.min = memo.obsMinValue; | ||
} | } | ||
} else { | } else { | ||
| Rivi 747: | Rivi 746: | ||
} | } | ||
if ( memo.info == '' && depthcats.length == 1 ) { | if ( memo.info == '' ) { | ||
if ( memo.siteid != '-' && memo.addsitetoinfo ) { | |||
memo.info += i18n[ 'siteinfostring' ][ memo.lang] + ': ' + memo.jw.site[ memo.siteid ].name; | |||
} | |||
if ( depthcats.length == 1 ) { | |||
if ( memo.depthsO[ depthcats[0] ].valstring != '' ) { | |||
if ( memo.info != '' ) { memo.info += "<br />"; } | |||
memo.info += i18n[ 'depthinfostring' ][ memo.lang] + ': ' + memo.depthsO[ depthcats[0] ].valstring; | |||
} | |||
} | } | ||
} | } | ||
if ( memo.info != '' ) { | if ( memo.info != '' ) { | ||
memo.titleEl.append( ' <button style="padding: 0 0.25em; font-size: 13px; margin-bottom: 3px;" type="button" class="btn btn-secondary btn-info" data-toggle="tooltip" data-placement="top" title="' + memo.info + '"><span class="fontawesome"></span></button>' ); | memo.titleEl.append( ' <button style="padding: 0 0.25em; font-size: 13px; margin-bottom: 3px;" type="button" class="btn btn-secondary btn-info" data-toggle="tooltip" data-placement="top" data-html="true" title="' + memo.info + '"><span class="fontawesome"></span></button>' ); | ||
jQuery( '[data-toggle="tooltip"]' ).tooltip(); | jQuery( '[data-toggle="tooltip"]' ).tooltip(); | ||
} | } | ||
| Rivi 996: | Rivi 1 002: | ||
function addDataToSeasonWithRefsChart(memo) { | function addDataToSeasonWithRefsChart(memo) { | ||
console.log( memo ); | |||
// do axis min and max | // do axis min and max | ||
memo.axisMinDate = new Date( memo.curSeason, 0, 1 ); | memo.axisMinDate = new Date( memo.curSeason, 0, 1 ); | ||
| Rivi 1 226: | Rivi 1 232: | ||
} | } | ||
if ( memo.trendType == 'linear' ) { | for ( var t in memo.options.trendlines ) { | ||
if ( memo.trendType == 'linear' ) { | |||
memo.options.trendlines[ t ].type = 'linear'; | |||
} else if ( memo.trendType = 'poly2deg' ) { | |||
memo.options.trendlines[ t ].type = 'polynomial'; | |||
memo.options.trendlines[ t ].degree = 2; | |||
} else if ( memo.trendType = 'poly3deg' ) { | |||
memo.options.trendlines[ t ].type = 'polynomial'; | |||
memo.options.trendlines[ t ].degree = 3; | |||
} else if ( memo.trendType == 'smart' ) { | |||
if ( ( memo.axisMaxDate.getFullYear() - memo.axisMinDate.getFullYear() > 10 ) && memo.obsesTotal > 20 ) { | if ( ( memo.axisMaxDate.getFullYear() - memo.axisMinDate.getFullYear() > 10 ) && memo.obsesTotal > 20 ) { | ||
memo.options.trendlines[ t ].type = 'polynomial'; | memo.options.trendlines[ t ].type = 'polynomial'; | ||
| Rivi 1 389: | Rivi 1 398: | ||
// make week averages | // make week averages | ||
memo.avgW = {}; | memo.avgW = {}; | ||
for ( var o in memo.obsesA ) { | for ( var o in memo.obsesA ) { | ||
mwDate = new Date( memo.obsesA[o].compareDate.getTime() ); | mwDate = new Date( memo.obsesA[o].compareDate.getTime() ); | ||
mwDate.setDate( mwDate.getDate() - mwDate.getDay() + 3 ); | mwDate.setDate( mwDate.getDate() - mwDate.getDay() + 3 ); | ||
| Rivi 1 400: | Rivi 1 407: | ||
v = memo.obsesA[o].value + memo.distF*Math.random() - memo.distF*Math.random(); | v = memo.obsesA[o].value + memo.distF*Math.random() - memo.distF*Math.random(); | ||
if ( memo.season == 'winter' && w == 1 && y == memo.curSeason ) { y++; } | |||
if ( typeof memo.avgW[y] == 'undefined' ) { memo.avgW[y] = {}; } | if ( typeof memo.avgW[y] == 'undefined' ) { memo.avgW[y] = {}; } | ||
if ( typeof memo.avgW[y][w] == 'undefined' ) { | if ( typeof memo.avgW[y][w] == 'undefined' ) { | ||
memo.avgW[y][w] = { cDate: mwDate, values: [ v ], sum: v, count: 1, avg: v }; | memo.avgW[y][w] = { cDate: mwDate, values: [ v ], sum: v, count: 1, avg: v }; | ||
} else { | } else { | ||
| Rivi 1 616: | Rivi 1 624: | ||
dataRow[s*4+3] = obs.popup; | dataRow[s*4+3] = obs.popup; | ||
if ( ( today.getTime() - obs.compareDate.getTime() < 10*24*60*60*1000 ) && s == 0 && o == ( memo.seasonsO[memo.seasonsA[s]].obses.length - 1 ) ) { | if ( ( today.getTime() - obs.compareDate.getTime() < 10*24*60*60*1000 ) && s == 0 && o == ( memo.seasonsO[memo.seasonsA[s]].obses.length - 1 ) ) { | ||
y = obs.mwDate.getFullYear(); | |||
w = obs.mwDate.getWeek(); | |||
if ( memo.season == 'winter' && w == 1 && y == memo.curSeason ) { y++; } | |||
var diff = obs.value - memo.avgW[ y ][ w ].avg; | |||
var diff = Math.round( diff*100 ); | var diff = Math.round( diff*100 ); | ||
var diffStr = diff.toString() + ' cm'; | var diffStr = diff.toString() + ' cm'; | ||
| Rivi 1 668: | Rivi 1 679: | ||
} | } | ||
} | } | ||
if ( memo.obscode == 'level' ) { | |||
memo.options.vAxis.viewWindow.min = Math.floor( memo.obsMinValue * 10 ) / 10; | |||
memo.options.vAxis.viewWindow.max = Math.ceil( memo.obsMaxValue * 10 ) / 10 ; | |||
} | |||
//console.log( memo ); | |||
drawChart( memo ); | drawChart( memo ); | ||
| Rivi 1 773: | Rivi 1 791: | ||
} | } | ||
var doResize = function( memo, force = false ) { | var doResize = function( memo, force = false ) { | ||
console.log( 'reize'); | |||
function wait() { | function wait() { | ||
if ( typeof memo.chartEl != 'undefined' && typeof memo.options != 'undefined' ) { | |||
var w = memo.chartEl.width(); | var w = memo.chartEl.width(); | ||
| Rivi 1 843: | Rivi 1 865: | ||
memo.chart.draw( memo.data, memo.options ); | memo.chart.draw( memo.data, memo.options ); | ||
} | } | ||
} else { | |||
setTimeout( wait, 500 ); | |||
} | |||
} | } | ||
//wait(); | //wait(); | ||
if ( typeof memo.chartEl != 'undefined' ) { | if ( typeof memo.chartEl != 'undefined' ) { | ||
setTimeout( wait, | setTimeout( wait, 100 ); | ||
} | } | ||
| Rivi 1 915: | Rivi 1 940: | ||
'surface': { 'fi': 'pinta', 'en': 'surface', 'sv': 'ytan' }, | 'surface': { 'fi': 'pinta', 'en': 'surface', 'sv': 'ytan' }, | ||
'bottom': { 'fi': 'pohja', 'en': 'bottom', 'sv': 'bottnet' }, | 'bottom': { 'fi': 'pohja', 'en': 'bottom', 'sv': 'bottnet' }, | ||
'depthinfostring': { 'fi': 'Havainnot | 'siteinfostring': { 'fi': 'Havaintopaikka', 'en': 'Observation site', 'sv': 'Observationsplatsen' }, | ||
'depthinfostring': { 'fi': 'Havainnot syvyydeltä', 'en': 'Depth of observations', 'sv': 'Djup för observationer' }, | |||
'download': { 'fi': 'Lataa csv-muodossa', 'en': 'Download in csv format', 'sv': 'Ladda ner i csv-format' }, | 'download': { 'fi': 'Lataa csv-muodossa', 'en': 'Download in csv format', 'sv': 'Ladda ner i csv-format' }, | ||
'fullscreen': { 'fi': 'Ota käyttöön/poista kokoruututila', 'en': 'Toggle fullscreen mode', 'sv': 'Växla helskärmsläge' }, | 'fullscreen': { 'fi': 'Ota käyttöön/poista kokoruututila', 'en': 'Toggle fullscreen mode', 'sv': 'Växla helskärmsläge' }, | ||
| Rivi 1 934: | Rivi 1 960: | ||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | 'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | ||
}, | }, | ||
'elodea': { | |||
'type': 'cat', | |||
'min': -0.5, | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Vesirutto', 'en': 'Elodea canadensis', 'sv': 'Vattenpest' }, | |||
'catNames': { | |||
0: { 'fi': 'Ei vesiruttoa', 'en': 'No E. canadensis', 'sv': 'Ingen vattenpest' }, | |||
1: { 'fi': 'Hieman vesiruttoa', 'en': 'Some E. canadensis', 'sv': 'Lite med vattenpest' }, | |||
2: { 'fi': 'Runsaasti vesiruttoa', 'en': 'Abundant with E. canadensis', 'sv': 'Rikligt med vattenpest' }, | |||
3: { 'fi': 'Erittäin runsaasti vesiruttoa', 'en': 'Very abundant with E. canadensis', 'sv': 'Ytterst rikligt med vattenpest' } | |||
}, | |||
'catNamesShort': { | |||
0: { 'fi': 'Ei yhtään', 'en': 'None', 'sv': 'Ingen' }, | |||
1: { 'fi': 'Hieman', 'en': 'Some', 'sv': 'Lite' }, | |||
2: { 'fi': 'Runsaasti', 'en': 'Abundant', 'sv': 'Rikligt' }, | |||
3: { 'fi': 'Erit. runsaasti', 'en': 'Very abundant', 'sv': 'Ytterst rikligt' } | |||
}, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
}, | |||
'jelly': { | |||
'type': 'cat', | |||
'min': -0.5, | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Meduusat', 'en': 'Jelly fish', 'sv': 'Maneter' }, | |||
'catNames': { | |||
0: { 'fi': 'Ei meduusoja', 'en': 'No jelly fish', 'sv': 'Inga maneter' }, | |||
1: { 'fi': 'Vähän meduusoja', 'en': 'Some jelly fish', 'sv': 'Lite med maneter' }, | |||
2: { 'fi': 'Runsaasti meduusoja', 'en': 'Abundant with jelly fish', 'sv': 'Rikligt med maneter' } | |||
}, | |||
'catNamesShort': { | |||
0: { 'fi': 'Ei yhtään', 'en': 'None', 'sv': 'Inga' }, | |||
1: { 'fi': 'Vähän', 'en': 'Some', 'sv': 'Lite' }, | |||
2: { 'fi': 'Runsaasti', 'en': 'Abundant', 'sv': 'Rikligt' } | |||
}, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
}, | |||
'trash': { | |||
'type': 'cat', | |||
'min': -0.5, | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Roskaisuus', 'en': 'Litter', 'sv': 'Rosk' }, | |||
'catNames': { | |||
0: { 'fi': 'Ei roskia', 'en': 'No litter', 'sv': 'Ingen rosk' }, | |||
1: { 'fi': 'Vähän roskia', 'en': 'Some litter', 'sv': 'Lite med rosk' }, | |||
2: { 'fi': 'Paljon roskia', 'en': 'Abundant with litter', 'sv': 'Rikligt med rosk' }, | |||
3: { 'fi': 'Erittäin paljon roskia', 'en': 'Very abundant with litter', 'sv': 'Ytterst rikligt med rosk' }, | |||
}, | |||
'catNamesShort': { | |||
0: { 'fi': 'Ei yhtään', 'en': 'None', 'sv': 'Inga' }, | |||
1: { 'fi': 'Vähän', 'en': 'Some', 'sv': 'Lite' }, | |||
2: { 'fi': 'Paljon', 'en': 'Abundant', 'sv': 'Rikligt' }, | |||
3: { 'fi': 'Erit. paljon', 'en': 'Very abundant', 'sv': 'Ytterst rikligt' }, | |||
}, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
}, | |||
'temp': { | 'temp': { | ||
'type': 'num', | 'type': 'num', | ||
| Rivi 2 049: | Rivi 2 136: | ||
'season': 'summer', | 'season': 'summer', | ||
'min': 0, | 'min': 0, | ||
'max': 110, | |||
'direction': 1, | 'direction': 1, | ||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | 'trend': { 'type': 'gaussian', 'layout': 'line' }, | ||
| Rivi 2 172: | Rivi 2 260: | ||
'long': { 'fi': 'Elokuu', 'en': 'August', 'sv': 'Augusti', 'ru': '???' }, | 'long': { 'fi': 'Elokuu', 'en': 'August', 'sv': 'Augusti', 'ru': '???' }, | ||
'short': { 'fi': 'Elo', 'en': 'Aug', 'sv': 'Aug', 'ru': '???' }, | 'short': { 'fi': 'Elo', 'en': 'Aug', 'sv': 'Aug', 'ru': '???' }, | ||
'roman': ' | 'roman': 'VIII' | ||
}, | }, | ||
8: { | 8: { | ||


