Ero sivun ”Widget:JwObsCharts2” versioiden välillä
Järvi-meriwikistä
(30 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
Rivi 82: | Rivi 82: | ||
memo.obscodeParts = memo.obscode.split('_'); | memo.obscodeParts = memo.obscode.split('_'); | ||
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 = jQuery( this ).attr( 'data- | + | memo.info = jQuery( this ).attr( 'data-info' ); if ( typeof memo.info == 'undefined' ) { memo.info = ""; } |
+ | memo.caption = jQuery( this ).attr( 'data-caption' ); if ( typeof memo.caption == 'undefined' ) { memo.caption = ""; } | ||
+ | //console.log( jQuery( this ).attr( 'data-showlink' ) ); | ||
+ | if ( typeof jQuery( this ).attr( 'data-showlink' ) == 'undefined' ) { | ||
+ | //console.log( 'sd' ); | ||
+ | memo.showlink = false; | ||
+ | } else { | ||
+ | memo.showlink = ( jQuery( this ).attr( 'data-showlink' ).toLowerCase() == 'true' ); | ||
+ | } | ||
if ( typeof jQuery( this ).attr( 'data-min' ) != 'undefined' ) { i18n[memo.obscode]['min'] = parseInt( jQuery( this ).attr( 'data-min' ) ); } | if ( typeof jQuery( this ).attr( 'data-min' ) != 'undefined' ) { i18n[memo.obscode]['min'] = parseInt( jQuery( this ).attr( 'data-min' ) ); } | ||
Rivi 117: | Rivi 125: | ||
// add chart container | // add chart container | ||
− | memo.widgetEl.append( '<div class="card JwCard mb-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>' ); | + | memo.widgetEl.append( '<div class="card JwCard mb-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' ); | ||
− | memo.headerEl = jQuery( this ).find( '.card-header' ); | + | memo.headerEl = jQuery( this ).find( '.card-header' ); |
+ | memo.footerEl = jQuery( this ).find( '.card-footer' ); | ||
// add title | // add title | ||
memo.headerEl.append( '<div class="obscharttitle" style="float: left;"></div>' ); | memo.headerEl.append( '<div class="obscharttitle" style="float: left;"></div>' ); | ||
memo.titleEl = jQuery( this ).find( '.obscharttitle' ); | memo.titleEl = jQuery( this ).find( '.obscharttitle' ); | ||
+ | console.log( memo ); | ||
+ | // add or hide footer | ||
+ | if ( memo.caption == '' ) { | ||
+ | memo.footerEl.hide(); | ||
+ | } else { | ||
+ | memo.footerEl.append( memo.caption ); | ||
+ | } | ||
// add fullscreen button | // add fullscreen button | ||
Rivi 314: | Rivi 330: | ||
}); | }); | ||
+ | } | ||
+ | |||
+ | // add show site link button | ||
+ | if ( memo.showlink ) { | ||
+ | memo.headerEl.append( '<div class="obschartbutton sitelink-button" style="display: none; margin-left: 10px; float: right; Xbackground-color: rgba( 255, 255, 255, 1 ); border-radius: 50%; Xborder: 1px solid rgba( 0, 0, 0, 0.5 ); Xpadding: 1px;"><button title="' + i18n['sitelink'][memo.lang] + '" style="width: 24px; height: 24px; padding: 0; margin: 0; color: #1B599B; background: none; border: none; "><i class="fas fa-map-marked"></i></button></div>' ); | ||
+ | memo.sitelinkEl = jQuery( this ).find( '.sitelink-button' ); | ||
+ | memo.sitelinkEl.on( 'click', function() { | ||
+ | var elem = memo.widgetEl[0]; | ||
+ | window.location.href = 'https://www.jarviwiki.fi/w/index.php?curid=' + memo.siteid; | ||
+ | }); | ||
} | } | ||
− | } | + | } |
memo.loadStarts = 0; | memo.loadStarts = 0; | ||
Rivi 618: | Rivi 644: | ||
} | } | ||
− | if ( | + | 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" title="' + memo.info + '"><span class="fontawesome"></span></button>' ); | ||
jQuery( '[data-toggle="tooltip"]' ).tooltip(); | jQuery( '[data-toggle="tooltip"]' ).tooltip(); | ||
Rivi 907: | Rivi 933: | ||
memo.options.series[1] = { type: 'line', pointSize: 0, color: colors.curObses, lineWidth: 5 }; | memo.options.series[1] = { type: 'line', pointSize: 0, color: colors.curObses, lineWidth: 5 }; | ||
− | memo.options.vAxis.viewWindow.min = 80.5; | + | //memo.options.vAxis.viewWindow.min = 80.5; |
− | memo.options.vAxis.viewWindow.max = 81.7; | + | //memo.options.vAxis.viewWindow.max = 81.7; |
memo.chart = new google.visualization.LineChart( memo.chartEl[0] ); // document.getElementById(memo.id) | memo.chart = new google.visualization.LineChart( memo.chartEl[0] ); // document.getElementById(memo.id) | ||
Rivi 1 415: | Rivi 1 441: | ||
memo.fullscreenEl.fadeIn( "slow" ); | memo.fullscreenEl.fadeIn( "slow" ); | ||
if ( memo.download) { memo.downloadEl.fadeIn( "slow" ); } | if ( memo.download) { memo.downloadEl.fadeIn( "slow" ); } | ||
+ | if ( memo.showlink ) { memo.sitelinkEl.fadeIn( "slow" ); } | ||
memo.selectedCol = 0; | memo.selectedCol = 0; | ||
Rivi 1 478: | Rivi 1 505: | ||
function wait() { | function wait() { | ||
− | console.log( memo.options ); | + | //console.log( memo.options ); |
var w = memo.chartEl.width(); | var w = memo.chartEl.width(); | ||
Rivi 1 523: | Rivi 1 550: | ||
// move current observations to top | // move current observations to top | ||
gEl = jQuery( document.getElementById(memo.id) ).find( 'svg' ).append( 'g' ); | gEl = jQuery( document.getElementById(memo.id) ).find( 'svg' ).append( 'g' ); | ||
+ | //console.log( jQuery( document.getElementById(memo.id) ).find( 'svg' ) ); | ||
jQuery( document.getElementById(memo.id) ).find( 'path[stroke="#3366cc"]' ).detach().appendTo( gEl ); | jQuery( document.getElementById(memo.id) ).find( 'path[stroke="#3366cc"]' ).detach().appendTo( gEl ); | ||
jQuery( document.getElementById(memo.id) ).find( 'circle[fill="#3366cc"]' ).detach().appendTo( gEl ); | jQuery( document.getElementById(memo.id) ).find( 'circle[fill="#3366cc"]' ).detach().appendTo( gEl ); | ||
jQuery( document.getElementById(memo.id) ).find( 'circle[stroke-width="3"]' ).each( function() { jQuery( this ).parent().append( jQuery( this ) ); }); | jQuery( document.getElementById(memo.id) ).find( 'circle[stroke-width="3"]' ).each( function() { jQuery( this ).parent().append( jQuery( this ) ); }); | ||
− | + | ||
+ | jQuery( 'circle[fill="#3366cc"]' ).each( function() { | ||
+ | //jQuery( this ).detach().appendTo( gEl ); | ||
+ | }); | ||
} | } | ||
} | } | ||
Rivi 1 599: | Rivi 1 630: | ||
'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' }, | ||
+ | 'sitelink': { 'fi': 'Mene havaintopaikan sivulle', 'en': "Go to the observation site's page", 'sv': 'Gå till observationsplatsen.' }, | ||
'edit': { 'fi': 'Lisää/muokkaa havaintoja', 'en': 'Add/edit observations', 'sv': 'Lägg till/redigera observationer' }, | 'edit': { 'fi': 'Lisää/muokkaa havaintoja', 'en': 'Add/edit observations', 'sv': 'Lägg till/redigera observationer' }, | ||
'season': { 'winter': { 'fi': 'Talvi', 'en': 'Winter', 'sv': 'Vintern' } }, | 'season': { 'winter': { 'fi': 'Talvi', 'en': 'Winter', 'sv': 'Vintern' } }, |