Skip to content

Commit

Permalink
Update CustomHandling.js
Browse files Browse the repository at this point in the history
  • Loading branch information
btaylor-sesda authored and dgarciabriseno committed Feb 22, 2022
1 parent cb2168c commit e973e69
Showing 1 changed file with 100 additions and 25 deletions.
125 changes: 100 additions & 25 deletions resources/js/CustomHandling/CustomHandling.js
Original file line number Diff line number Diff line change
@@ -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=<?php echo (rand(9999,9999999)); ?>", 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=<?php echo (rand(9999,9999999)); ?>", function(pspdata){



var pspencnum=0;

// loop through each encounter
$.each(pspdata, function(pspvalue, pspkey){
console.log(pspkey, pspvalue);


pspencnum++;

Expand All @@ -23,40 +75,63 @@ $(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('<span class="hvenclabels"></span>');
$('.hvenclabels').html('<br>Encounter '+pspencnum);
//document.getElementsByClassName("hover-date-container").innerHTML+= '<br>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('<br>Encounter '+pspencnum);
$('#showjsondata').append('#stereo_a-psp-trajectory-hover-date-'+pspstartenc+' // Encounter '+pspencnum+'<br>');
pspstartenc+=21600000;
}


}

});




}).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





0 comments on commit e973e69

Please sign in to comment.