diff --git a/resources/js/CustomHandling/CustomHandling.js b/resources/js/CustomHandling/CustomHandling.js index 04ea7620a..b66ebcecc 100644 --- a/resources/js/CustomHandling/CustomHandling.js +++ b/resources/js/CustomHandling/CustomHandling.js @@ -1,16 +1,68 @@ $(document).ready(function() { + + function HVcustomHandling(thisHVcomponent) { + + function hvtutorialHandling(thisHVtutSection) { + // custom close button function + $("#tool #close").click(function(){ + + // revert back to saved state of userSettings + + }); + + switch(thisHVtutSection) { + + case 'hvtutorial_CB_click': + // if the Featured Events section is showing, hide it + if($("#accordion-events .disclosure-triangle:first").hasClass("closed")===false){ + $("#accordion-events .disclosure-triangle:first").addClass("closed"); + $("#accordion-events .content, #soho-dynaccordion .dynaccordion-cell, #stereo_a-dynaccordion .dynaccordion-cell, #stereo_b-dynaccordion .dynaccordion-cell").css("display","none"); + } + + break; + } + + } + + + + switch(thisHVcomponent) { + case 'hvtutorial_CB_click': + hvtutorialHandling(thisHVcomponent); + break; + } + + + } + + + // START Encounter Count - $('#stereo_a-psp-tree-trajectory .button, #soho-psp-tree-trajectory .button').click(function(){ + function showEncounter() { - $.getJSON("https://api.beta.helioviewer.org/resources/JSON/celestial-objects/soho/psp/soho_psp_dictionary.json?rndnm=", function(pspdata){ - - console.log('getJSON succeeded'); + + + var thishvurlstr = window.location.href; + + + if(thishvurlstr.search('beta.helioviewer')==-1) { + thishvapiurl= "https://api.helioviewer.org"; + } + else { + thishvapiurl= "https://api.beta.helioviewer.org"; + } + + setTimeout(function() { + + $.getJSON(thishvapiurl+"/resources/JSON/celestial-objects/soho/psp/soho_psp_dictionary.json?rndnm=", function(pspdata){ + + var pspencnum=0; // loop through each encounter $.each(pspdata, function(pspvalue, pspkey){ - console.log(pspkey, pspvalue); + pspencnum++; @@ -23,28 +75,27 @@ $(document).ready(function() { var pspstartenc = myPSPObj; + // if the very first appropriate encounter div exists if($('#soho-psp-container-hover-date-'+pspstartenc).length > 0 || $('#stereo_a-psp-trajectory-hover-date-'+pspstartenc).length > 0) { + $(".hover-date-container").removeClass("hvenclabels"); - if($('#soho-psp-container-hover-date-'+pspstartenc).length > 0) { - var numEncPoints= $('#soho-psp-trajectory .hover-date-container').length; - } - else if($('#stereo_a-psp-trajectory-hover-date-'+pspstartenc).length > 0) { - var numEncPoints= $('#stereo_a-psp-trajectory .hover-date-container').length; - } + + $('.hover-date-container').css('height','33px'); + + const hvencelems = document.getElementsByClassName('hvenclabels'); + while(hvencelems.length > 0){ + hvencelems[0].parentNode.removeChild(hvencelems[0]); + } + + $(".hover-date-container").removeClass("hvenclabels"); + + $('.hover-date-container').append(''); + $('.hvenclabels').html('
Encounter '+pspencnum); + //document.getElementsByClassName("hover-date-container").innerHTML+= '
Encounter '+pspencnum; - console.log('found current encounter'); - // go through each encounter unix time and append the Encounter to each label - for(var psp_subenc=1;psp_subenc<=numEncPoints;psp_subenc++) { - $('#soho-psp-trajectory .hover-date-container, #stereo_a-psp-trajectory .hover-date-container').css('height','33px'); - $('#soho-psp-trajectory .hover-date-container, #stereo_a-psp-trajectory .hover-date-container').append('
Encounter '+pspencnum); - $('#showjsondata').append('#stereo_a-psp-trajectory-hover-date-'+pspstartenc+' // Encounter '+pspencnum+'
'); - pspstartenc+=21600000; - } - - } }); @@ -52,11 +103,35 @@ $(document).ready(function() { - }).fail(function(){ - console.log('getJSON failed'); - }); + }).fail(function(){ + console.log('Parker Solar Probe JSON failed'); + }); + + }, 500); + + } + $(document).on('click', '#stereo_a-psp-tree-trajectory .button, #soho-psp-tree-trajectory .button, #zoom-out-button, #zoom-in-button', function () { + showEncounter(); }); -}); + $("#helioviewer-viewport").bind("mousewheel", function(){showEncounter()}); + + showEncounter(); + + // END Encounter Count + + + // interactive tutorial Celestial Bodies positioning + $(document).on('click','#bvmodal_4', function() { + HVcustomHandling('hvtutorial_CB_click'); + }); + + +}); // end of doc ready + + + + +