function afterIframeLoad(iframeElement) { //I can't really modify these unfortunately. console.log('Iframe was totally loaded.'); if( !iframeElement.contentWindow.map ) { //We should just return, there's no map element loaded, so this is probably about:blank return true; } jQuery(iframeElement).contents().find('.glyphicon.glyphicon-menu-hamburger') .removeClass('glyphicon glyphicon-menu-hamburger') .addClass('fa fa-bars') .css({ position:'relative', color:'white', top:'60px', backgroundColor:'rgba(0,0,0,.5)', width:'30px', height:'30px', fontSize:'30px' }); iframeElement.contentWindow.map.removeLayer(iframeElement.contentWindow.tc2015); iframeElement.contentWindow.map.removeLayer(iframeElement.contentWindow.wc2015); iframeElement.contentWindow.map.removeLayer(iframeElement.contentWindow.fl20102015); iframeElement.contentWindow.map.removeLayer(iframeElement.contentWindow.cntryBoundaries); iframeElement.contentWindow.view.setMinZoom(0); iframeElement.contentWindow.view.setZoom(2); iframeElement.contentWindow.map.setView(iframeElement.contentWindow.view); iframeElement.contentWindow.tc2015 = new iframeElement.contentWindow.ol.layer.Tile({ title: 'Tree Cover 2015', name: 'tc2015', visible: true, preload: Infinity, source: new iframeElement.contentWindow.ol.source.XYZ({ minZoom:3, url: 'https://tpts01.terrapulse.com:8090/map/tcc_global_2015_50/{z}/{x}/{-y}.png', attributions: [new iframeElement.contentWindow.ol.Attribution({ html: '© <' + String.fromCharCode(97) + ' href="https://www.terrapulse.com" target="_blank">terraPulse Tree Cover 2015' })] }) }); iframeElement.contentWindow.wc2015 = new iframeElement.contentWindow.ol.layer.Tile({ title: 'Water Cover 2015', name: 'wc2015', visible: false, minResolution : 2, preload: Infinity, source: new iframeElement.contentWindow.ol.source.XYZ({ minZoom:3, url: 'https://tpts01.terrapulse.com:8090/map/global_water_freq_2010_2015/{z}/{x}/{-y}.png', attributions: [new iframeElement.contentWindow.ol.Attribution({ html: '© <' + String.fromCharCode(97) + ' href="https://www.terrapulse.com" target="_blank">terraPulse Water Cover 2015' })] }) }); iframeElement.contentWindow.fl20102015 = new iframeElement.contentWindow.ol.layer.Tile({ title: 'Forest Loss 2010 - 2015', name: 'fl20102015', visible: false, minResolution : 2, preload: Infinity, source: new iframeElement.contentWindow.ol.source.XYZ({ minZoom:3, url: 'https://tpts01.terrapulse.com:8090/map/loss_2010_2015_30p/{z}/{x}/{-y}.png', attributions: [new iframeElement.contentWindow.ol.Attribution({ html: '© <' + String.fromCharCode(97) + ' href="http://www.terrapulse.com" target="_blank">terraPulse Forest Loss 2010 2015' })] }) }); iframeElement.contentWindow.cntryBoundaries = new iframeElement.contentWindow.ol.layer.Tile({ title: 'Admin Boundaries', name: 'cntryBoundaries', visible: false, minResolution : 2, preload: Infinity, source: new iframeElement.contentWindow.ol.source.XYZ({ minZoom:3, url: 'https://server.arcgisonline.com/arcgis/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{x}/{y}.png', attributions: [new iframeElement.contentWindow.ol.Attribution({ html: '© navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1 ) { //If we go over to the next one, we'll stop here. navi_helper.pictureModule.picturePointer[setNum].currentPointer = navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1; navi_helper.pictureModule.pause(setNum); return true; } var newSrc = navi_helper.picRotName.replace('{0}', navi_helper.pictureModule.picturePointer[setNum].imgSet[navi_helper.pictureModule.picturePointer[setNum].currentPointer] ); jQuery(navi_helper.pictureModule.picturePointer[setNum].imgID).prop({ src: './images/story2/hinter-maps/' + newSrc }); jQuery(navi_helper.pictureModule.picturePointer[setNum].imgID+'-title').text( navi_helper.pictureModule.picturePointer[setNum].imgSet[navi_helper.pictureModule.picturePointer[setNum].currentPointer] ); jQuery(navi_helper.pictureModule.picturePointer[setNum].sliderID).val(navi_helper.pictureModule.picturePointer[setNum].currentPointer); if( navi_helper.pictureModule.picturePointer[setNum].syncToGraph ) { navi_helper.pictureModule.synchronizeGraph(setNum); } }, (1000 / this.myFPS)); //Let's now refresh }, pause: function (setNum) { console.log('[Set: '+ setNum +'] Pause'); if( !this.pictureTimer[setNum] ) { console.log('Already paused or stopped...'); } clearInterval(this.pictureTimer[setNum]); this.pictureTimer[setNum]=null; /* if( this.pictureTimer[page_num] ) { clearInterval(this.pictureTimer[page_num]); this.pictureTimer[page_num]=null; } */ }, sliderGoTo: function (setNum, value) { console.log('[Set: '+ setNum +'] Slider Value: {'+value+'}'); this.pause(setNum); navi_helper.pictureModule.picturePointer[setNum].currentPointer = value; if ( navi_helper.pictureModule.picturePointer[setNum].currentPointer > navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1 ) { //stop here. navi_helper.pictureModule.picturePointer[setNum].currentPointer = navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1; return true; //navi_helper.pictureModule.picturePointer[setNum].currentPointer = 0; }else if ( navi_helper.pictureModule.picturePointer[setNum].currentPointer < 0 ) { navi_helper.pictureModule.picturePointer[setNum].currentPointer = 0; return true; //navi_helper.pictureModule.picturePointer[setNum].currentPointer = navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1; } jQuery(navi_helper.pictureModule.picturePointer[setNum].sliderID).val(navi_helper.pictureModule.picturePointer[setNum].currentPointer); var newSrc = navi_helper.picRotName.replace('{0}', this.picturePointer[setNum].imgSet[this.picturePointer[setNum].currentPointer] ); jQuery(this.picturePointer[setNum].imgID).prop({ src: './images/story2/hinter-maps/' + newSrc }); jQuery(this.picturePointer[setNum].imgID+'-title').text( this.picturePointer[setNum].imgSet[this.picturePointer[setNum].currentPointer] ); if( navi_helper.pictureModule.picturePointer[setNum].syncToGraph ) { navi_helper.pictureModule.synchronizeGraph(setNum); } }, step: function (setNum, stepUp) { console.log('[Set: '+ setNum +'] Step: {'+(stepUp ? 'Up' : 'Back')+'}'); this.pause(setNum); if( stepUp ){ //Next year navi_helper.pictureModule.picturePointer[setNum].currentPointer++; if ( navi_helper.pictureModule.picturePointer[setNum].currentPointer > navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1 ) { //stop here. navi_helper.pictureModule.picturePointer[setNum].currentPointer = navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1; return true; //navi_helper.pictureModule.picturePointer[setNum].currentPointer = 0; } }else{ //previous year navi_helper.pictureModule.picturePointer[setNum].currentPointer--; if ( navi_helper.pictureModule.picturePointer[setNum].currentPointer < 0 ) { navi_helper.pictureModule.picturePointer[setNum].currentPointer = 0; return true; //navi_helper.pictureModule.picturePointer[setNum].currentPointer = navi_helper.pictureModule.picturePointer[setNum].imgSet.length-1; } } jQuery(navi_helper.pictureModule.picturePointer[setNum].sliderID).val(navi_helper.pictureModule.picturePointer[setNum].currentPointer); var newSrc = navi_helper.picRotName.replace('{0}', this.picturePointer[setNum].imgSet[this.picturePointer[setNum].currentPointer] ); jQuery(this.picturePointer[setNum].imgID).prop({ src: './images/story2/hinter-maps/' + newSrc }); jQuery(this.picturePointer[setNum].imgID+'-title').text( this.picturePointer[setNum].imgSet[this.picturePointer[setNum].currentPointer] ); if( navi_helper.pictureModule.picturePointer[setNum].syncToGraph ) { navi_helper.pictureModule.synchronizeGraph(setNum); } return true; }, synchronizeGraph: function (setNum) { //alert(setNum); if( setNum == 1 || setNum == 2 || setNum == 4 || setNum == 5 ) { console.log('[synchronizeGraph] No graphs to synchronize in this set ('+ navi_helper.contentSets[navi_helper.current_page] +').') }else if( setNum == 3 ) { console.log('[synchronizeGraph] Synchronizing Graph to Picture Set 3'); if( !navi_helper.chartModule.chart ) { console.log('Chart not initialized yet, leaving function.'); return true; } //We can just set the data to what we have. var findYear = this.picturePointer[setNum].imgSet[this.picturePointer[setNum].currentPointer]; for(var i=0;i 0) { this.my_chart.series[0].remove(true); } }, clickEnabled:false, chartClickEvent: function ( event ) { }, myFPS:1.5, //a picture will be shown ever ( 1000 / myFPS ) ms chartPointer: { //index is content set 5: { //imgIDs:['#set-2-dynami-image-1', '#set-2-dynami-image-2'], imgID:'', labelID:'#set-5-year-label', sliderID:'#graph-slider-set-5', useChart:'est-spruce-infested', min:1990, max:2017, currentPointer:1990, syncToPic: false, syncToSubchart: false, subchartDetails: [] } }, imgBreakPoints:[ ], chartTimer: { //Set number 5: null }, stopAll: function () { for(var i in this.chartTimer) { if(this.chartTimer[i]){ this.pause(i); } this.resetImg(i); /*if( this.picturePointer[i].syncToGraph ) { this.synchronizeGraph(i); }*/ } return true; }, resetImg: function (setNum){ console.log('Graph: Reset Image for set `',setNum,'`') this.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].min; if(this.chartPointer[setNum].syncToPic){ jQuery(navi_helper.chartModule.chartPointer[setNum].imgID+'-title').text( this.findImgBreakpoint(navi_helper.chartModule.chartPointer[setNum].currentPointer) ); jQuery(navi_helper.chartModule.chartPointer[setNum].imgID).prop({ src:'./images/story4/ice-loss/'+ this.findImgBreakpoint(navi_helper.chartModule.chartPointer[setNum].currentPointer) +'_ice-loss-anim_revised.jpg' }); } }, findImgBreakpoint: function (myYear){ var i=0; //console.log('findImgBreakpoint: `'+ myYear +'`'); for(i;i navi_helper.chartModule.chartPointer[setNum].max ) { //console.log('Chart pointer is maxxed out. Stopping...',navi_helper.chartModule.chartPointer[setNum].currentPointer, navi_helper.chartModule.chartPointer[setNum].max ); navi_helper.chartModule.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].max; navi_helper.chartModule.pause(setNum); return true; } var translateI = navi_helper.chartModule.chartPointer[setNum].currentPointer - navi_helper.chartModule.chartPointer[setNum].min; navi_helper.chartModule.chart.series[0].setData( navi_helper.chartModule.seriesSets[navi_helper.chartModule.chartPointer[setNum].useChart].slice(0, translateI+1) ); jQuery(navi_helper.chartModule.chartPointer[setNum].sliderID).val(navi_helper.chartModule.chartPointer[setNum].currentPointer); if( navi_helper.chartModule.chartPointer[setNum].syncToPic ) { navi_helper.chartModule.synchronizePicture(setNum); } if( navi_helper.chartModule.chartPointer[setNum].syncToSubchart ) { navi_helper.chartModule.synchronizeSubchart(setNum); } }, (1000 / this.myFPS)); //Let's now refresh }, pause: function (setNum) { console.log('[Set: '+ setNum +'] Pause'); if( !this.chartTimer[setNum] ) { console.log('Already paused or stopped...'); } clearInterval(this.chartTimer[setNum]); this.chartTimer[setNum]=null; }, sliderGoTo: function (setNum, value) { console.log('[Set: '+ setNum +'] Slider Value: {'+value+'}'); navi_helper.chartModule.pause(setNum); navi_helper.chartModule.chartPointer[setNum].currentPointer = value; if ( navi_helper.chartModule.chartPointer[setNum].currentPointer > navi_helper.chartModule.chartPointer[setNum].max ) { navi_helper.chartModule.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].max; return true; }else if ( navi_helper.chartModule.chartPointer[setNum].currentPointer < navi_helper.chartModule.chartPointer[setNum].min ) { navi_helper.chartModule.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].min; return true; } var translateI = navi_helper.chartModule.chartPointer[setNum].currentPointer - navi_helper.chartModule.chartPointer[setNum].min; navi_helper.chartModule.chart.series[0].setData( navi_helper.chartModule.seriesSets[navi_helper.chartModule.chartPointer[setNum].useChart].slice(0, translateI+1) ); //jQuery().val(navi_helper.chartModule.chartPointer[setNum].currentPointer); if( navi_helper.chartModule.chartPointer[setNum].syncToPic ) { navi_helper.chartModule.synchronizePicture(setNum); } if( navi_helper.chartModule.chartPointer[setNum].syncToSubchart ) { navi_helper.chartModule.synchronizeSubchart(setNum); } }, step: function (setNum, stepUp) { console.log('[Set: '+ setNum +'] Step: {'+(stepUp ? 'Up' : 'Back')+'}'); this.pause(setNum); if( stepUp ){ //Next year navi_helper.chartModule.chartPointer[setNum].currentPointer++; if ( navi_helper.chartModule.chartPointer[setNum].currentPointer > navi_helper.chartModule.chartPointer[setNum].max ) { navi_helper.chartModule.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].max; return true; } }else{ //previous year navi_helper.chartModule.chartPointer[setNum].currentPointer--; if ( navi_helper.chartModule.chartPointer[setNum].currentPointer < navi_helper.chartModule.chartPointer[setNum].min ) { navi_helper.chartModule.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].min; return true; } } var translateI = navi_helper.chartModule.chartPointer[setNum].currentPointer - navi_helper.chartModule.chartPointer[setNum].min; navi_helper.chartModule.chart.series[0].setData( navi_helper.chartModule.seriesSets[navi_helper.chartModule.chartPointer[setNum].useChart].slice(0, translateI+1) ); jQuery(navi_helper.chartModule.chartPointer[setNum].sliderID).val(navi_helper.chartModule.chartPointer[setNum].currentPointer); if( navi_helper.chartModule.chartPointer[setNum].syncToPic ) { navi_helper.chartModule.synchronizePicture(setNum); } if( navi_helper.chartModule.chartPointer[setNum].syncToSubchart ) { navi_helper.chartModule.synchronizeSubchart(setNum); } return true; }, destroyAllCharts: function () { if(this.chart){ this.chart.destroy(); this.chart=null; } if(this.subcharts['1']){ this.subcharts['1'].destroy(); this.subcharts['1']=null; } if(this.subcharts['2']){ this.subcharts['2'].destroy(); this.subcharts['2']=null; } if(this.subcharts['3']){ this.subcharts['3'].destroy(); this.subcharts['3']=null; } return true; }, updateGraphState: function ( setNum ) { console.log('[Func(): navi_helper.chartModule.updateGraphState] `' + setNum + '` '); if( setNum == 1 || setNum == 2 || setNum == 3 || setNum == 4 || //setNum == 5 || //only guy with graph this time. setNum == 6 || setNum == 7 || setNum == 8 ){ console.log('[updateGraphState] No graphs in this set ('+ navi_helper.contentSets[navi_helper.current_page] +').'); return true; }else if( setNum == 5 ){ this.destroyAllCharts(); console.log('[updateGraphState] Updating ('+ navi_helper.contentSets[navi_helper.current_page] +').'); console.log('[updateGraphState] Preparing Est. Spruce Infestation.'); this.chart = Highcharts.chart('set-5-chart', { chart: { id:'set5', type: 'spline', spacingRight: 10, }, plotOptions:{}, title: { text: 'Acreage of Spruce Beetle Infested Area 1990 - 2017' }, tooltip:{ useHTML:true, enabled:false }, xAxis: { title: { text: "Year" }, type: 'linear', min:1990, max:2017, labels:{ }, //tickInterval:5, }, yAxis: { title: { text: 'In thousands of acres (estimated)' }, labels:{ }, min:0, max:1250, }, series: [{ name: 'Acreage of Spruce Beetle Infested Area', data: navi_helper.chartModule.seriesSets['est-spruce-infested'].slice(0,1), //navi_helper.chartModule.seriesSets[3]['chart-1'] color:'red' }] }); navi_helper.chartModule.chartPointer[setNum].currentPointer = navi_helper.chartModule.chartPointer[setNum].min; jQuery(navi_helper.chartModule.chartPointer[setNum].sliderID).val(navi_helper.chartModule.chartPointer[setNum].min); navi_helper.chartModule.synchronizeSubchart(setNum); return true; } return true; } }, my_popups:{ 1:[], //None 2:[], //None 3:[], //None 4:[], 5:[], 6:[] }, go_to_page: function ( page_num ) { jQuery('span.hover-box,span.hover-box-img').slideUp(); jQuery('.standard-set').show(); jQuery('.ext-set').hide(); //console.info('[navi_helper]: Go to page `'+ page_num +'`.'); if( page_num == 'next' ) { this.current_page++; }else if( page_num == 'prev' ) { this.current_page--; if( this.current_page < this.min_page) { this.current_page = this.min_page; } }else{ this.current_page = parseInt(page_num); } if( this.current_page < this.min_page) { this.current_page = this.min_page; }else if ( this.max_page < this.current_page ) { this.current_page = this.max_page; } if( this.current_page == 11 ){ console.log('End!'); } //this.pictureModule.stopAll(); this.chartModule.stopAll(); this.chartModule.updateGraphState(navi_helper.contentSets[navi_helper.current_page]); this.chartModule.synchronizePicture(navi_helper.contentSets[navi_helper.current_page]); this.chartModule.synchronizeSubchart(navi_helper.contentSets[navi_helper.current_page]); /* this.chartModule.updateGraphState(navi_helper.contentSets[navi_helper.current_page]); this.chartModule.synchronizePicture(navi_helper.contentSets[navi_helper.current_page]); this.chartModule.synchronizeSubchart(navi_helper.contentSets[navi_helper.current_page]); this.pictureModule.synchronizeGraph(navi_helper.contentSets[navi_helper.current_page]); */ //Specials by Content set if( this.contentSets[this.current_page] == 1 ){ //If this page is 1, add hovers, and remove the background. if( this.current_page == 1 ) { jQuery('.is-clickable', '#mosaic-page-'+this.current_page+'-right' ) .on('click', function (event) { jQuery('span.hover-box-img').html( navi_helper.contentSetInfo[navi_helper.contentSets[navi_helper.current_page]][jQuery(this).data( 'text-set' )] ).slideDown(); console.log('Clicking'); }); //jQuery('span.display-page-1').show(); }/*else if( this.current_page == 2 ) { //jQuery('span.display-page-1').hide(); }*/ }else if( this.contentSets[this.current_page] == 2 ){ if( this.current_page == 2 ) { //jQuery('#set-2-right-pic').prop({src:'/polar_ice/images/story4/globe-90-60N.jpg'}); jQuery('.display-page-2').show(); jQuery('.display-page-3').hide(); }else if( this.current_page == 3 ) { //jQuery('#set-2-right-pic').prop({src:'/polar_ice/images/story4/AlaskaBodySpring.jpg'}); jQuery('.display-page-2').hide(); jQuery('.display-page-3').show(); } }else if( this.contentSets[this.current_page] == 3 ){ console.log('Content Set 3'); if( this.current_page == 4 ) { jQuery('.display-page-4').show(); jQuery('.display-page-5').hide(); }else if( this.current_page == 5 ) { jQuery('.display-page-4').hide(); jQuery('.display-page-5').show(); }/*else if( this.current_page == 6 ) { jQuery('.display-page-4').hide(); jQuery('.display-page-5').hide(); }*/ }else if ( this.contentSets[this.current_page] == 4 ) { }else if ( this.contentSets[this.current_page] == 5 ) { if( this.current_page == 10 ) { jQuery('.display-page-10').show(); jQuery('.display-page-11').hide(); }else if( this.current_page == 11 ) { jQuery('.display-page-10').hide(); jQuery('.display-page-11').show(); } }else if ( this.contentSets[this.current_page] == 6 ) { }else if ( this.contentSets[this.current_page] == 7 ) { jQuery('.display-page-6').show(); }else if ( this.contentSets[this.current_page] == 8 ) { jQuery('.display-page-9').show(); } this.update_info_bubbles(); jQuery('button','#mosaic-button-nav').removeClass('current-page'); jQuery('button[data-page-id="'+ this.current_page +'"]','#mosaic-button-nav').addClass('current-page'); jQuery('.switch-page','#mosaic-page-content').removeClass('view-page'); jQuery('#mosaic-page-' + this.current_page + '-left','#mosaic-page-content').addClass('view-page'); jQuery('#mosaic-right-content-set-' + this.contentSets[this.current_page], '#mosaic-page-content').addClass('view-page'); //jQuery('#play-controls-1').css({display: ( this.current_page > 3 ? 'block' : 'none' ) } ); //this.update_image_information(); return this.next_button_state() && this.prev_button_state(); }, update_info_bubbles: function () { jQuery('span.marker').remove(); var my_icons = navi_helper.my_popups[ this.current_page ]; //console.log('Updating info bubbles.'); for(var index in my_icons ) { var create_icon = my_icons[index]; //Only picture-frame-1 is currently getting icons var target = jQuery('#image-wrapper-1'); //console.log(create_icon); if( create_icon.icon == '' ) { // jQuery('') .css({ top: create_icon.position.top, left: create_icon.position.left }).html('    '+ create_icon.content +''). appendTo(target); }else if( create_icon.icon == 'info' ) { jQuery('') .css({ top: create_icon.position.top, left: create_icon.position.left }).html(''+ create_icon.content +''). appendTo(target); }else if( create_icon.icon == 'penguin' ) { jQuery('') .css({ top: create_icon.position.top, left: create_icon.position.left }).html(''+ create_icon.content +''). appendTo(target); for(var i in create_icon.icon_position){ var new_pos = create_icon.icon_position[i]; jQuery('') .css({ top: new_pos.top, left: new_pos.left }).html(''). appendTo(target); } }else if( create_icon.icon == 'whale' ) { jQuery('') .css({ top: create_icon.position.top, left: create_icon.position.left }).html(''+ create_icon.content +''). appendTo(target); for(var i in create_icon.icon_position){ var new_pos = create_icon.icon_position[i]; jQuery('') .css({ top: new_pos.top, left: new_pos.left }).html(''). appendTo(target); } }else if( create_icon.icon == 'plankton' ) { //Are amoebas plankton? Probably. No longer questioning it. jQuery('') .css({ top: create_icon.position.top, left: create_icon.position.left }).html(''+ create_icon.content +''). appendTo(target); for(var i in create_icon.icon_position){ var new_pos = create_icon.icon_position[i]; jQuery('') .css({ top: new_pos.top, left: new_pos.left }).html(''). appendTo(target); } } } jQuery('span.marker').on('click', function() { var $marker = jQuery(this), $caption = jQuery('span.caption', $marker); //console.log($caption); if( $caption.length < 1 ) { if( $marker.hasClass('penguin') ) { jQuery('span.marker.penguin.is-clickable').trigger('click'); }else if( $marker.hasClass('whale') ) { jQuery('span.marker.whale.is-clickable').trigger('click'); }else if( $marker.hasClass('plankton') ) { jQuery('span.marker.plankton.is-clickable').trigger('click'); } }else{ if ($caption.is(':hidden')) { $caption.slideDown(300); } else { $caption.slideUp(300); } } }); //Fix anchor links in the span marker click to avoid event propagation // and other bad behavior jQuery('span.marker a').on('click', function (event) { event.stopPropagation(); return true; }); return true; }, update_image_information: function () { return true; this.pause_images(1); this.pause_images(2); if( this.current_page < 4 ) { jQuery('#picture-frame-1').removeClass('dual-image'); jQuery('#picture-frame-2').removeClass('dual-image').hide(); jQuery('#image-changer-1').prop({src: this.static_image}); jQuery('#play-controls-1').hide(); return true; } jQuery('#play-controls-1').show(); jQuery('#picture-frame-1').removeClass('dual-image'); jQuery('#picture-frame-2').removeClass('dual-image').hide(); var my_rules = this.dynamic_images[ this.current_page ]; if( my_rules.num_images == 1 ) { this.dynamic_images[ this.current_page ].frames[1].show_picture = 0; jQuery('#play-slider-1').val(0).prop({max:this.dynamic_images[ this.current_page ].frames[1].pictures.length-1}); var pad = "00"; var str_day = '' + this.dynamic_images[ this.current_page ].frames[1].curr_day; var str_hr = '' + this.dynamic_images[ this.current_page ].frames[1].curr_hr; jQuery('#image-changer-1').prop({ src: this.dynamic_images[ this.current_page ].location + '201502' + pad.substring(0, pad.length - str_day.length) + str_day + 'T' + pad.substring(0, pad.length - str_hr.length) + str_hr + '00.png' });//.removeClass('dual-image'); jQuery('#picture-frame-2').css({display:'none'}); }else{ jQuery('#play-slider-1').val(0).prop({max:this.dynamic_images[ this.current_page ].frames[1].pictures.length-1}); jQuery('#play-slider-2').val(0).prop({max:this.dynamic_images[ this.current_page ].frames[2].pictures.length-1}); this.dynamic_images[ this.current_page ].frames[1].show_picture = 0; this.dynamic_images[ this.current_page ].frames[2].show_picture = 0; jQuery('#picture-frame-1').addClass('dual-image'); jQuery('#picture-frame-2').addClass('dual-image').css({display:'inline-block'}); var pad = "00"; var str_day = '' + this.dynamic_images[ this.current_page ].frames[1].curr_day; var str_hr = '' + this.dynamic_images[ this.current_page ].frames[1].curr_hr; var str_day2 = '' + this.dynamic_images[ this.current_page ].frames[2].curr_day; var str_hr2 = '' + this.dynamic_images[ this.current_page ].frames[2].curr_hr; jQuery('#image-changer-1').prop({ src: this.dynamic_images[ this.current_page ].location + '201502' + pad.substring(0, pad.length - str_day.length) + str_day + 'T' + pad.substring(0, pad.length - str_hr.length) + str_hr + '00.png' }); jQuery('#image-changer-2').prop({ src: this.dynamic_images[ this.current_page ].location + '201502' + pad.substring(0, pad.length - str_day2.length) + str_day2 + 'T' + pad.substring(0, pad.length - str_hr2.length) + str_hr2 + '00.png' }); } if( this.current_page == 4 || this.current_page == 6 ){ if( my_rules.num_images == 1 ) { this.play_images(1); }else{ this.play_images(1); this.play_images(2); } } return true; }, play_images: function (frame_id) { this.pause_images(frame_id); this.my_timer[frame_id] = setInterval( function () { //console.log('Image change.'); navi_helper.forward_image_source(frame_id); }, ( 1000 / this.fps ) ); }, pause_images: function (frame_id) { if( this.my_timer[frame_id] !== null ) { clearInterval( this.my_timer[frame_id] ); this.my_timer[frame_id] = null; } }, step_forward: function (frame_id) { this.pause_images(frame_id); this.forward_image_source(frame_id); }, step_back: function (frame_id) { this.pause_images(frame_id); this.previous_image_source(frame_id); }, go_to_picture: function (frame_id, picture_id){ this.dynamic_images[ this.current_page ].frames[frame_id].show_picture = picture_id; this.show_images(frame_id); }, forward_image_source: function (frame_id) { this.dynamic_images[ this.current_page ].frames[frame_id].show_picture++; if( this.dynamic_images[ this.current_page ].frames[frame_id].show_picture >= this.dynamic_images[ this.current_page ].frames[frame_id].pictures.length ) { this.dynamic_images[ this.current_page ].frames[frame_id].show_picture=0; } //console.log(this.dynamic_images[ this.current_page ]); jQuery('#play-slider-' + frame_id).val( this.dynamic_images[ this.current_page ].frames[frame_id].show_picture ) ; this.show_images(frame_id); return true; }, previous_image_source: function (frame_id) { this.dynamic_images[ this.current_page ].frames[frame_id].show_picture--; if( this.dynamic_images[ this.current_page ].frames[frame_id].show_picture < 0 ) { this.dynamic_images[ this.current_page ].frames[frame_id].show_picture=this.dynamic_images[ this.current_page ].frames[frame_id].pictures.length-1; } jQuery('#play-slider-' + frame_id).val( this.dynamic_images[ this.current_page ].frames[frame_id].show_picture ) ; this.show_images(frame_id); return true; }, show_images: function (frame_id) { var my_rules = this.dynamic_images[ this.current_page ].frames[frame_id]; var pad = "00"; var str_day = '' + this.dynamic_images[ this.current_page ].frames[frame_id].curr_day; var str_hr = '' + this.dynamic_images[ this.current_page ].frames[frame_id].curr_hr; jQuery('#image-changer-' + frame_id).prop({ src: this.dynamic_images[ this.current_page ].frames[frame_id].pictures[ this.dynamic_images[ this.current_page ].frames[frame_id].show_picture ] }); ///polar_ice/maps/justmap_new_160212/tidalcurrents_20150208T0100.png /* jQuery('#image-changer-' + frame_id).prop({ src: this.dynamic_images[ this.current_page ].location + '201502' + pad.substring(0, pad.length - str_day.length) + str_day + 'T' + pad.substring(0, pad.length - str_hr.length) + str_hr + '00.png' }); */ return true; }, prev_button_state: function () { jQuery('#mosaic-prev-button').prop({disabled: (this.current_page == this.min_page) }); return true; }, next_button_state: function () { jQuery('#mosaic-next-button').prop({disabled: (this.current_page == this.max_page) }); return true; }, preload_all_images: function() { return true; }, initialize_pictures: function () { var my_dynamic_images = this.dynamic_images; for(var page in my_dynamic_images){ var my_frames = this.dynamic_images[page].frames; for(var my_frame in my_frames){ //We'll need to calculate then push (in order) var total_time = (this.dynamic_images[ page ].frames[my_frame].curr_day * 100) + this.dynamic_images[ page ].frames[my_frame].curr_hr; var end_time = (this.dynamic_images[ page ].frames[my_frame].end_day * 100) + this.dynamic_images[ page ].frames[my_frame].end_hr; while( total_time < end_time ) { this.dynamic_images[ page ].frames[my_frame].curr_hr++; if( this.dynamic_images[ page ].frames[my_frame].curr_hr >= 24 ) { this.dynamic_images[ page ].frames[my_frame].curr_day++; this.dynamic_images[ page ].frames[my_frame].curr_hr=0; } //e.g. day = 8 (or '08') hour = 11 (or '11'), total time = 811 or ('0811') vs end time of 2200 for day 22, hour 00 total_time = (this.dynamic_images[ page ].frames[my_frame].curr_day * 100) + this.dynamic_images[ page ].frames[my_frame].curr_hr; var pad = "00"; var str_day = '' + this.dynamic_images[ page ].frames[my_frame].curr_day; var str_hr = '' + this.dynamic_images[ page ].frames[my_frame].curr_hr; this.dynamic_images[ page ].frames[my_frame].pictures.push( this.dynamic_images[ page ].location + '201502' + pad.substring(0, pad.length - str_day.length) + str_day + 'T' + pad.substring(0, pad.length - str_hr.length) + str_hr + '00.png' ); } console.info('Page: `'+ page +'`, Frame: `'+ my_frame +'` initialized'); } } return true; }, loadStaticCharts: function () { //Loading static cahrts console.log('[Func(): loadStaticCharts]'); } }; //There might be a conflict with the shorthand Dollar sign ($), so we'll just use jQuery instead jQuery(function () { console.log('[jQuery loaded]'); jQuery.get('https://polar-ice.org/wp-content/uploads/2020/04/story_5_eng.html.txt', function(data) { console.log('THE DATA: ', data); var myHTML = data.replace(/REPLACE_OPEN_ANGLE_BRACKET/g, '<'); myHTML = myHTML.replace(/REPLACE_CLOSE_ANGLE_BRACKET/g, '>'); jQuery('#story-5-div').html(myHTML); console.log('HTML Loaded. Loading other items.'); jQuery.ajax({ url : "https://polar-ice.org/wp-content/uploads/2019/02/story_5_PROXY.txt", dataType: 'text', success : function (data) { var myHTML = data.replace(/REPLACE_OPEN_ANGLE_BRACKET/g, '<'); myHTML = myHTML.replace(/REPLACE_CLOSE_ANGLE_BRACKET/g, '>'); //$('#terra-view').html(data); //Because of CORS via iframes, and the need to demonstrate how terraPulse works, // and with some limitations from their website we needed to override a few commands (and fix the search [mobile]) // We re-added the layers to allow people to zoom out farther and be able to see data from father away. // Credit to TerraPulse var doc = document.getElementById('terra-view').contentWindow.document; doc.open(); doc.write(myHTML); doc.close(); //afterIframeLoad(document.getElementById('terra-view')); } }); jQuery('#mosaic-prev-button').prop({disabled:true}); jQuery('#mosaic-next-button').prop({disabled:false}); jQuery('button','#mosaic-button-nav').on('click', function () { navi_helper.go_to_page( jQuery(this).data('page-id') ); }); //We're going to remove the #sidebar for now and make #main width 100% jQuery('#sidebar').hide(); jQuery('#main').css({width:'100%'}); jQuery('.ext-page').on('click', function () { console.log(jQuery(this).data('extpage') ); jQuery('.standard-set').hide(); jQuery('#' + jQuery(this).data('extpage') ).show(); }); navi_helper.chartModule.initializeGraphs(); navi_helper.initializeButtons(); navi_helper.loadStaticCharts(); navi_helper.go_to_page(0); jQuery('span.hover-box').on('click', function () { jQuery(this).slideUp(); }); jQuery('span.hover-box-img').on('click', function () { jQuery(this).slideUp(); }); }, 'text'); });