var url = $("html").attr( "data-site-url" ); var csrf_token = $("html").attr( "data-attr-csrf" ); var custom_base_url = $("html").attr( "data-custom-base-url"); var lastScrollTop = 0; window.onscroll = function () { scsc(); } $('.try_quiz_banner2').owlCarousel({ loop:true, margin:30, items:1, nav:true, dots:false, autoplayHoverPause: true, autoplaySpeed: 800, responsive:{ 0:{ items:1.25, nav:true }, 767:{ items:2, nav:true }, 992:{ items:3, nav:true }, 1200:{ items:3, nav:true } } }); function shareOnTwitter() { var copyText = document.getElementById("reflink"); var url = copyText.value; window.open("https://twitter.com/share?url="+encodeURIComponent(url)); } function copyrefflink() { console.log("first") var copyText = document.getElementById("reflink"); // copyText.select(); // document.execCommand("copy"); navigator.clipboard.writeText(copyText.value); } function checkcorre_wrong(key,id,correct_ans,check,lastid,qid) { var un = key+1; var correctans = $('#correctans_'+correct_ans).val(); var an = $('#ans_'+correct_ans+'_'+id).val(); var wr = $('#wron_'+correct_ans+'_'+id).val(); $('.eachquestion_'+un).removeClass('pointer_none'); set_wron_corr_question(id,qid,check,an,2,key,lastid); if(correctans == check) { $('.corre_'+check+'_'+id).addClass('rightans'); $('.chckgreen_'+check+'_'+id).addClass('chckoptnsgreen'); $('.chckgreen_'+check+'_'+id).addClass('fa fa-check-circle'); $('.chckgreen_'+check+'_'+id).removeClass('hide'); $('.right_ans_text_'+id).html("

"+ an+"

"); $('.msgsco_'+id).show(); total_rights = $("#total_ans_input").val(); $("#total_ans_input").val(parseInt(total_rights)+1); } else { $('.corre_'+correct_ans+'_'+id).addClass('rightans'); $('.corre_'+check+'_'+id).addClass('wrongans'); $('.chckred_'+check+'_'+id).addClass('chckoptnsred'); $('.chckred_'+check+'_'+id).addClass('fa fa-times-circle'); $('.chckred_'+check+'_'+id).removeClass('hide'); $('.chckgreen_'+correct_ans+'_'+id).addClass('chckoptnsgreen'); $('.chckgreen_'+correct_ans+'_'+id).addClass('fa fa-check-circle'); $('.chckgreen_'+correct_ans+'_'+id).removeClass('hide'); $('.wronng_ans_text_'+id).html("

"+ an+"

"); $('.msgs_'+id).show(); } $('.eachquestion_'+key).addClass('pointer_none'); if(id == lastid){ $('#quiz_result_button').removeClass('pointer_none'); complete_quiz(qid); } } function checkcorre(sta_id,key,id,lastid,qu_id,new_old=0){ var un = key+1; $('.eachquestion_'+un).removeClass('pointer_none'); if(sta_id == 1){ $('.check_1_'+id).removeClass('hide'); $('.check_2_'+id).addClass('hide'); $('.check_3_'+id).addClass('hide'); $('.check_4_'+id).addClass('hide'); $('.corre_1_'+id).addClass('optnslcted'); $('.corre_2_'+id).removeClass( 'optnslcted'); $('.corre_3_'+id).removeClass( 'optnslcted'); $('.corre_4_'+id).removeClass( 'optnslcted'); set_sessquestion(id,qu_id,1,1,key,lastid); }if(sta_id == 2){ $('.check_1_'+id).addClass('hide'); $('.check_2_'+id).removeClass('hide'); $('.check_3_'+id).addClass('hide'); $('.check_4_'+id).addClass('hide'); $('.corre_1_'+id).removeClass('optnslcted'); $('.corre_2_'+id).addClass( 'optnslcted'); $('.corre_3_'+id).removeClass( 'optnslcted'); $('.corre_4_'+id).removeClass( 'optnslcted'); set_sessquestion(id,qu_id,2,1,key,lastid); }if(sta_id == 3){ $('.check_1_'+id).addClass('hide'); $('.check_2_'+id).addClass('hide'); $('.check_3_'+id).removeClass('hide'); $('.check_4_'+id).addClass('hide'); $('.corre_1_'+id).removeClass('optnslcted'); $('.corre_2_'+id).removeClass( 'optnslcted'); $('.corre_3_'+id).addClass( 'optnslcted'); $('.corre_4_'+id).removeClass( 'optnslcted'); set_sessquestion(id,qu_id,3,1,key,lastid); }if(sta_id == 4){ $('.check_1_'+id).addClass('hide'); $('.check_2_'+id).addClass('hide'); $('.check_3_'+id).addClass('hide'); $('.check_4_'+id).removeClass('hide'); $('.corre_1_'+id).removeClass('optnslcted'); $('.corre_2_'+id).removeClass( 'optnslcted'); $('.corre_3_'+id).removeClass( 'optnslcted'); $('.corre_4_'+id).addClass( 'optnslcted'); set_sessquestion(id,qu_id,4,1,key,lastid); } $('.eachquestion_'+key).addClass('pointer_none'); if(id == lastid){ $('#quiz_result_button').removeClass('pointer_none'); // complete_quiz(qu_id); } // if($("#question_page").val() && $("#question_page").val() == 'style3'){ // $("#cont_quiz_questions_butt").removeAttr('disabled'); // } // $('.buttcf_1').show(); // $('.webbscroll').hide(); // $('.buttmf_'+lastid).show(); // $('.buttcf_1').show(); // if(id == lastid){ // if(new_old == 1) // $(".trivia_result_btn").css("display", "block"); // $('.see').removeClass('hide'); // $('.see').show(); // //$('a.see').attr('href', '#startquiz_'+un); // } else{ // $('a.oneper').attr('href', '#startquiz_'+un); // $('a.topscrl').attr('href', '#startquiz_'+un); // } // if(key != 0){ // $('a.mobhr').attr('href', '#startquiz_'+key); // } // if(id == lastid) // { // complete_quiz(qu_id); // } } function set_wron_corr_question(id,qu_id,checkid,an,topref,key,lastid) { var chech = 'check_'+checkid+'_'+id; $.ajax({ type: "POST", url: url+"/set_wron_corr_question", data:{_token:csrf_token,id:id,qu_id:qu_id,checkid:checkid,an:an,topref:topref,key:key,lastid:lastid}, success:function(response){ } }); } function set_sessquestion(id,qu_id,checkid,topref,key,lastid) { var chech = 'check_'+checkid+'_'+id; $.ajax({ type: "POST", url: url+"/set_sessquestion", data:{_token:csrf_token,id:id,qu_id:qu_id,checkid:checkid,topref:topref,key:key,lastid:lastid}, success:function(response){ } }); } function toprefresh(id,qid) { $.ajax({ type: "POST", url: url+"/unsetsession", data:{_token:csrf_token,id:id,qid:qid}, success:function(response){ location.reload(true); } }); } function complete_quiz(quizid) { $.ajax({ type: "POST", url: url+"/completequiz", data:{_token:csrf_token,quizid:quizid}, success:function(response){ } }); total_rights = $("#total_ans_input").val(); total_input = $("#total_input").val(); percent = (total_rights/total_input*100).toFixed(2); $.ajax({ type: "POST", url: url+"/quizresult", data:{_token:csrf_token,qid:quizid,score:percent}, success:function(response){ } }); } function show_result(){ $('#quiz_result_button').addClass('hide'); total_rights = $("#total_ans_input").val(); total_input = $("#total_input").val(); percent = (total_rights/total_input*100).toFixed(2); $("#result_score_per_text").html("Your score: "+percent); $("#result_score_text").html("You got "+total_rights+" correct out of "+total_input+"!"); $('#quiz_result_box').removeClass('hide'); $('html, body').animate({ scrollTop: $("#quiz_result_box").offset().top-100 }, 1000); } function scsc(){ var Cheight = document.querySelector('.sidequiz').offsetHeight; const CTop = document.querySelector('.sidequiz').offsetTop; Cheight = parseFloat(Cheight)+CTop; var scroll = $(window).scrollTop(); if (scroll >= Cheight) { $(".rigtads").addClass("newfixedclass"); } var scroll = $(window).scrollTop(); if(scroll <= Cheight) { $(".rigtads").removeClass("newfixedclass"); } }