1
|
!function(){var t;(t=jQuery).fn.shuffleQuiz=function(){var a=this.get(),e=t.map(a,(function(){var e,n=(e=a.length,Math.floor(Math.random()*e)),i=t(a[n]).clone(!0)[0];return a.splice(n,1),i}));return this.each((function(a){t(this).replaceWith(t(e[a]))})),t(e)},jQuery((function(t){t(".jetpack-quiz").each((function(){var a=t(this);a.find("div.jetpack-quiz-answer").shuffleQuiz(),a.find("div[data-correct]").removeAttr("data-correct").data("correct",1),a.find("div.jetpack-quiz-answer:last").addClass("last")})),t("div.jetpack-quiz").on("click","div.jetpack-quiz-answer",(function(){var a,e=t(this),n=e.closest("div.jetpack-quiz");n.data("a8ctraining")&&((new Image).src="//pixel.wp.com/b.gif?v=wpcom-no-pv&x_trainingchaos-"+n.data("username")+"="+n.data("a8ctraining")+"&rand="+Math.random(),n.data("a8ctraining",!1),n.data("trackid",!1)),a=n.data("trackid"),e.data("correct")?(e.addClass("correct"),a&&((new Image).src="//pixel.wp.com/b.gif?v=wpcom-no-pv&x_quiz-"+a+"=correct&rand="+Math.random())):(e.addClass("wrong"),a&&((new Image).src="//pixel.wp.com/b.gif?v=wpcom-no-pv&x_quiz-"+a+"=wrong&rand="+Math.random())),n.data("trackid",!1)}))})),document.querySelectorAll(".jetpack-quiz-wrapper").forEach((function(t){t.childNodes.forEach((function(a,e){a.style.display="none",a.setAttribute("quiz-number",e),a.querySelector(".jetpack-quiz-count").innerHTML=e+1+"/"+t.childElementCount})),t.childNodes[0].style.display="block"})),document.querySelectorAll(".jetpack-quiz-option-button").forEach((function(t){t.addEventListener("click",(function(){var a=t.parentElement.parentElement;a.style.display="none";var e="next"===t.getAttribute("data-quiz-option")?1:-1,n=a.parentElement.childNodes[parseInt(a.getAttribute("quiz-number"))+e];n.style.display="block";var i=n.querySelector(".jetpack-quiz-question");i&&i.focus()}))}))}();
|