Skip to content

Instantly share code, notes, and snippets.

@z3cka
Created March 21, 2014 04:44
Show Gist options
  • Save z3cka/9679658 to your computer and use it in GitHub Desktop.
Save z3cka/9679658 to your computer and use it in GitHub Desktop.
maybe the easiest test I ever took... :-P via http://www.cdc.gov/concussion/HeadsUp/Training/index.html
var currentLesson;
var currentSlide;
var highestLesson;
var thisDelay;
var isPaused = true;
var l2audioIsPlaying = false;
var quizKey = {};
var questionOrVideo = {};
var didExplore = 0;
var cl = getUrlVars()["cl"];
var cs = getUrlVars()["cs"];
var correctCount = 0;
var maxPlayPosition = 0.0;
var seeking = false;
var skipToQuestion = false;
var certName = 'No Name Entered';
/* v1.7 12-10-2013 */
$(document).ready(function(){
$(window).bind('beforeunload', function(eventObject) {
var returnValue = undefined;
returnValue = "Are you sure you want to close? By closing this page, you will not have access to your completion certificate again unless you retake the training. Please ensure your certificate has printed off properly or you have saved to your desktop before closing. If your Flash plugin has crashed, try clicking the button corresponding to your current lesson in the left menu to refresh the player and avoid losing your progress.";
eventObject.returnValue = returnValue;
return returnValue;
});
currentLesson = (cl) ? cl : 1;
currentSlide = (cs) ? cs : 1;
highestLesson = 1;
$(".fancybox").fancybox({
height:650,
width:960,
autoScale:true,
scrolling:false
});
$(".fancybox_wallet").fancybox({
height:400,
width:500,
autoScale:true,
scrolling:false
});
$("#warning_container").bind('click',function(event) {
$("#warning_container").css('display','none');
$("#warning_container").unbind('click');
});
//prevent submittion of name form via enter key
$('#my_name').keypress(function(e){
if ( e.which == 13 ) return false;
//or...
if ( e.which == 13 ) e.preventDefault();
});
/* question type / right answer / right answer description / wrong answer description / user answer correct t/f */
/* for type mc_custom, c4 custom popups */
quizKey['lesson1slide2'] = ["tf","A", "Correct!", "Correct Answer: True. This sudden movement can literally cause the brain to bounce around or twist in the skull stretching and damaging the brain cells and creating chemical changes in the brain.", 0];
quizKey['lesson1slide3'] = ["mc","D", "Correct! All of the statements are true.", "Almost! The correct answer is D: All of the statements are true.", 0];
quizKey['lesson1slide4'] = ["mc","D", "Correct! All of these are important reasons to properly recognize and respond to a suspected concussion.", "Almost! The correct answer is D: All of the above. All of the statements are true and are reason to recognize and respond properly to a suspected concussion.", 0];
/* custom_a = popup, custom_b = checkbox */
quizKey['lesson2slide2'] = ["interactive"];
quizKey['lesson2slide4'] = ["mc_custom_a","Correct! Any forceful bump, blow, or jolt to the head or body that results in rapid movement of the head can cause a concussion. And as we learned in Lesson 1, this can be a collision among players or with an object like a goalpost, the ground, or another obstacle.", "Although it is important to watch for signs of dehydration among your players, this has no direct effect on causing a concussion. Please try again.", "Correct! Any concussion signs or symptoms, changes in behavior, thinking, or physical functioning can be a sign of a concussion.", "Although it is important for athletes to eat a healthy and balanced diet, this has no direct effect on causing a concussion. Please try again.", 0];
quizKey['lesson2slide5'] = ["mc_custom_b", "Z", "Correct! In fact, all of these are either signs that may be observed by coaching staff or symptoms reported by athletes."];
quizKey['lesson2slide6'] = ["mc_custom_b", "Z", "Correct! In fact, all of these are either signs that may be observed by coaching staff or symptoms reported by athletes."];
quizKey['lesson4slide2'] = ["mc","B", "Correct! Light aerobic exercise, but only to increase an athlete's heart rate is the first step in getting them back into the game. But during each step of this process, be sure to keep your eyes open for returning symptoms. If the symptoms come back, or he or she exhibits new symptoms, stop the activity and talk to the health care professional. ", "We want to gradually introduce the athlete back into play safely and giving the brain time to completely heal. Therefore, the athlete should start with light aerobic exercise-but only to increase the athlete's heart rate. Correct answer B.", 0];
quizKey['lesson4slide3'] = ["mc","C", "Correct! In fact here is the complete list in the correct order: 1. Light aerobic exercise, but only to increase an athlete's heart rate-meaning 5-10 minutes on an exercise bike, walking, or light jogging. No weight lifting, jumping, or hard running. 2. Activities that increase the athlete's heart rate and incorporate limited body or head movement-including moderate jogging, brief running, moderate-intensity stationary biking, and moderate-intensity weightlifting. 3. Bump it up a notch to heavy, non-contact physical activity-including sprinting/running, high-intensity stationary biking, regular weightlifting routine and non-contact sports-specific drills. 4. Reintegrate the athlete in practice sessions, even full contact in controlled practice if appropriate to the sport. 5. Put the athlete back into play.", "It is important to introduce the athlete back into play using a set of careful steps to avoid a repetitive or further injury. Please review the list in their correct order below: 1. Light aerobic exercise, but only to increase an athlete's heart rate-meaning 5-10 minutes on an exercise bike, walking, or light jogging. No weight lifting, jumping, or hard running. 2. Activities that increase the athlete's heart rate and incorporate limited body or head movemenincluding moderate jogging, brief running, moderate-intensity stationary biking, and moderate-intensity weightlifting. 3. Bump it up a notch to heavy, non-contact physical activity-including sprinting/running, high-intensity stationary biking, regular weightlifting routine and non contact sport specific drills. 4. Reintegrate the athlete in practice sessions, even full contact in controlled practice if appropriate to the sport.5. Put the athlete back into play.", 0];
quizKey['lesson4slide4'] = ["tf","A", "Correct! Depending on the severity of the injury and the individual, it can take different amounts of time for different individuals to heal from a concussion. That's why it is so important to stay in contact with a health care professional and keep watch for any continuing concussion signs or symptoms.", "Depending on the severity of the injury and the individual, it can take different amounts of time for different individuals to heal from a concussion. That's why it is so important to stay in contact with a health care professional and keep watch for any continuing concussion signs or symptoms. ", 0];
quizKey['lesson6slide1'] = ["mc","A", "C", "W", 0];
quizKey['lesson6slide2'] = ["mc","C", "C", "W", 0];
quizKey['lesson6slide3'] = ["mc","B", "C", "W", 0];
quizKey['lesson6slide4'] = ["mc","A", "C", "W", 0];
quizKey['lesson6slide5'] = ["mc","C", "C", "W", 0];
quizKey['lesson6slide6'] = ["mc","A", "C", "W", 0];
quizKey['lesson6slide7'] = ["mc","C", "C", "W", 0];
quizKey['lesson6slide8'] = ["mc","B", "C", "W", 0];
quizKey['lesson6slide9'] = ["mc","C", "C", "W", 0];
quizKey['lesson6slide10'] = ["mc","B", "C", "W", 0];
quizKey['lesson6slide11'] = ["mc","C", "C", "W", 0];
quizKey['lesson6slide12'] = ["mc","holder", "holder", "holder", 0];
quizKey['lesson6slide13'] = ["mc","holder", "holder", "holder", 0];
$("#video_container").css("display","none");
$("#resources_menu").css("display","none");
var tl = new TimelineLite();
//append a to() tween
//start items
tl.to($("#main_menu"), 0, {css:{left:"-500px"}});
tl.to($("#whistle"), 0, {css:{alpha:0}});
tl.to($("#participating_orginizations_pop"), 0, {css:{alpha:0, zIndex:-1}});
tl.to($(".slide"), 0, {css:{alpha:0}});
tl.to($("#player_controls"), 0, {css:{left:"-500px"}});
tl.to($("#participating_orginizations"), 0, {css:{right:"-500px"}});
tl.to($("#participating_orginizations_pop"), 0, {css:{alpha:0, scaleY:0.1}});
tl.to($("#heads_up_logo"), 0, {css:{alpha:0, scale:0.1}});
//tl.to($("#resources_menu"), 0, {css:{alpha:0, scaleX:0.1, left:"-500px"}});
tl.to($("#quiz_question_result_box"), 0, {css:{alpha:0, zIndex:0}});
tl.to($("#main_menu"), .7, {css:{left:"-30px"}, ease:Back.easeOut});
tl.to($("#participating_orginizations"), .7, {css:{right:"250px"}, ease:Back.easeOut});
tl.to($("#player_controls"), .7, {css:{left:"158px"}, ease:Back.easeOut}, -.7);
/* for if test var skip in url */
if(!cl) {
tl.to($("#video_container"), .7, {css:{alpha:1, zIndex:100}, ease:Power3.easeOut});
}
tl.to($("#whistle"), .7, {css:{alpha:1, zIndex:200}, ease:Power3.easeOut}, -.7);
tl.to($("#heads_up_logo"), .5, {css:{scale:1.2, alpha:1}, ease:Power3.easeOut});
tl.to($("#heads_up_logo"), .5, {css:{scale:1}, ease:Power3.easeOut,onComplete:function(){
$("#name_input_link").fancybox({closeClick: false,closeBtn: false, scrolling:false, afterShow:function() {$('#my_name').focus();}, helpers: {overlay : {closeClick: false}}}).trigger('click');
}});
tl.play();
$("#main_menu a#m6_click").bind('click',function(event) {
event.preventDefault();
showResourcesMenu();
});
$("a#participating_orginizations").bind('click',function(event) {
event.preventDefault();
showParticipatingOrgs();
});
$("a#play_btn").bind('click',function(event) {
event.preventDefault();
playPauseVideo();
});
$("a#mute_btn").bind('click',function(event) {
event.preventDefault();
muteVideo();
});
$("a#cc_btn").bind('click',function(event) {
event.preventDefault();
ccVideo();
});
//resetBackNextBtns();
/* skip to questions if test var in url */
if(cl) {
showBackNextBtns(); //loadQuestion(currentLesson,currentSlide);
}
appDispatch(true);
/* if we have values pairs in the url to skip around */
if(cl) {
$("#m1").toggleClass('disabled');
$("#m1").toggleClass('active');
changeLessonIndicator(true);
}
});
function loadVideo(file, image, cc) {
/* turn on player buttons */
toggleDisablePlayerButtons(false);
$("#play_btn").removeClass("off");
$("#video_container").fadeIn("fast");
$("#video_container").css("z-index", "100");
$("#video_container").css("visibility", "visible");
resetBackNextBtns();
jwplayer("mediaspace").setup({
playlist: [{
file: file,
image: 'video_assets/' + image + '',
captions: [{
file: "video_assets/"+ cc + "",
label: "Closed Captions"
}]
}],
analytics: {
cookies: false
},
primary: 'flash',
skin:'jwplayer/jwplayer-skins-premium/six.xml',
height: '364',
width: '647'
});
jwplayer("mediaspace").onIdle(function() {
$("#video_container").css("display","none");
if(currentLesson !=3) {
showBackNextBtns();
toggleDisablePlayerButtons(true);
}
appDispatch(true);
if($("#play_btn").hasClass("off")) {
$("#play_btn").removeClass("off");
}
isPaused = true;
maxPlayPosition = 0.0;
seeking = false;
});
jwplayer("mediaspace").onPlay(function() {
if(!$("#play_btn").hasClass("off")) {
$("#play_btn").addClass("off");
}
if(jwplayer("mediaspace").getMute()) {
$("#mute_btn").addClass("off");
} else {
$("#mute_btn").removeClass("off");
}
});
jwplayer("mediaspace").onPause(function() {
if($("#play_btn").hasClass("off")) {
$("#play_btn").removeClass("off");
}
});
jwplayer("mediaspace").onMute(function() {
if(jwplayer("mediaspace").getMute()) {
$("#mute_btn").addClass("off");
} else {
$("#mute_btn").removeClass("off");
}
});
jwplayer("mediaspace").onSeek(function (event) {
if (!seeking) {
if (event.offset > maxPlayPosition) {
seeking = true;
setTimeout(function () { jwplayer("mediaspace").seek(maxPlayPosition); }, 100);
}
} else {
seeking = false;
}
});
jwplayer("mediaspace").onTime(function(event) {
if (!seeking) {
maxPlayPosition = Math.max(event.position, maxPlayPosition);
}
});
}
function playPauseVideo() {
jwplayer('mediaspace').play();
isPaused = (isPaused) ? false : true;
}
function pauseVideo() {
jwplayer('mediaspace').pause(true);
isPaused = true;
}
function muteVideo() {
jwplayer('mediaspace').setMute();
}
function ccVideo() {
$('a#cc_btn').toggleClass("off");
jwplayer('mediaspace').getPlugin("captions");
}
function resetBackNextBtns() {
var tl = new TimelineLite();
tl.to($("#down_arrow"), 0, {css:{alpha:0}});
tl.to($("#down_arrow"), 0, {css:{top:"100px"}});
tl.to($("#angle_endcap"), 0, {css:{alpha:0}});
tl.to($("#angle_endcap"), 0, {css:{left:"200px"}});
tl.to($("#back_btn"), 0, {css:{alpha:0}});
tl.to($("#back_btn"), 0, {css:{left:"200px"}});
tl.to($("#next_btn"), 0, {css:{alpha:0}});
tl.to($("#next_btn"), 0, {css:{left:"200px"}});
tl.play();
$("#back_btn").attr("class", "disabled");
$("#next_btn").attr("class", "disabled");
$('a.disabled').click(function() { return false; });
}
function showResourcesMenu() {
jwplayer('mediaspace').pause(true);
toggleDisablePlayerButtons(true);
$('#main_menu a#m6_click').unbind('click');
$("#training").css({ opacity: 0 });
$("#training").css("visibility", "hidden");
$("#training").css("z-index", "1");
//hide video container
$("#video_container").css("visibility", "hidden");
$("#video_container").css("z-index", "1");
//show resources
//hide main menu
$("#main_menu").fadeOut();
//show resources menu
$("#resources_menu").delay(500).fadeIn('slow', function() {
$("#resources_menu a#rm1").bind('click', function(event) {
showMainMenu();
});
$("#resources").fadeIn();
$("#resources").css("z-index", "100");
$('.resource_center').css('display','block');
$('.resource_center').css('opacity','0');
loadResource('downloadable_tools', 'rm2');
$("#resources_menu a.rm_btn").bind('click', function(event) {
var r = $("#"+ event.target.id + "").attr("data-resource");
loadResource(r, event.target.id);
});
});
}
function showMainMenu() {
toggleDisablePlayerButtons(false);
if(!$('#play_btn').hasClass("enabled")) {
$('#play_btn').addClass('enabled');
}
$('#resources_menu a#rm1').unbind('click');
//hide resources container
$("#resources").fadeOut();
$("#resources").css("z-index", "1");
$(".resource_center").css("display","none");
//hide resources menu
$("#resources_menu").fadeOut();
//show main menu
$("#main_menu").fadeIn('slow', function() {
$("#main_menu a#m6_click").bind('click', function(event) {
showResourcesMenu();
});
//$("#training").fadeIn();
var thisSlide = currentSlide-1;
var slideType = $("#l"+currentLesson+"s"+ thisSlide +"").attr("data-type");
if(slideType == "video"){
$("#video_container").css('visibility','visible');
//$("#video_container").fadeIn();
$("#video_container").css("z-index", "100");
$("#training").css("visibility", "visible");
$("#training").css("z-index", "100");
$("#training").css({ opacity: 1 });
} else {
$("#training").css("visibility", "visible");
$("#training").css("z-index", "100");
$("#training").css({ opacity: 1 });
}
});
}
function loadResource(r, btn) {
$("a.rm_btn").removeClass("active");
var tl = new TimelineLite();
tl.to($(".resource_center"), 0, {css:{alpha:0, zIndex:1}, ease:Power3.easeOut, onComplete: function() {$("a#" +btn + "").toggleClass("active");}});
tl.to($("#"+r+""), .5, {css:{alpha:1, zIndex:300}, ease:Power3.easeOut});
tl.play();
}
function loadQuestion(lesson, slide) {
/*zxcv*/
/* if interactive section lesson 2, play audio */
if(currentLesson == '2' && currentSlide == '2') {
playAudio();
}
/* skip to result if at end */
if(lesson == 6 && slide == 12) {
$("#next_btn").addClass("disabled");
$("#next_btn").unbind("click");
$("#back_btn").addClass("disabled");
$("#back_btn").unbind("click");
resetBackNextBtns();
$(".slide").css("z-index","1");
$(".slide").css("visibility","hidden");
$("#l"+lesson+"s"+slide+" a.answer_btn").removeClass("selected");
$("#l"+lesson+"s"+slide+"").css("z-index",20);
$("#l"+lesson+"s"+slide+"").css("visibility","visible");
$("#l"+lesson+"s"+slide+" a.answer_btn").addClass("allowhover");
$("#l"+lesson+"s"+slide+" a.submit_btn").addClass("allowhover");
var tl2 = new TimelineLite();
tl2.to($("#down_arrow"), 0, {css:{alpha:0}});
tl2.to($("#down_arrow"), 0, {css:{top:"100px"}});
tl2.play();
$("#l"+lesson+"s"+slide+"").fadeTo("fast", 1);
$("#video_container").css("display","none");
loadQuizResults();
} else
{
/* tracking var for custom_a */
var done = 0;
$("#next_btn").addClass("disabled");
$("#next_btn").unbind("click");
$("#back_btn").addClass("disabled");
$("#back_btn").unbind("click");
$(".slide").css("z-index","1");
$(".slide").css("visibility","hidden");
$("#l"+lesson+"s"+slide+" a.answer_btn").removeClass("selected");
$("#l"+lesson+"s"+slide+" a.answer_btn").unbind('click');
$("#l"+lesson+"s"+slide+"").css("z-index","20");
$("#l"+lesson+"s"+slide+"").css("visibility","visible");
var questionType = quizKey["lesson" + lesson +"slide" + slide][0];
if(questionType == 'mc' || questionType == 'tf') {
$("#l"+lesson+"s"+slide+" a.answer_btn").bind('click', function(event) {
event.preventDefault();
$("#l"+lesson+"s"+slide+" .answer_btn").removeClass("selected");
$("#l"+lesson+"s"+slide+" #"+event.target.id+"").toggleClass("selected");
$("a.submit_btn").unbind('click');
$("#l"+lesson+"s"+slide+" a.submit_btn").bind('click', function(event) {
event.preventDefault();
$("#l"+lesson+"s"+slide+" a.submit_btn").unbind('click');
checkAnswer(lesson, slide);
});
});
}
/* questions below do not have traditaionl answers to check so we skip that function */
else if (questionType == 'mc_custom_a') {
$("#l"+lesson+"s"+slide+" a.answer_btn").bind('click', function(event) {
event.preventDefault();
var answer = $(this).attr("data-value");
$(".contentbox.cb_custom_a").css('display', 'block');
var key;
if(answer == 'A') { key = 1; done++;} else
if(answer == 'B') { key = 2; } else
if(answer == 'C') { key = 3; done++;} else
if(answer == 'D') { key = 4; }
$(".cb_custom_a_answer p").text("" +quizKey["lesson" + lesson +"slide" + slide][key]+"");
if(done == 1) {
activateNextBtn();
done=0;
}
$("#l"+lesson+"s"+slide+" #"+event.target.id+"").toggleClass("selected");
});
} else if (questionType == 'mc_custom_b') {
$("#l"+lesson+"s"+slide+" a.submit_btn").css('display','none');
$("#l"+lesson+"s"+slide+" a.answer_btn.check_btn").bind('click', function(event) {
event.preventDefault();
var alreadySelected = $("#l"+lesson+"s"+slide+" #"+event.target.id+"").hasClass('selected');
$("#l"+lesson+"s"+slide+" #"+event.target.id+"").toggleClass("selected");
if(!alreadySelected) {
done++;
} else {
done--;
}
if(done == 3 && slide == 6) {
$("#l"+lesson+"s"+slide+" a.submit_btn").css('display','block');
$("#l"+lesson+"s"+slide+" a.submit_btn").bind('click', function(event) {
event.preventDefault();
checkAnswer(lesson, slide);
});
done=0;
} else if (done == 5 && slide == 5){
$("#l"+lesson+"s"+slide+" a.submit_btn").css('display','block');
$("#l"+lesson+"s"+slide+" a.submit_btn").bind('click', function(event) {
event.preventDefault();
checkAnswer(lesson, slide);
});
done=0;
}
});
} else if (questionType== 'interactive') {
/* do nothing */
setTimeout(function() {activateNextBtn(); }, 18000);
} else {
//do nothing
}
$("#l"+lesson+"s"+slide+" a.answer_btn").addClass("allowhover");
$("#l"+lesson+"s"+slide+" a.submit_btn").addClass("allowhover");
var tl2 = new TimelineLite();
tl2.to($("#down_arrow"), 0, {css:{alpha:0}});
tl2.to($("#down_arrow"), 0, {css:{top:"100px"}});
if($("#l"+lesson+"s"+slide+"").length != 0) {
tl2.to($("#l"+lesson+"s"+slide+""), 1, {css:{alpha:1}, ease:Power3.easeOut});
}
tl2.play();
activateBackBtn();
$("#video_container").css("display", "none");
}
}
function checkAnswer(lesson,slide) {
$("#quiz_question_result_box").css("z-index",200);
$("#l"+lesson+"s"+slide+" a.answer_btn").removeClass("allowhover");
$("#l"+lesson+"s"+slide+" a.submit_btn").removeClass("allowhover");
$("#l"+lesson+"s"+slide+" a.answer_btn").unbind('click');
$("#l"+lesson+"s"+slide+" a.submit_btn").unbind('click');
var answer = $("#l"+lesson+"s"+slide+" a.answer_btn.selected").attr("data-value");
var correctAnswer = quizKey["lesson" + lesson +"slide" + slide + ""][1];
if(answer == correctAnswer || answer == 'Z') {
$("#quiz_question_result_box p").text("" +quizKey["lesson" + lesson +"slide" + slide][2]+"");
quizKey["lesson" + lesson +"slide" + slide + ""][4] = 1;
} else {
$("#quiz_question_result_box p").text("" +quizKey["lesson" + lesson +"slide" + slide][3]+"");
quizKey["lesson" + lesson +"slide" + slide + ""][4] = 0;
}
if(lesson == 6) {
activateNextBtn();
} else {
var tl = new TimelineLite();
tl.to($("#quiz_question_result_box"), 1, {css:{top:"265px", alpha:1, zIndex:30},onComplete: activateNextBtn});
tl.play();
}
}
function loadQuizResults() {
$('#quizpass').css("display","none");
$('#quizfail').css("display","none");
$("a.submit_btn").unbind('click');
correctCount = 0;
for(var i=1; i <= 11; i++) {
if(quizKey["lesson6slide"+i+""][4] == 1) {
correctCount++;
}
}
/* pass */
if(correctCount >= 9) {
$('#quizpass').css("display","block");
}
/* fail */
else {
$('#quizfail').css("display","block");
correctCount = 0;
}
}
function showBackNextBtns() {
var tl = new TimelineLite();
tl.to($("#angle_endcap"), .3, {css:{alpha:1, left:"273px"}});
tl.to($("#back_btn"), .5, {css:{alpha:1,left:"288px"}, ease:Back.easeOut}, .5);
tl.to($("#next_btn"), .5, {css:{alpha:1,left:"361px"}, ease:Back.easeOut});
tl.play();
}
function activateNextBtn() {
var tl = new TimelineLite();
tl.to($("#down_arrow"), 1, {css:{alpha:1, top:"395", zIndex:500}, ease:Bounce.easeOut});
tl.play();
$("#next_btn").removeClass("disabled");
$("#next_btn").bind('click', function(event) {
event.preventDefault();
appDispatch(true);
clearResult();
if(l2audioIsPlaying == true) {
/* sound.pause(); */
}
});
}
function activateBackBtn() {
if(currentLesson == 1 && currentSlide == 1) {
$("#back_btn").addClass("disabled");
$("#back_btn").unbind('click');
} else {
$("#back_btn").removeClass("disabled");
$("#back_btn").bind('click', function(event) {
event.preventDefault();
appDispatch(false);
clearResult();
});
}
}
function clearResult() {
var tl = new TimelineLite();
tl.to($("#quiz_question_result_box"), 1, {css:{top:"100px", alpha:0, zIndex:0}});
tl.to($(".slide"), 0, {css:{alpha:0}});
tl.play();
}
function appDispatch(dir) {
var thisLessonQuestionCount;
var thisSlideType;
/* forward */
if(dir) {
thisLessonQuestionCount = $("div[data-lesson='lesson" + currentLesson + "']").size();
thisSlideType = $("#l"+currentLesson+"s"+currentSlide+"").data('type');
if(currentSlide <= thisLessonQuestionCount) {
/* video or question? */
if(thisSlideType == 'video') {
var url = $("#l"+currentLesson+"s"+currentSlide+"").data('url');
var img = $("#l"+currentLesson+"s"+currentSlide+"").data('img');
var cc = $("#l"+currentLesson+"s"+currentSlide+"").data('cc');
loadVideo(url, img, cc);
} else {
loadQuestion(currentLesson, currentSlide);
}
currentSlide++;
} else if(currentSlide > thisLessonQuestionCount) {
/* next lesson */
currentSlide=1;
currentLesson= currentLesson +1;
changeLessonIndicator(true);
var thisSlideTypeNew = $("#l"+currentLesson+"s"+currentSlide+"").data('type');
if(thisSlideTypeNew == 'video') {
var url = $("#l"+currentLesson+"s"+currentSlide+"").data('url');
var img = $("#l"+currentLesson+"s"+currentSlide+"").data('img');
var cc = $("#l"+currentLesson+"s"+currentSlide+"").data('cc');
loadVideo(url, img, cc);
} else {
loadQuestion(currentLesson, currentSlide);
}
currentSlide++;
}
} else /* backward */ {
var justGoBack = (currentLesson != 1 && currentSlide == 1) ? false : true;
/* go back a lesson */
if(!justGoBack){
prevLesson = currentLesson-1;
var lastLessonSlideCount = $("div[data-lesson='lesson" + prevLesson + "']").size();
currentLesson = prevLesson;
currentSlide = lastLessonSlideCount;
/* video or question? */
if(thisSlideType == 'video') {
var url = $("#l"+currentLesson+"s"+currentSlide+"").data('url');
var img = $("#l"+currentLesson+"s"+currentSlide+"").data('img');
var cc = $("#l"+currentLesson+"s"+currentSlide+"").data('cc');
loadVideo(url, img, cc);
} else {
loadQuestion(prevLesson, lastLessonSlideCount);
}
changeLessonIndicator(false);
} /* go back a slide */ else if (justGoBack) {
prevSlide = currentSlide-2;
currentSlide = prevSlide;
/* video or question? */
var thisSlideTypeNew = $("#l"+currentLesson+"s"+currentSlide+"").data('type');
if(thisSlideTypeNew == 'video') {
var url = $("#l"+currentLesson+"s"+currentSlide+"").data('url');
var img = $("#l"+currentLesson+"s"+currentSlide+"").data('img');
var cc = $("#l"+currentLesson+"s"+currentSlide+"").data('cc');
loadVideo(url, img, cc);
} else {
loadQuestion(currentLesson, prevSlide);
}
currentSlide++;
}
}
/* highestLesson helps us disabled or enable less nav buttons */
if(currentLesson > highestLesson) {
highestLesson = currentLesson;
}
}
function changeLessonIndicator(fwd) {
var thisIsDisabled = $('#m' +currentLesson+"").hasClass('disabled');
var prevLesson = (fwd == true) ? currentLesson-1 : currentLesson+1;
if(thisIsDisabled) {
$("#m" +currentLesson+"").toggleClass('disabled');
}
$("#m" +currentLesson+"").toggleClass('active');
$("#m" +prevLesson+"").removeClass('active');
$("#m" +prevLesson+"").addClass('enabled');
}
function showCB(id) {
$("#cb" +id+"").css('display', 'block');
didExplore += parseInt(id);
}
function closeCB(id) {
$("#cb" +id+"").css('display', 'none');
didExplore += parseInt(id);
if(id != 3){
//setTimeout(function() {activateNextBtn();}, 10000)
if(didExplore >= 6) {
//activateNextBtn();
}
}
}
function goToLesson(lessonNum) {
if(lessonNum > highestLesson) {
return false;
} else {
$('#main_menu').find("a.active").removeClass('active').addClass('enabled');
currentLesson = lessonNum;
currentSlide = 1;
changeLessonIndicator(true);
appDispatch(true);
}
}
function retakeTest() {
currentLesson = 6;
currentSlide = 1;
showBackNextBtns();
appDispatch(true);
}
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function showParticipatingOrgs() {
$('a#participating_orginizations').unbind('click');
var tl = new TimelineLite();
tl.to($("#participating_orginizations_pop"), 1, {css:{alpha:1, zIndex:"1000", scaleY:1}, ease:Power3.easeOut, onComplete:function() {
$("#participating_orginizations_pop").bind('click', function(event) {
closeParticipatingOrgs();
});
}}, -.5);
tl.play();
}
function closeParticipatingOrgs() {
$("a#participating_orginizations").bind('click',function(event) {
event.preventDefault();
showParticipatingOrgs();
});
var tl = new TimelineLite();
tl.to($("#participating_orginizations_pop"), 1, {css:{alpha:0, zIndex:"-1", scaleY:0.1}, ease:Power3.easeOut, onComplete:function() {
$("#participating_orginizations_pop").bind('click', function(event) {
closeParticipatingOrgs();
});
}}, -.5);
tl.play();
}
function toggleDisablePlayerButtons(disable) {
/* true = disabled */
if(disable) {
$("#play_btn").removeClass("enabled");
$("#mute_btn").removeClass("enabled");
$("#play_btn").addClass("disabled");
$("#mute_btn").addClass("disabled");
} else {
$("#play_btn").removeClass("disabled");
$("#mute_btn").removeClass("disabled");
$("#play_btn").addClass("enabled");
$("#mute_btn").addClass("enabled");
}
}
function playAudio() {
l2audioIsPlaying = true;
jwplayer('audioplayer').setup({
file: "video_assets/l2_audio.mp3",
width: "3",
height: "3",
primary: "flash"
});
jwplayer('audioplayer').play();
}
function submitName() {
certName = $('input#my_name').val();
$.fancybox.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment