Best JavaScript code snippet using wpt
jscripts.js
Source:jscripts.js
...212 $('#txt_srch_forum1').hide();213 $('.clickforum').show();214 $('#cmdPosts').removeAttr('disabled').css({'opacity': '1'});215 },200);216 create_cookie('selected_file1', 0);217 $('#selectedCaption1').empty().html('No file selected');218 setTimeout(function(){219 $(".hide_txtbox").fadeOut('fast');220 221 },300);222 }else{223 224 $('#cmdPosts').removeAttr('disabled').css({'opacity': '1'});225 $(".errs").fadeIn('fast').html(data);226 setTimeout(function(){227 $(".hide_txtbox").fadeOut('fast');228 },800);229 }230 231 },error : function(data){232 $(".errs").fadeIn('fast').html('Error! Network Connection Failed!');233 $('#cmdPosts').removeAttr('disabled').css({'opacity': '1'});234 }235 });236 }else{237 $(".errs").fadeIn('fast').html('Please write a comment or upload an image.');238 }239 }));240 function bringProducts(edit_ids){241 var txtsrch = $('#txt_srch_forum').val();242 var txtcats1 = $('#txtcats1').val();243 var txtmemsid = $('#txtmemsid').val();244 var page = 0;245 var datastring1='page='+page246 +'&txtcats1='+txtcats1247 +'&txtmemsid='+txtmemsid248 +'&txtsrch='+txtsrch;249 $('.srch_captn').show();250 $(".loadersmall").show();251 $(".loaders_").show().html("Loading...<br><img src='"+site_urls+"images/loader.gif'>");252 if($(window).width()<760){253 if(edit_ids!="")254 $("html, body").animate({ scrollTop: 300 }, "fast");255 else256 $("html, body").animate({ scrollTop: 270 }, "fast");257 }else{258 if(edit_ids!="")259 $("html, body").animate({ scrollTop: 200 }, "fast");260 else261 $("html, body").animate({ scrollTop: 200 }, "fast");262 }263 $.ajax({264 type : "POST",265 url : site_urls+"node/getForums",266 data : datastring1,267 cache : false,268 success : function(data){269 $("#ajax_table_forum").empty().append(data);270 $('#load_more_mba').data('val', ($('#load_more_mba').data('val')));271 $(".loaders_").hide();272 },error : function(data){273 $(".loaders_").hide();274 }275 });276 }277 $("#upload_form_centre").on('submit',(function(e) {278 e.preventDefault();279 $(".alert_msg").hide();280 $('#cmd_upload_content').attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});281 $(".alert_msg").hide();282 var txtsch_id = $("#txt_id").val();283 284 $.ajax({285 url : site_urls+"node/upload_centres",286 type: "POST",287 data: new FormData(this),288 contentType: false, 289 cache: false,290 processData:false,291 timeout: 30000, // 30 second timeout292 success: function(data){293 if(data=="createds"){294 $('#cmd_upload_content').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});295 //$('.main_actvs1').html(txttitle);296 if(txtsch_id==""){297 $("#upload_form_centre")[0].reset();298 quill.setText('');299 }300 $('.first_create_form').hide();301 $('.success_form').slideDown('fast');302 setTimeout(function(){303 $(".alert_msg").hide();304 },2500);305 }else{306 $(".alert_msg").show().html('<div class="Errormsg">'+data+'</div>');307 }308 $('#cmd_upload_content').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});309 310 },error : function(data, timeouts){311 if(timeouts==="timeout") {312 alert("Time out, please try again later");313 }else{314 alert('Error! Network Connection Failed!');315 }316 $('#cmd_upload_content').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});317 }318 });319 }));320 $("#upload_form_res").on('submit',(function(e) {321 e.preventDefault();322 $(".alert_msg").hide();323 $('#cmd_upload_content').attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});324 $(".alert_msg").hide();325 var txt_id = $("#txt_id").val();326 if(txt_id!="") var captions = "Update Resource"; else var captions = "Upload Resource";327 328 $.ajax({329 url : site_urls+"node/upload_res",330 type: "POST",331 data: new FormData(this),332 contentType: false, 333 cache: false,334 processData:false,335 dataType: 'json',336 timeout: 30000, // 30 second timeout337 success: function(data){338 //alert(data);339 if(data.msg.trim()=="createds" || data.msg.trim()=="updateds"){340 $('#cmd_upload_content').removeAttr('disabled').css({'color': '#fff'}).html(captions);341 if(txt_id==""){342 $("#upload_form_res")[0].reset();343 quill.setText('');344 }345 $('.first_create_form').hide();346 $('.success_form').slideDown('fast');347 setTimeout(function(){348 $(".alert_msg").hide();349 },2500);350 }else{351 $(".alert_msg").show().html('<div class="Errormsg">'+data.msg+'</div>');352 }353 $('#cmd_upload_content').removeAttr('disabled').css({'color': '#fff'}).html(captions);354 355 },error : function(data, timeouts){356 if(timeouts==="timeout") {357 alert("Time out, please try again later");358 }else{359 alert('Error! Network Connection Failed!');360 }361 $('#cmd_upload_content').removeAttr('disabled').css({'color': '#fff'}).html(captions);362 }363 });364 }));365 $("#upload_form_logo").on('submit',(function(e) {366 e.preventDefault();367 $(".alert_msg").hide();368 $('#cmd_upload_content').attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});369 $(".alert_msg").hide();370 var txt_id = $("#txt_id").val();371 if(txt_id!="") var captions = "Update Logo"; else var captions = "Upload Logo";372 373 $.ajax({374 url : site_urls+"node/upload_logo",375 type: "POST",376 data: new FormData(this),377 contentType: false, 378 cache: false,379 processData:false,380 dataType: 'json',381 timeout: 30000, // 30 second timeout382 success: function(data){383 if(data.msg.trim()=="createds" || data.msg.trim()=="updateds"){384 $('#cmd_upload_content').removeAttr('disabled').css({'color': '#fff'}).html(captions);385 if(txt_id==""){386 $("#upload_form_logo")[0].reset();387 }388 $('.first_create_form').hide();389 $('.success_form').slideDown('fast');390 setTimeout(function(){391 $(".alert_msg").hide();392 },2500);393 }else{394 $(".alert_msg").show().html('<div class="Errormsg">'+data.msg+'</div>');395 }396 $('#cmd_upload_content').removeAttr('disabled').css({'color': '#fff'}).html(captions);397 398 },error : function(data, timeouts){399 if(timeouts==="timeout") {400 alert("Time out, please try again later");401 }else{402 alert('Error! Network Connection Failed!');403 }404 $('#cmd_upload_content').removeAttr('disabled').css({'color': '#fff'}).html(captions);405 }406 });407 }));408 $("#create_quiz_form").on('submit',(function(e) {409 e.preventDefault();410 $(".alert_msg1").hide();411 var txtquizid = $('#txtquizid').val();412 //alert('sss')413 414 $('#cmd_create_quiz').attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});415 $(".alert_msg1").hide();416 417 $.ajax({418 url : site_urls+"node/save_quiz_settings1",419 type: "POST",420 data: new FormData(this),421 contentType: false, 422 cache: false,423 processData: false,424 timeout: 40000, //60 second timeout425 success: function(data){426 if(data=='inserted' || data=='updated2'){427 $('.first_create_game').hide();428 $('.third_create_form').fadeIn('fast');429 430 if(txtquizid=="") $("#create_quiz_form")[0].reset();431 setTimeout(function(){432 $(".alert_msg1").fadeOut('fast');433 },3000);434 }else{435 436 $(".alert_msg1").fadeIn().html(data);437 }438 $('#cmd_create_quiz').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});439 440 },error : function(data, timeouts){441 if(timeouts==="timeout") {442 alert("Time out, please try again later");443 }else{444 alert('Error! Network Connection Failed!');445 }446 447 $('#cmd_create_quiz').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});448 }449 });450 }));451 $("#create_quiz_form1").on('submit',(function(e) {452 e.preventDefault();453 var txt_upload_type = $("#txt_upload_type").val();454 $(".alert_msg1").hide();455 var txtquestions = $("#txtquestions").val();456 var txtquizid = $("#txtquizid").val();457 458 txtquestions = txtquestions.replace('<p><br></p>', '');459 if(txt_upload_type == "type"){ // type the questions460 if(txtquestions == '' ){461 $(".alert_msg1").fadeIn('fast').removeClass('alert-success').addClass('alert-danger').html('<div class="Errormsg">Please type a question!</div>');462 }else{463 464 $('#cmd_submit_quiz').attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});465 $(".alert_msg1").hide();466 467 $.ajax({468 url : site_urls+"node/submit_my_questions",469 type: "POST",470 data: new FormData(this),471 contentType: false, 472 cache: false,473 processData:false,474 timeout: 30000, // 30 second timeout475 success: function(data){476 477 if(data=='inserted'){478 $(".alert_msg1").fadeIn().removeClass('alert-danger').addClass('alert-success').html('<div style="font-size:15px; text-align:center;">Your question has been saved!</div>');479 480 setTimeout(function(){481 $(".alert_msg1").fadeOut('fast');482 },3000);483 setTimeout(function(){484 $("html, body").animate({ scrollTop: 140 }, "fast");485 },1000);486 487 if(txtquizid==""){488 $('#create_quiz_form1 .form-control, #create_quiz_form1 select').val('');489 quill.setText('');490 }491 492 }else{493 494 $(".alert_msg1").fadeIn().html(data);495 }496 $('#cmd_submit_quiz').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});497 498 },error : function(data, timeouts){499 if(timeouts==="timeout") {500 alert("Time out, please try again later");501 }else{502 alert('Error! Network Connection Failed!');503 }504 $('#cmd_submit_quiz').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});505 }506 });507 }508 509 }else{ // just upload the questions510 $('#cmd_submit_quiz').attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});511 $(".alert_msg1").hide();512 513 $.ajax({514 url : site_urls+"node/upload_my_questions",515 type: "POST",516 data: new FormData(this),517 contentType: false, 518 cache: false,519 processData:false,520 timeout: 30000, // 30 second timeout521 success: function(data){522 //alert(data)523 524 if(data=='inserted'){525 //alert('bbb');526 $(".alert_msg1").fadeIn().removeClass('alert-danger').addClass('alert-success').html('<div style="font-size:15px; text-align:center;">Your questions have been saved!</div>');527 528 setTimeout(function(){529 $(".alert_msg1").fadeOut('fast');530 },3000);531 setTimeout(function(){532 $("html, body").animate({ scrollTop: 140 }, "fast");533 },1000);534 $("#uploadFile").val('');535 }else{536 //alert('eee');537 $(".alert_msg1").fadeIn().html(data);538 }539 $('#cmd_submit_quiz').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});540 541 },error : function(data, timeouts){542 if(timeouts==="timeout") {543 alert("Time out, please try again later");544 }else{545 alert('Error! Network Connection Failed!');546 }547 $('#cmd_submit_quiz').removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});548 }549 });550 }551 }));552 553 $('body').on('click', '#cmd_done_add_test', function () {554 window.location = site_urls+"admin/set_test/";555 });556 557 558 $('body').on('click', '#post_content', function () {559 $('.bold_info1').slideUp('fast');560 });561 $('body').on('click', '.close-search', function () {562 $('.bring_search').fadeToggle('fast');563 $('.navs2 .hide_lnks').show();564 });565 $('body').on('click', '#load_more_mba_forum', function () {566 var page = $(this).data('val');567 var txtsrch_test = $('.txtsrch_test').val();568 //var txtparams = $('#txtparams').val();569 var txtmemsid = $('#txtmemsid').val();570 var txtkeywd1 = retrieve_cookie('txtkeywd1');571 if(txtkeywd1=="" || txtkeywd1=="undefined") var txtkeywd1 = "";572 if(txtsrch_test=="")573 var txtsrch_test = retrieve_cookie('cats_f');574 $('#load_more_mba_forum').hide();575 $('#load_more_mba_forum1').show();576 var datastring='page='+page577 //+'&txtparams='+txtparams578 +'&txtkeywd1='+txtkeywd1579 +'&txtmemsid='+txtmemsid580 +'&txtsrch_test='+txtsrch_test;581 $.ajax({582 type : "POST",583 url : site_urls+"node/getForums",584 data : datastring,585 cache : false,586 success : function(data){587 var responseReturn = data.match(/Category/g);588 if(responseReturn != null){589 $("#ajax_table_forum").append(data);590 $('.load_more_bt').data('val', ($('.load_more_bt').data('val')+1));591 $('#load_more_mba_forum').show();592 $('#load_more_mba_forum1').hide();593 }else{594 $('#load_more_mba_forum').hide();595 $('#load_more_mba_forum1').show();596 $('.load_more_bt, .load_more_bma1').html('<font style="color:#999 !important;">No more posts!</font>');597 }598 },error : function(data){599 $('#load_more_mba_forum').show();600 $('#load_more_mba_forum1').hide();601 }602 });603});604 $('body').on('click', '.filters', function (e) {605 e.stopPropagation();606 $('.search_contents').slideToggle(80);607 });608 $('body').on('click', '.search_contents select, .search_contents input', function (e) {609 e.stopPropagation();610 });611 $('body, html').on('click', function (e) {612 e.stopPropagation();613 $('.search_contents').slideUp('fast');614 if($(window).width() < 760) // mobile615 $('.navbar-static-side').slideUp('fast');616 $('#country_list_id').hide();617 $('.show_answer').slideUp('fast');618 $('.edit_div').slideUp('fast');619 $('.edit_div1').slideUp('fast');620 });621 $('body').on('change', '#uploadFile', function () {622 var fls = $("#uploadFile").val();623 var fileExtension = ['xlsx', 'xls'];624 if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {625 alert("Excel formats allowed are : "+fileExtension.join(', '));626 $("#uploadFile").val('');627 return false;628 }629 });630 $('body').on('change', '#txtfile', function () {631 var fls = $("#txtfile").val();632 var fileExtension = ['pdf', 'doc', 'mp4'];633 if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {634 alert("Formats allowed are : "+fileExtension.join(', '));635 $("#txtfile").val('');636 return false;637 }638 });639 $('body').on('change', '#txtfile1', function () {640 var fls = $("#txtfile1").val();641 var fileExtension = ['jpg', 'jpeg', 'png'];642 if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {643 alert("Formats allowed are : "+fileExtension.join(', '));644 $("#txtfile").val('');645 return false;646 }647 });648 649 $('body').on('click', '.search_college', function () {650 $("#txtcollege1").trigger('change');651 });652 $('#load_more_mba').click(function(){653 var page = $(this).data('val');654 var txtsources = $("#txtsources").val();655 656 $('#load_more_mba').hide();657 $('#load_more_mba1').show();658 var datastring='page='+page659 +'&txtsources='+txtsources;660 661 $.ajax({662 type : "POST",663 url : site_urls+"node/getMoreRecords",664 data : datastring,665 cache : false,666 timeout: 30000, // 30 second timeout667 success : function(data){668 var responseReturn = data.match(/Downloads/g);669 //alert(responseReturn);670 if(responseReturn != null){671 $("#ajax_table_bma").append(data);672 $('.load_more_bt').data('val', ($('.load_more_bt').data('val')+1));673 $('#load_more_mba').show();674 $('#load_more_mba1').hide();675 }else{676 $('#load_more_mba').hide();677 $('#load_more_mba1').show();678 $('.load_more_bt, .load_more_bma1').html('<font style="color:#999 !important;">No more records!</font>');679 }680 },error : function(data, timeouts){681 if(timeouts==="timeout") {682 alert("Time out, please try again later");683 }else{684 alert('Error! Network Connection Failed!');685 }686 $('#load_more_mba').show();687 $('#load_more_mba1').hide();688 }689 });690 });691 $(".upload_questions").click(function(){692 $(".alert_msg1").hide();693 $(".write_quest_div").hide();694 $(".uploadQuests").fadeIn('fast');695 $("#txt_upload_type").val('upload');696 });697 $(".type_questions").click(function(){698 $(".alert_msg1").hide();699 $(".uploadQuests").hide();700 $(".write_quest_div").fadeIn('fast');701 $("#txt_upload_type").val('type');702 });703 $('body').on('click', '.cmd_search_res', function () {704 var keywords = $(".txtkeywd").val();705 var locs = $(".txtsrch_state").val();706 707 var datastring='keywords='+keywords708 +'&wholesearch=0'709 +'&locs='+locs;710 $(".loaders").show();711 $.ajax({712 type : "POST",713 url : site_urls+"node/filterCentres",714 data : datastring,715 cache : false,716 timeout: 30000, // 30 second timeout717 success : function(data){718 $(".loaders").hide();719 $(".filterCentres1").html(data);720 $("html, body").animate({scrollTop: $('.scrollhere2').offset().top-120 }, 20);721 },error : function(data, timeouts){722 if(timeouts==="timeout") {723 alert("Time out, please try again later");724 }else{725 alert('Error! Network Connection Failed!');726 }727 $(".loaders").hide();728 }729 });730 });731 $('body').on('click', '.cmd_search_test', function () {732 var keywords = $(".txtkeywd1").val();733 var tests = $(".txtsrch_test").val();734 var txtsources = $("#txtsources").val();735 736 var datastring='keywords='+keywords737 +'&txtsources='+txtsources738 +'&tests='+tests;739 $(".loaders").show();740 $.ajax({741 type : "POST",742 url : site_urls+"node/filterRes",743 data : datastring,744 cache : false,745 timeout: 30000, // 30 second timeout746 success : function(data){747 $("#ajax_table_bma").html(data);748 $("html, body").animate({scrollTop: $('.scrollhere1').offset().top-60 }, 20);749 $(".loaders").hide();750 },error : function(data, timeouts){751 if(timeouts==="timeout") {752 alert("Time out, please try again later");753 }else{754 alert('Error! Network Connection Failed!');755 }756 $(".loaders").hide();757 }758 });759 });760 create_cookie('txtkeywd1', '');761 $('body').on('click', '.cmd_search_forum', function () {762 var vals = $(this).attr('vals');763 var txtkeywd1 = $('.txtkeywd1').val();764 var txtsrch_test = $('.txtsrch_test').val();765 var urls = site_urls+"node/getForums";766 if(txtkeywd1!=""){767 create_cookie('txtkeywd1', txtkeywd1);768 }769 770 $(".loaders_").show().html("Loading...<br><img src='"+site_urls+"images/loader.gif'>");771 772 if($(window).width()<760)773 $("html, body").animate({scrollTop:$('.topics_2').offset().top-40}, "fast");774 else775 $("html, body").animate({scrollTop:$('.topics_2').offset().top-390}, "fast");776 var datastring='txtkeywd1='+txtkeywd1777 +'&txtsrch_test='+txtsrch_test;778 +'&page=0';779 $.ajax({780 type : "POST",781 url : urls,782 data : datastring,783 success : function(data){784 $(".loaders_, .reply_forum").hide();785 $("#ajax_table_forum").html(data).fadeIn('fast');786 },error : function(data){787 }788 });789 });790 791 $('body').on('click', '.close_map', function () {792 var id1 = $(this).attr('id1');793 $(".open_map").fadeOut('fast');794 $(".filterCentres1").fadeIn('slow');795 setTimeout(function(){796 $("html, body").animate({scrollTop: $('.scrollhere'+id1).offset().top-80 }, 20);797 },200);798 });799 $('body').on('click', '.open_map', function () {800 var id1 = $(this).attr('id1');801 $(this).fadeOut('fast');802 $(".filterCentres1").fadeIn('slow');803 setTimeout(function(){804 $("html, body").animate({scrollTop: $('.scrollhere'+id1).offset().top-80 }, 20);805 },200);806 // $(".open_map").fadeOut('fast');807 // $(".filterCentres1").fadeIn('slow');808 // setTimeout(function(){809 // $("html, body").animate({scrollTop: $('.scrollhere'+id1).offset().top-80 }, 20);810 // },200);811 });812 $('body').on('click', '.menu_icn', function (e) {813 e.stopPropagation();814 var ids = $(this).attr("ids");815 $('#edit_div'+ids).slideToggle('fast');816 });817 $('body').on('click', '.menu_icn1', function (e) {818 e.stopPropagation();819 var ids = $(this).attr("ids");820 $('#edit_div1'+ids).slideToggle('fast');821 });822 $('body').on('click', '#editpost', function () {823 var ids = $(this).attr("ids");824 var messages1 = $(this).attr("messages1");825 var files = $(this).attr("files");826 var topics = $(this).attr("topics");827 var counters = $(this).attr("counters");828 create_cookie('counters', counters);829 //alert(topics)830 $('#edit_div'+ids).slideToggle('fast');831 $('#selectedCaption1').html(files);832 $('#edit_ids').val(ids);833 $('#former_file1').val(files);834 $('#post_content').val(messages1);835 $("#txtcats").val(topics);836 $("#cmdPosts").val("Edit Comment");837 838 $("html, body").animate({scrollTop: $('.txtcreate_topic').offset().top-50 }, "fast");839 840 setTimeout(function(){841 $('.clickforum').click();842 },500);843 });844 $('body').on('click', '#delpost', function () {845 var ids = $(this).attr("ids");846 if(confirm("Proceed to delete this post?")){847 $('.forumBox_scroll'+ids).slideUp('fast');848 var datastring='post_id='+ids849 +'&type1=forums';850 $.ajax({851 type : "POST",852 url : site_urls+"node/delete_post",853 data: datastring,854 //cache : false,855 success : function(data){856 },error : function(data){857 }858 });859 return false;860 }861 });862 $('body').on('click', '#delpost2', function (){863 var ids = $(this).attr("ids");864 var ids2 = $(this).attr("ids2");865 $('.forum_rep'+ids2).slideUp('fast');866 867 var txtrep_cnts = $('#txtrep_cnts').val();868 var new_cnt = parseInt(txtrep_cnts)-1;869 $('#txtrep_cnts').val(new_cnt);870 $('.newcount').html(new_cnt);871 var datastring='post_id='+ids872 +'&type1=forum_reply';873 $.ajax({874 type : "POST",875 url : site_urls+"node/delete_post",876 data: datastring,877 success : function(data){878 },error : function(data){879 }880 });881 return false;882 });883 884 $('body').on('mousedown', '#uploadfiles1', function (){885 $("#imgpreview1").html('');886 $('#file4').click();887 });888 $('body').on('mousedown', '#uploadfiles1_rep', function (){889 $("#imgpreview1_rep").html('');890 $('#file4_rep').click();891 });892 create_cookie('selected_file1', 0);893 $('body').on('change', '#file4', function (){894 var myfile = $('#file4').val();895 var extn = myfile.slice(-7);896 897 if(myfile.length > 16){898 var myfile1 = myfile.substring(0,16);899 var combined_one1 = myfile1+'...'+extn;900 }else{901 var combined_one1 = myfile;902 }903 904 if(myfile1 == ''){905 $('#selectedCaption1').html('No file selected');906 create_cookie('selected_file1', 0);907 }else{908 $('#selectedCaption1').html('<b style="color:#996600; font-size:0.9em;">Selected:</b> '+combined_one1);909 create_cookie('selected_file1', 1);910 }911 912 $("#imgpreview1").html('').show();913 //this code below is for the uploading to stay right beside the box914 $("#form2").ajaxForm({915 target: '#imgpreview1'916 }).submit()917 //to bring all the chats from a function918 setTimeout(function(){919 $("#imgpreview1").html('');920 $("#imgpreview1").hide();921 $('#selectedCaption1').empty().html('No file selected');922 },1300);923 });924 $('body').on('change', '#file4_rep', function (){925 var myfile = $('#file4_rep').val();926 var extn = myfile.slice(-7);927 928 if(myfile.length > 16){929 var myfile1 = myfile.substring(0,16);930 var combined_one1 = myfile1+'...'+extn;931 }else{932 var combined_one1 = myfile;933 }934 935 if(myfile1 == ''){936 $('#selectedCaption1_rep').html('No file selected');937 create_cookie('selected_file1', 0);938 }else{939 $('#selectedCaption1_rep').html('<b style="color:#996600; font-size:0.9em;">Selected:</b> '+combined_one1);940 create_cookie('selected_file1', 1);941 }942 943 $("#imgpreview1_rep").html('').show();944 //this code below is for the uploading to stay right beside the box945 $("#form2").ajaxForm({946 target: '#imgpreview1_rep'947 }).submit()948 //to bring all the chats from a function949 setTimeout(function(){950 $("#imgpreview1_rep").html('');951 $("#imgpreview1_rep").hide();952 $('#selectedCaption1_rep').empty().html('No file selected');953 },1300);954 });955 $('body').on('click', '.view_maps', function () {956 var id1 = $(this).attr('id1');957 var addrs = $(this).attr('addrs');958 var centre_name = $(this).attr('centre_name');959 $(".open_map .open_inner_map").html('<img src="'+site_urls+'images/loaderq.gif"></div>');960 961 var datastring='addrs='+addrs962 +'&id1='+id1963 +'¢re_name='+centre_name;964 //alert(datastring)965 $(".filterCentres1").hide();966 $(".open_map").fadeIn('fast').css('display', 'flex');967 $.ajax({968 type : "POST",969 url : site_urls+"node/findMap",970 data : datastring,971 cache : false,972 timeout: 30000, // 30 second timeout973 success : function(data){974 $(".open_map").attr('id1', id1);975 $(".open_map .open_inner_map").html(data);976 //$(".loaders").hide();977 },error : function(data, timeouts){978 if(timeouts==="timeout") {979 alert("Time out, please try again later");980 }981 }982 });983 });984 985 $('body').on('change', '#txtaction', function () {986 var txtaction = $(this).val();987 if(txtaction=="all"){988 window.location = site_urls+"admin/members/";989 }990 });991 $('body').on('change', '#txtaction1', function () {992 var txtaction = $(this).val();993 if(txtaction=="all"){994 window.location = site_urls+"admin/resources/";995 }996 });997 $('body').on('click', '#cmd_back_tofirst', function () {998 $('.success_form').hide();999 $('.first_create_form').fadeIn('fast');1000 });1001 $('body').on('click', '.view_changes', function () {1002 var pages = $(this).attr("pages");1003 window.location = site_urls+"admin/"+pages+"/";1004 });1005 $(".remove_file").click(function(){1006 var files = $(this).attr("files");1007 var folders = $(this).attr("folders");1008 var id2 = $(this).attr("id2");1009 var imgfile = $(this).attr("imgfile");1010 1011 var datastring='files='+files1012 +'&id2='+id21013 +'&folders='+folders;1014 if(confirm("Proceed to delete this?")){1015 $(this).hide();1016 $("#update_imgs1_"+id2).slideUp('fast');1017 $.ajax({1018 type: "POST",1019 url : site_urls+"node/delete_imgs",1020 data: datastring,1021 cache: false,1022 success : function(data){1023 1024 },error : function(data){1025 }1026 });1027 }1028 });1029 $('body').on('click', '.approve_me', function () {1030 var id1 = $(this).attr("id1");1031 var caps = $(this).attr("caps");1032 var tbls = $(this).attr("tbls");1033 var columns = $(this).attr("columns");1034 1035 $('#approve_me'+id1).html('<b>.......</b>').removeClass('approve_me');1036 1037 if(tbls=="cart"){1038 var caps1="This cannot be undone, Proceed?";1039 }else if(tbls=="members"){1040 if(caps!="Approved")1041 var caps1="Proceed to unblock this member?";1042 else1043 var caps1="Proceed to block this member?";1044 }else{1045 if(caps!="Approved")1046 var caps1="Approving this will make it visible on the platform.\r\nProceed?";1047 else1048 var caps1="Proceed to disapprove this?";1049 }1050 if(confirm(caps1)){1051 var datastring='id1='+id11052 +'&tbls='+tbls1053 +'&columns='+columns;1054 //alert(datastring)1055 $.ajax({1056 type : "POST",1057 url : site_urls+"node/approve_tables",1058 data: datastring,1059 timeout: 30000, // 30 second timeout1060 success : function(data){1061 dataTable.clear().draw();1062 dataTable.rows.add(NewlyCreatedData);1063 dataTable.columns.adjust().draw();1064 1065 },error : function(data, timeouts){1066 if(timeouts==="timeout") {1067 alert("Time out, please try again later");1068 }1069 $('#approve_me'+id1).html('<b>'+caps+'</b>').addClass('approve_me');1070 }1071 });1072 return false;1073 }else{1074 $('#approve_me'+id1).html('<b>'+caps+'</b>').addClass('approve_me');1075 }1076 return false;1077 });1078 $('body').on('click', '.edit_me', function () {1079 var ids = $(this).attr("id");1080 var usertype = $(this).attr("usertype");1081 var mypage = $(this).attr("mypage");1082 var url_task = $(this).attr("url_task");1083 if($.isNumeric(usertype) && parseInt(usertype)>0){1084 window.location = site_urls+"dashboard/"+mypage+"/"+ids+"/";1085 }else{1086 if(url_task!="")1087 window.location = site_urls+"admin/"+mypage+"/"+ids+"/"+url_task+"/";1088 else1089 window.location = site_urls+"admin/"+mypage+"/"+ids+"/";1090 }1091 });1092 1093 $('body').on('change', '#txtyears', function () {1094 var txtyears = $(this).val();1095 var ids_arr = $(this).attr('ids_arr');1096 var name_of_sch = $(this).attr('name_of_sch');1097 var txtsubjid = $('.txtsubjid').val();1098 var txttest_board = $('.txttest_board').val();1099 1100 var datastring='txtyears='+txtyears1101 +'&txtsubjid='+txtsubjid1102 +'&ids_arr='+ids_arr1103 +'&name_of_sch='+name_of_sch1104 +'&txttest_board='+txttest_board;1105 //alert(datastring)1106 $(".no_of_quests").html('Loading...');1107 $.ajax({1108 type : "POST",1109 url : site_urls+"node/noofquest",1110 data : datastring,1111 cache : false,1112 success : function(data){1113 $(".no_of_quests").html(data);1114 $("#txt_no_of_quests").val(data);1115 },error : function(data){1116 }1117 });1118 });1119 function copyToClipboard(element) {1120 var $temp = $("<textarea>");1121 $("body").append($temp);1122 var x = $(element).html().trim().replace(/<br>/g, '\n').replace(/<\/?[^>]+>/g, '');1123 $temp.val(x).select();1124 document.execCommand("copy");1125 $temp.remove();1126 }1127 $('body').on('click', '.copy_text', function () {1128 var ids = $(this).attr('ids');1129 copyToClipboard(document.getElementById("copyTarget"+ids));1130 $('.copy_text').fadeOut(30);1131 $('#cover_contents1'+ids).fadeOut('fast');1132 });1133 $('body').on('click', '.copy_texts', function () {1134 var ids = $(this).attr('ids');1135 copyToClipboard(document.getElementById("copyTarget"+ids));1136 $('.copy_texts').fadeOut(30);1137 $('#cover_contents1'+ids).fadeOut('fast');1138 });1139 $('body').on('click', '.open_comment', function () {1140 var frid = $(this).attr('frid');1141 var tils = $(this).attr('tils');1142 //var directs1 = $(this).attr('directs1');1143 create_cookie('frid', frid);1144 create_cookie('tils', tils);1145 // if(directs1!=""){1146 // window.location = site_urls+directs1;1147 // }else{1148 open_comment();1149 //}1150 });1151 function open_comment(){1152 //hide_all_no_e();1153 //var hash = location.hash.substring(1);1154 var frid = retrieve_cookie('frid');1155 var tils = retrieve_cookie('tils');1156 if($(window).width()<760)1157 $("html, body").animate({scrollTop:$('.scrltotop').offset().top}, "fast");1158 else1159 $("html, body").animate({scrollTop:$('.scrltotop').offset().top+120}, "fast");1160 //create_cookie('urls_prev', hash);1161 create_cookie('frid', frid);1162 //$(".forum_view").show().html('<div class="load_values"><img src="'+site_urls+'images/loader.gif"> Loading replies...</div><br><br><br><br><br>');1163 $('.main_forum').hide();1164 $('.reply_forum').fadeIn('fast').html('<div style="text-align:center"><img src="'+site_urls+'images/loader.gif"> Loading replies...</div><br><br><br><br>');1165 var datastring='frid='+frid;1166 //+'&activityid='+activityid;1167 //alert(datastring)1168 $.ajax({1169 type : "POST",1170 url : site_urls+"node/forum_view_loads",1171 data : datastring,1172 //cache : false,1173 success : function(data){1174 //alert(data)1175 $('.reply_forum').html(data);1176 setTimeout(function(){1177 $('#fr_ids').val(frid);1178 },100);1179 },error : function(data){1180 }1181 });1182 }1183 $('body').on('mousedown', '.read_mores', function () {1184 $('.start_about').slideUp('fast');1185 $('.contd_about').slideDown('fast');1186 });1187 $('body').on('mousedown', '.read_lesss', function () {1188 $('.contd_about').slideUp('fast');1189 $('.start_about').slideDown('fast');1190 });1191 $('body').on('change', '#txtcollege1', function () {1192 var txtcollege1 = $(this).val();1193 var test_logo = $(this).attr('test_logo');1194 var test_board1 = $(this).attr('test_board1');1195 var datastring='colleges='+txtcollege11196 +'&test_logo='+test_logo1197 +'&test_board1='+test_board1;1198 var src1 = $(".img_test_logo img").attr('src1');1199 $(".loaders").show();1200 $.ajax({1201 type : "POST",1202 url : site_urls+"node/display_subjects",1203 data : datastring,1204 cache : false,1205 dataType: 'json',1206 timeout: 30000, // 30 second timeout1207 success : function(data){1208 $(".sch_contents").html(data.msg);1209 if(data.logos!="")1210 $(".img_test_logo img").attr('src', site_urls+"logos_files/"+data.logos);1211 else1212 $(".img_test_logo img").attr('src', src1);1213 $(".loaders").hide();1214 },error : function(data, timeouts){1215 if(timeouts==="timeout") {1216 alert("Time out, please try again later");1217 }else{1218 alert('Error! Network Connection Failed!');1219 }1220 $(".loaders").hide();1221 }1222 });1223 });1224 $('body').on('click', '.start_here', function () {1225 $("html, body").animate({scrollTop: $('.educate').offset().top-30 }, 1000);1226 });1227 $('body').on('click', '.select_test', function () {1228 $('.explore_cats').slideUp('fast');1229 $('.explore_1').slideDown('fast');1230 });1231 $('body').on('click', '.back_btn', function () {1232 $('.explore_cats').slideDown('fast');1233 $('.explore_1').slideUp('fast');1234 });1235 $('body').on('click', '.login_btn', function () {1236 $('.div_contents').hide();1237 $('#div_contents, .choose_subjects').hide();1238 $('.div_reg_login').fadeIn('fast');1239 $(this).html('« Back').removeClass('login_btn').addClass('back_to_main');1240 });1241 $('body').on('click', '.login_btn_j', function () {1242 $('.div_contents').hide();1243 $('#div_contents, .choose_subjects').hide();1244 $('.div_reg_login').fadeIn('fast');1245 //$(this).html('« Back').removeClass('login_btn').addClass('back_to_main');1246 });1247 1248 $('body').on('click', '.empty_tests', function () {1249 alert('Cannot proceed! No questions in this subject!')1250 });1251 1252 $('body').on('click', '.mobile_goback', function () {1253 $('.main_forum').fadeIn('fast');1254 $('.reply_forum').hide();1255 });1256 $('body').on('click', '.no_start_tests', function () {1257 var selected_subjs = $('.selected_subjs').val();1258 var counts = selected_subjs.split(',').length;1259 var isSubjects = $(this).attr('isSubjects');1260 if(isSubjects==1){1261 if(counts < 2){1262 $('.selecteds').html("<div class='errs'>Please select at least 2 subjects</div>").show();1263 return false;1264 }else if(counts > 6){1265 $('.selecteds').html("<div class='errs'>You can only select maximum of 6 subjects</div>").show();1266 return false;1267 }else{1268 $('.login_btn').html('« Back').removeClass('login_btn').addClass('back_to_main');1269 $('.login_btn_i').html('« BACK').removeClass('login_btn_i').addClass('back_to_main');1270 }1271 $('.div_contents').hide();1272 $('.div_reg_login').fadeIn('fast');1273 }else{1274 $('.div_contents').hide();1275 $('.div_reg_login').fadeIn('fast');1276 //return false;1277 }1278 $('.choose_subjects').hide();1279 1280 });1281 1282 $('body').on('click', '.cmd_back2', function () {1283 create_cookie('onGoingTest', 0);1284 create_cookie('s_id1', '');1285 create_cookie('s_selected_subjs', '');1286 create_cookie('s_test_board2', '');1287 create_cookie('s_txtcollege1', '');1288 create_cookie('s_name_of_sch', '');1289 create_cookie('s_arrays', '');1290 create_cookie('s_counts', '');1291 create_cookie('s_memid', '');1292 create_cookie('txtpage_number', '');1293 create_cookie('txttotalquiz', '');1294 create_cookie('subjects', '');1295 create_cookie('selected_subjs', '');1296 create_cookie('counts', '');1297 create_cookie('id1', '');1298 create_cookie('test_types', '');1299 $(".subject_instruc").hide();1300 $(".main_test_page").html('').hide();1301 if($(window).width() < 760) $('.myheaders_mobile').show();1302 $('.choose_subjects').fadeIn('fast');1303 });1304 1305 $('body').on('click', '.cmd_back_details', function () {1306 $(".buybtn_online").css({'opacity': '1', 'color': '#ddd'}).html("Pay Online <i class='fa fa-arrow-right'></i>").addClass('buybtn_online');1307 $(".alert_msgs").hide();1308 $(".myBookDetails_Pay").hide();1309 $('.myBookDetails').fadeIn('fast');1310 });1311 // $('body').on('click', '.cmd_back_lists', function () {1312 // window.location = site_urls+"resources/past-questions/";1313 // });1314 1315 $('body').on('click', '.cmd_buythis', function () {1316 $(".myBookDetails").hide();1317 $(".myBookDetails_Pay").fadeIn('fast');1318 });1319 $('body').on('click', '.buybtn', function () {1320 var self = this;1321 var ids = $(this).attr('ids');1322 var titles = $(this).attr('titles');1323 var txtwrite = $('.txtwrite').val();1324 if(txtwrite==1)1325 var txtlocatn = $('#txtlocatn').val();1326 else1327 var txtlocatn = "";1328 $(".alert_msgs").hide();1329 if(confirm("Proceed to submit this using bank transfer?")){1330 $(self).css({'opacity': '0.6', 'color': '#ccc'}).html("Please wait...").removeClass('buybtn');1331 var datastring='ids='+ids1332 +'&txtlocatn='+txtlocatn1333 +'&txtwrite='+txtwrite1334 +'&pay_type=manual'1335 +'&titles='+titles;1336 $.ajax({1337 type: "POST",1338 url : site_urls+"node/submit_orders",1339 data: datastring,1340 timeout: 30000, // 30 second timeout1341 success : function(data){1342 //alert(data)1343 if(data=="submitted"){1344 $(self).css({'opacity': '1', 'color': '#ddd'}).html("Use Mobile Transfer <i class='fa fa-arrow-right'></i>").addClass('buybtn');1345 $('.myBookDetails_Pay').hide();1346 $('.myBookDetails_Success').fadeIn('fast');1347 }else{1348 $(".alert_msgs").fadeIn('fast').html(data).addClass('alert-danger');1349 $(self).css({'opacity': '1', 'color': '#ddd'}).html("Use Mobile Transfer <i class='fa fa-arrow-right'></i>").addClass('buybtn');1350 }1351 },error : function(data, timeouts){1352 if(timeouts==="timeout") {1353 alert("Time out, please try again later");1354 }1355 $(self).css({'opacity': '1', 'color': '#ddd'}).html("Use Mobile Transfer <i class='fa fa-arrow-right'></i>").addClass('buybtn');1356 $(".alert_msgs").fadeIn('fast').html(data).addClass('alert-danger');1357 }1358 });1359 }1360 });1361 $(".buybtn_online").click(function(){1362 var self = this;1363 var ids = $(this).attr('ids');1364 var titles = $(this).attr('titles');1365 var txtwrite = $('.txtwrite').val();1366 var myemail = $(this).attr("myemail");1367 var amts = $(this).attr("amts");1368 if(txtwrite==1)1369 var txtlocatn = $('#txtlocatn').val();1370 else1371 var txtlocatn = "";1372 $(self).css({'opacity': '0.6', 'color': '#ccc'}).html("Please wait...").removeClass('buybtn_online');1373 $(".alert_msgs").hide();1374 var datastring='ids='+ids1375 +'&txtlocatn='+txtlocatn1376 +'&txtwrite='+txtwrite1377 +'&titles='+titles;1378 $.ajax({1379 type: "POST",1380 url : site_urls+"node/submit_orders_verify",1381 data: datastring,1382 cache: false,1383 timeout: 30000, // 30 second timeout1384 success : function(data){1385 if(data=="verified"){1386 var handler = PaystackPop.setup({1387 key: 'pk_test_7a186fe10e37f8cbcb70c59eceedec05dc7dd32a',1388 //key: 'pk_live_0cb98f972c8c916632114df231f0b294d1bdac57',1389 email: myemail,1390 amount: amts,1391 ref: ''+Math.floor((Math.random() * 1000000000) + 1),1392 callback: function(response){1393 var datastring='ids='+ids1394 +'&txtlocatn='+txtlocatn1395 +'&txtwrite='+txtwrite1396 +'&pay_type='+response.reference1397 +'&titles='+titles;1398 $.ajax({1399 type: "POST",1400 url : site_urls+"node/submit_orders",1401 data: datastring,1402 cache: false,1403 timeout: 30000, // 30 second timeout1404 success : function(data){1405 //alert(data)1406 if(data=="submitted"){1407 $(self).css({'opacity': '1', 'color': '#ddd'}).html("Pay Online <i class='fa fa-arrow-right'></i>").addClass('buybtn_online');1408 $('.myBookDetails_Pay').hide();1409 $('.myBookDetails_Success').fadeIn('fast');1410 }else{1411 $(".alert_msgs").fadeIn('fast').html(data).addClass('alert-danger');1412 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#ddd'}).html("Pay Online <i class='fa fa-arrow-right'></i>").addClass('buybtn_online');1413 }1414 },error : function(data, timeouts){1415 if(timeouts==="timeout") {1416 alert("Time out, please try again later");1417 }1418 $(self).css({'opacity': '1', 'color': '#ddd'}).html("Pay Online <i class='fa fa-arrow-right'></i>").addClass('buybtn_online');1419 $(".alert_msgs").fadeIn('fast').html(data).addClass('alert-danger');1420 }1421 });1422 },1423 onClose: function(){1424 $(self).css({'opacity': '1', 'color': '#ddd'}).html("Pay Online <i class='fa fa-arrow-right'></i>").addClass('buybtn_online');1425 }1426 });1427 handler.openIframe();1428 }else{1429 $(".alert_msgs").fadeIn('fast').html(data).addClass('alert-danger');1430 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#ddd'}).html("Pay Online <i class='fa fa-arrow-right'></i>").addClass('buybtn_online');1431 }1432 }1433 });1434 });1435 // var jQ = jQuery.noConflict()1436 // jQ('body').on('click', '.cmd_enter_sch', function () {1437 // var txtschs = jQ("#txtschs").val();1438 // var datastring2='txtschs='+txtschs;1439 // jQ.ajax({1440 // type: "POST",1441 // url : site_urls+"node/add_to_schs",1442 // data: datastring2,1443 // timeout: 30000, // 30 second timeout1444 // success : function(data){1445 // if(data=="exists"){1446 // alert('The school name already exists');1447 // return false;1448 // }1449 // jQ(".div_sch").html(data);1450 // jQ("#txtschs").val('');1451 // jQ('.cover_body').hide();1452 // jQ('#add_schs').fadeOut('fast');1453 // }1454 // });1455 // });1456 1457 $('body').on('click', '.cmd_enter_sch', function () {1458 var txtschs = $("#txtschs").val();1459 var datastring2='txtschs='+txtschs;1460 $.ajax({1461 type: "POST",1462 url : site_urls+"node/add_to_schs",1463 data: datastring2,1464 timeout: 30000, // 30 second timeout1465 success : function(data){1466 if(data=="exists"){1467 alert('The school name already exists');1468 return false;1469 }1470 $(".div_sch").html(data);1471 $("#txtschs").val('');1472 $('.cover_body').hide();1473 $('#add_schs').fadeOut('fast');1474 }1475 });1476 });1477 $('body').on('click', '.cmd_enter_sub', function () {1478 var txtsub = $("#txtsub").val();1479 var datastring2='txtsub='+txtsub;1480 $.ajax({1481 type: "POST",1482 url : site_urls+"node/add_to_subjs",1483 data: datastring2,1484 timeout: 30000, // 30 second timeout1485 success : function(data){1486 if(data=="exists"){1487 alert('The subject name already exists');1488 return false;1489 }1490 $(".div_subject").html(data);1491 $("#txtsub").val('');1492 $('.cover_body').hide();1493 $('#add_subj_dv').fadeOut('fast');1494 }1495 });1496 });1497 // $('body').on('click', '.noclickforum, #cmdnoPosts', function () {1498 // if(confirm("You cannot use this feature, please login and continue.\r\nDo you want to login or register?")){1499 // window.location = site_urls;1500 // }1501 // return false;1502 // });1503 $('body').on('click', '.txt_srch_forums', function (e) {1504 e.stopPropagation();1505 if($(window).width()<760)1506 $(".mobile_cats").animate({height:'270'})1507 });1508 //$('.clickforum').live("click",function(){1509 $('body').on('click', '.clickforum', function () {1510 $('.txtselectcat').fadeIn('fast');1511 $('.textareas').slideDown('fast');1512 $('.clickforum').hide();1513 $('#txt_srch_forum1').show();1514 });1515 $('body').on('click', '.cancel_posts', function () {1516 $("#form2")[0].reset();1517 $('.txtselectcat').fadeOut('fast');1518 $('.textareas').slideUp('fast');1519 $('#txt_srch_forum1').hide();1520 $('.clickforum').show();1521 $('#selectedCaption1').empty().html('No file selected');1522 $(".errs").hide();1523 $('.bold_info1').hide();1524 });1525 $('body').on('click', '.view_formats', function () {1526 $('.bold_info1').fadeToggle('fast');1527 });1528 $('body').on('click', '.cmd_downloadthis', function () {1529 var self = this;1530 var ids = $(this).attr('ids');1531 var files = $(this).attr('files');1532 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).html("Please wait...");1533 var datastring='ids='+ids;1534 $.ajax({1535 type: "POST",1536 url : site_urls+"node/download_file",1537 data: datastring,1538 timeout: 30000, // 30 second timeout1539 success : function(data){1540 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#ddd'}).html("Download Now");1541 window.location = site_urls+"resourcesfiles/"+files;1542 //window.location = site_urls+"images/1.jpg";1543 },error : function(data, timeouts){1544 if(timeouts==="timeout") {1545 alert("Time out, please try again later");1546 }else{1547 alert('Error! Network Connection Failed!');1548 }1549 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#ddd'}).html("Download Now");1550 }1551 });1552 });1553 1554 $('body').on('click', '.alert_msgs', function () {1555 $(this).fadeOut('fast');1556 });1557 1558 $('body').on('click', '.show_performance span', function () {1559 if(confirm("It will open a new page to view it, continue?")){1560 window.location = site_urls+"dashboard/performance/";1561 }1562 });1563 $('body').on('click', '.start_tests', function () {1564 var inits = false;1565 var subjects = $(this).attr('subjects');1566 var isSubjects = $(this).attr('isSubjects');1567 var memid = $(this).attr('memid');1568 var subject_id = $(this).attr('subject_id');1569 $('.selecteds').html('').hide();1570 $('.login_info').hide();1571 //var selected_subjs = $('.selected_subjs').val();1572 1573 var selected_subjs1 = retrieve_cookie('s_selected_subjs');1574 var subjects1 = retrieve_cookie('subjects');1575 var id1 = retrieve_cookie('s_id1');1576 var test_board2 = retrieve_cookie('s_test_board2');1577 //var txtcollege1 = retrieve_cookie('s_txtcollege1');1578 var s_arrays = retrieve_cookie('s_arrays');1579 var counts = retrieve_cookie('s_counts');1580 //var memid = retrieve_cookie('s_memid');1581 if(subjects1==""){1582 create_cookie('subjects', subjects);1583 $('.selected_subjs').val(subjects);1584 }else{1585 $('.selected_subjs').val(subjects1);1586 }1587 if(selected_subjs1==""){1588 var selected_subjs = $('.selected_subjs').val();1589 create_cookie('s_selected_subjs', selected_subjs);1590 }else{1591 var selected_subjs = selected_subjs1;1592 }1593 if(counts==""){1594 var counts = selected_subjs.split(',').length;1595 create_cookie('counts', counts);1596 }1597 if(id1==""){1598 var id1 = $(this).attr('id1');1599 create_cookie('id1', id1);1600 }1601 if(test_board2==""){1602 var test_types = $(this).attr("test_types");1603 create_cookie('test_types', test_types);1604 }else{1605 var test_types = test_board2;1606 }1607 if(s_arrays==""){1608 var ids = "non_arrays";1609 }else{1610 var ids = "arrays";1611 }1612 if(memid==0 || memid==""){1613 $('.login_info').fadeIn('fast');1614 return false;1615 }1616 $('.choose_subjects').slideUp('fast');1617 $('.subject_instruc').slideDown('slow');1618 var emps="";1619 var datastring='id1='+id11620 +'&selected_subjs='+selected_subjs1621 +'&test_board2='+test_types1622 +'&txtcollege1='+emps1623 +'&name_of_sch='+emps1624 +'&subject_id='+subject_id1625 +'&ids='+ids1626 +'&counts='+counts;1627 // var datastring='id1='+id11628 // +'&selected_subjs='+selected_subjs1629 // +'&test_board2='+test_board21630 // +'&txtcollege1='+txtcollege11631 // +'&name_of_sch='+name_of_sch11632 // +'&ids=arrays'1633 // +'&counts='+counts;1634 //alert(datastring)1635 $.ajax({1636 type : "POST",1637 url : site_urls+"node/display_subject_details",1638 data : datastring,1639 cache : false,1640 timeout: 30000, // 30 second timeout1641 success : function(data){1642 $(".subject_instruc").html(data);1643 },error : function(data, timeouts){1644 if(timeouts==="timeout") {1645 alert("Time out, please try again later");1646 }1647 $(".subject_instruc").html(data);1648 }1649 });1650 });1651 $('body').on('click', '.start_tests_proceed', function () {1652 var inits = false;1653 var subjects = $(this).attr('subjects');1654 var isSubjects = $(this).attr('isSubjects');1655 var id1 = $('.selected_subjs_ids').val();1656 var txtcollege1 = $('#txtcollege1').val();1657 $('.selecteds').html('').hide();1658 var memid = $(this).attr('memid');1659 var test_board2 = $(this).attr('test_board2');1660 var name_of_sch = $(this).attr('name_of_sch');1661 1662 $('.login_info').hide();1663 var selected_subjs = $('.selected_subjs').val();1664 var counts = selected_subjs.split(',').length;1665 //alert(counts);1666 if(counts < 2){1667 $('.selecteds').html("<div class='errs1'>Please select at least 2 subjects</div>").show();1668 return false;1669 }else if(counts > 6){1670 $('.selecteds').html("<div class='errs1'>You can only select maximum of 6 subjects</div>").show();1671 return false;1672 }else{1673 var id1_i = id1.replace(/\n/gi, "");1674 var selected_subjs_i = selected_subjs.replace(/\n/gi, "");1675 ////// store in cookies incase i refresh //////1676 create_cookie('s_id1', id1_i);1677 create_cookie('s_selected_subjs', selected_subjs_i);1678 create_cookie('s_test_board2', test_board2);1679 create_cookie('s_txtcollege1', txtcollege1);1680 create_cookie('s_name_of_sch', name_of_sch);1681 create_cookie('s_arrays', 'arrays');1682 create_cookie('s_counts', counts);1683 create_cookie('s_memid', memid);1684 ////// store in cookies incase i refresh //////1685 1686 if(memid==0 || memid==""){1687 $('.login_info').fadeIn('fast');1688 return false;1689 }1690 $('.choose_subjects').slideUp('fast');1691 $('.subject_instruc').slideDown('slow');1692 var emps="";1693 1694 var datastring='id1='+id11695 +'&selected_subjs='+selected_subjs1696 +'&test_board2='+test_board21697 +'&txtcollege1='+txtcollege11698 +'&name_of_sch='+name_of_sch1699 +'&subject_id='+emps1700 +'&ids=arrays'1701 +'&counts='+counts;1702 //alert(datastring)1703 $.ajax({1704 type : "POST",1705 url : site_urls+"node/display_subject_details",1706 data : datastring,1707 cache : false,1708 timeout: 30000, // 30 second timeout1709 success : function(data){1710 $(".subject_instruc").html(data);1711 },error : function(data, timeouts){1712 if(timeouts==="timeout") {1713 alert("Time out, please try again later");1714 }1715 $(".subject_instruc").html(data);1716 }1717 });1718 }1719 });1720 function start_tests_proceed_func(){1721 $('.selecteds').html('').hide();1722 1723 var selected_subjs = retrieve_cookie('s_selected_subjs');1724 var id1 = retrieve_cookie('s_id1');1725 var test_board2 = retrieve_cookie('s_test_board2');1726 var txtcollege1 = retrieve_cookie('s_txtcollege1');1727 var name_of_sch1 = retrieve_cookie('s_name_of_sch');1728 var s_arrays = retrieve_cookie('s_arrays');1729 var counts = retrieve_cookie('s_counts');1730 var memid = retrieve_cookie('s_memid');1731 $('.login_info').hide();1732 var txtpage_number = retrieve_cookie('txtpage_number');1733 var txttotalquiz = retrieve_cookie('txttotalquiz');1734 $("#txttotalquiz").val(txttotalquiz);1735 $("#txtpage_number").val(txtpage_number);1736 $('.selected_subjs').val(selected_subjs);1737 $('.selected_subjs_ids').val(id1);1738 //alert(selected_subjs);1739 // alert(counts);1740 //alert(id1);1741 // alert(test_board2);1742 // alert(txtcollege1);1743 // alert(s_arrays);1744 // alert(counts);1745 // alert(memid);1746 if(memid==0 || memid==""){1747 $('.login_info').fadeIn('fast');1748 return false;1749 }1750 $('.choose_subjects').slideUp('fast');1751 $('.subject_instruc').slideDown('slow');1752 var emps="";1753 var datastring='id1='+id11754 +'&selected_subjs='+selected_subjs1755 +'&test_board2='+test_board21756 +'&txtcollege1='+txtcollege11757 +'&name_of_sch='+name_of_sch11758 +'&subject_id='+emps1759 +'&ids=arrays'1760 +'&counts='+counts;1761 $.ajax({1762 type : "POST",1763 url : site_urls+"node/display_subject_details",1764 data : datastring,1765 cache : false,1766 timeout: 30000, // 30 second timeout1767 success : function(data){1768 $(".subject_instruc").html(data);1769 },error : function(data, timeouts){1770 if(timeouts==="timeout") {1771 alert("Time out, please try again later");1772 }1773 $(".subject_instruc").html(data);1774 }1775 });1776 }1777 $('body').on('click', '#cmd_submit_answers_timeout', function () {1778 $('.tawk_to').show();1779 $('.cmd_next_quiz').hide();1780 $('.cmd_next_quiz1').show();1781 $('.cmd_next_quiz2').show();1782 //$('.quiz_starts').hide();1783 create_cookie('onGoingTest', 0);1784 create_cookie('s_id1', '');1785 create_cookie('s_selected_subjs', '');1786 create_cookie('s_test_board2', '');1787 create_cookie('s_txtcollege1', '');1788 create_cookie('s_name_of_sch', '');1789 create_cookie('s_arrays', '');1790 create_cookie('s_counts', '');1791 create_cookie('s_memid', '');1792 create_cookie('txtpage_number', '');1793 create_cookie('txttotalquiz', '');1794 create_cookie('subjects', '');1795 create_cookie('selected_subjs', '');1796 create_cookie('counts', '');1797 create_cookie('id1', '');1798 create_cookie('test_types', '');1799 var qid_intro = $(this).attr('id_sch');1800 var subject_id = $(this).attr('subject_id');1801 var test_board = $(this).attr('test_board');1802 var ids_arr = $(this).attr('ids_arr');1803 //$(".cmd_sub_answers").click();1804 clearThisSession(qid_intro, subject_id, test_board, ids_arr);1805 });1806 $('body').on('click', '.cancel_test span', function () {1807 var id_sch = $(this).attr('id_sch');1808 var subject_id = $(this).attr('subject_id');1809 var ids_arr = $(this).attr('ids_arr');1810 $('.tawk_to').show();1811 if(confirm("Are you sure you want to cancel this test?")){1812 totalAmount = 0;1813 clearTimeout(timeloop);1814 localStorage.removeItem('countDown');1815 create_cookie('onGoingTest', 0);1816 create_cookie('s_id1', '');1817 create_cookie('s_selected_subjs', '');1818 create_cookie('s_test_board2', '');1819 create_cookie('s_txtcollege1', '');1820 create_cookie('s_name_of_sch', '');1821 create_cookie('s_arrays', '');1822 create_cookie('s_counts', '');1823 create_cookie('s_memid', '');1824 create_cookie('txtpage_number', '');1825 create_cookie('txttotalquiz', '');1826 create_cookie('subjects', '');1827 create_cookie('selected_subjs', '');1828 create_cookie('counts', '');1829 create_cookie('id1', '');1830 create_cookie('test_types', '');1831 $('.fade_questions').show();1832 $('.cmd_next_quiz').show();1833 $('.cmd_next_quiz1').hide();1834 $('.cmd_next_quiz2').hide();1835 $('.subject_instruc').hide();1836 $('.main_test_page').html('');1837 $('.main_test_page').hide();1838 $('.quiz_starts').hide();1839 $('.choose_subjects').fadeIn('fast');1840 if($(window).width() < 760) $('.myheaders_mobile').show();1841 var datastring2='id_sch='+id_sch1842 +'&subject_id='+subject_id1843 +'&ids_arr='+ids_arr;1844 $.ajax({1845 type: "POST",1846 url : site_urls+"node/remove_started_test",1847 data: datastring2,1848 success : function(data){1849 1850 }1851 });1852 }1853 });1854 var onGoingTest = retrieve_cookie('onGoingTest');1855 if(onGoingTest == 1){1856 $(".start_tests").click();1857 //start_tests_proceed_func();1858 }1859 1860 var s_arrays = retrieve_cookie('s_arrays');1861 //alert(s_arrays)1862 if(s_arrays == "arrays"){1863 start_tests_proceed_func();1864 }1865 $('body').on('click', '.close_list', function (e) { 1866 e.stopPropagation();1867 });1868 $('body').on('click', '.close_list i', function (e) {1869 $('#country_list_id').hide();1870 });1871 $('body').on('click', '#cmd_goto_first', function (e) {1872 $('.third_create_form').hide();1873 $('.first_create_game').fadeIn('fast');1874 });1875 $('body').on('click', '#cmd_goto_questions', function (e) {1876 window.location = site_urls+"admin/upload_questions/";1877 });1878 1879 $('body').on('keyup', '.txtkeywd', function (e) { 1880 e.stopPropagation();1881 var keyword = $('.txtkeywd').val();1882 1883 var datastring='keyword='+keyword;1884 //+'&search_type='+search_type;1885 if(keyword != ""){1886 $.ajax({1887 url : site_urls+"node/getSearches",1888 type: 'POST',1889 data: datastring,1890 timeout: 30000, // 30 second timeout1891 success:function(data){1892 //alert(data);1893 if(data != ""){1894 $('#country_list_id').show();1895 $('#country_list_id').html(data);1896 }else{1897 $('#country_list_id').hide();1898 $('#country_list_id').html('');1899 }1900 },error : function(data){1901 1902 }1903 });1904 }else{1905 $('#country_list_id').hide();1906 }1907 });1908 1909 $('body').on('click', '.set_item', function (e) {1910 e.stopPropagation();1911 var thisname = $(this).attr('thisname');1912 $('.txtkeywd').val(thisname);1913 var txtkeywd = $('.txtkeywd').val();1914 var datastring='keywords='+txtkeywd1915 +'&wholesearch=1';1916 $(".loaders").show();1917 $.ajax({1918 type : "POST",1919 url : site_urls+"node/filterCentres",1920 data : datastring,1921 cache : false,1922 timeout: 30000, // 30 second timeout1923 success : function(data){1924 //alert(data)1925 $(".loaders").hide();1926 $(".filterCentres1").html(data);1927 $("html, body").animate({scrollTop: $('.scrollhere2').offset().top-120 }, 20);1928 },error : function(data, timeouts){1929 if(timeouts==="timeout") {1930 alert("Time out, please try again later");1931 }1932 $(".loaders").hide();1933 }1934 });1935 });1936 var myEditor = document.querySelector('#editor');1937 if(myEditor != null){1938 var editor_html = myEditor.children[0].innerHTML;1939 var editor = $("#txteditor").val(editor_html);1940 var editor = $("#txtquestions").val(editor_html);1941 //var editor = $("#txtdescrip").val(editor_html);1942 }1943 1944 $('body').on('blur, keyup, focusout', '#editor', function () {1945 var myEditor = document.querySelector('#editor');1946 var editor_html = myEditor.children[0].innerHTML;1947 var editor = $("#txteditor").val(editor_html);1948 var editor = $("#txtquestions").val(editor_html);1949 //var editor = $("#txtdescrip").val(editor_html);1950 });1951 $('body').on('click', '.add_sch', function () {1952 $('.cover_body').show();1953 $('#add_schs').fadeIn('fast');1954 });1955 $('body').on('click', '.add_subj', function () {1956 $('.cover_body').show();1957 $('#add_subj_dv').fadeIn('fast');1958 });1959 $('body').on('click', '.cover_body, .cmd_close_sch', function () {1960 $("#txtschs").val('');1961 $('.cover_body').hide();1962 $('#delete_dv').hide();1963 $('#add_schs').fadeOut('fast');1964 });1965 $('body').on('click', '.cover_body, .cmd_close_sub', function () {1966 $("#txtsub").val('');1967 $('.cover_body').hide();1968 $('#delete_dv').hide();1969 $('#add_subj_dv').fadeOut('fast');1970 });1971 $('body').on('click', '.cmd_remove_adm', function () { 1972 var txtall_id = $("#txtall_id").val();1973 var txt_dbase_table = $("#txt_dbase_table").val();1974 $(".cmd_remove_adm").hide();1975 $(".cmd_remove_adm1").show();1976 1977 var datastring='txtall_id='+txtall_id1978 +'&txt_dbase_table='+txt_dbase_table;1979 $.ajax({1980 type: "POST",1981 url : site_urls+"node/delete_records",1982 data: datastring,1983 cache: false,1984 success: function(html){1985 $(".cmd_remove_adm").show();1986 $(".cmd_remove_adm1").hide();1987 $('.cmd_close_sch').click();1988 1989 dataTable.clear().draw();1990 dataTable.rows.add(NewlyCreatedData);1991 dataTable.columns.adjust().draw();1992 1993 },error : function(html){1994 alert('Error! Network Connection Failed!');1995 $(".cmd_remove_adm").show();1996 $(".cmd_remove_adm1").hide();1997 }1998 });1999 });2000 $('body').on('click', '#cmd_update_pass_admin', function (e) {2001 e.preventDefault();2002 var self = this;2003 $(".alert_msg1").hide();2004 2005 $(self).attr('disabled', true).css({'background': '#FFA275', 'color': '#ccc'});2006 2007 $.ajax({2008 type : "POST",2009 url : site_urls+"node/update_my_pass",2010 data: $("#edit_pass").serialize(),2011 timeout: 30000, // 30 second timeout2012 success : function(data){2013 if(data=="pass1_updated"){2014 $(self).removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});2015 2016 $(".alert_msg1").show().html('<div style="text-align:center">Your password has been updated!</div>').removeClass('alert-danger').addClass('alert-success');2017 $("#edit_pass")[0].reset();2018 2019 setTimeout(function(){2020 $(".alert_msg1").hide();2021 },2500);2022 2023 }else{2024 $(self).removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});2025 $(".alert_msg1").show().html('<div class="Errormsg">'+data+'</div>');2026 }2027 },error : function(data, timeouts){2028 if(timeouts==="timeout") {2029 alert("Time out, please try again later");2030 }else{2031 $(".alert_msg1").show().html('<div class="Errormsg">Poor Network Connection!</div>');2032 }2033 $(self).removeAttr('disabled').css({'background': '#f7631b', 'color': '#fff'});2034 }2035 });2036 });2037 $('body').on('click', '.cmd_sub_answers', function () {2038 var txt_time_finished = $("#txt_time_finished").val();2039 var tminus = $("#tminus").val();2040 var id_sch = $(this).attr('id_sch');2041 var subject_id = $(this).attr('subject_id');2042 var test_board = $(this).attr('test_board');2043 var ids_arr = $(this).attr('ids_arr');2044 $('.tawk_to').show();2045 if(confirm("Proceed to submit this?")){2046 create_cookie('onGoingTest', 0);2047 create_cookie('s_id1', '');2048 create_cookie('s_selected_subjs', '');2049 create_cookie('s_test_board2', '');2050 create_cookie('s_txtcollege1', '');2051 create_cookie('s_name_of_sch', '');2052 create_cookie('s_arrays', '');2053 create_cookie('s_counts', '');2054 create_cookie('s_memid', '');2055 create_cookie('txtpage_number', '');2056 create_cookie('txttotalquiz', '');2057 create_cookie('subjects', '');2058 create_cookie('selected_subjs', '');2059 create_cookie('counts', '');2060 create_cookie('id1', '');2061 create_cookie('test_types', '');2062 totalAmount = 0;2063 clearTimeout(timeloop);2064 localStorage.removeItem('countDown');2065 var datastring2='id_sch='+id_sch2066 +'&subject_id='+subject_id2067 +'&test_board='+test_board2068 +'&ids_arr='+ids_arr2069 +'&txt_time_finished='+txt_time_finished;2070 $.ajax({2071 type: "POST",2072 url : site_urls+"node/save_my_ansas",2073 data: datastring2,2074 success : function(data){2075 //alert(data)2076 $('.cmd_next_quiz').show();2077 $('.cmd_next_quiz1').hide();2078 $('.cmd_next_quiz2').hide();2079 $('.subject_instruc').hide();2080 $('.main_test_page').show();2081 $('.quiz_starts').hide();2082 //alert(tminus+"tminus")2083 if(tminus=="0:00")2084 $('.div_success_test_timeout').fadeIn('fast');2085 else2086 $('.div_success_test').fadeIn('fast');2087 }2088 });2089 }2090 });2091 $('body').on('click', '.contd_quiz', function () {2092 $('.tawk_to').hide();2093 $('.start_main_test').hide();2094 $('.start_main_test1').show();2095 var self = this;2096 //var txtans1 = $("#txtans1").val();2097 $('.started_text_value').val(1);2098 $(".loaders").show();2099 var txtrandom_quiz = $("#txtrandom_quiz").val();2100 var txtpage_number = $(this).attr('txtpage_number');2101 create_cookie('onGoingTest', 1);2102 var studid = $(this).attr('studid');2103 var id1 = $(this).attr('id1');2104 var is_new_rec = $(this).attr('is_new_rec');2105 $('.choose_subjects').slideUp('fast');2106 var instructn = $(this).attr('instructn');2107 var set_time = $(this).attr('set_time');2108 var test_types = $(this).attr('test_types');2109 var test_board = $(this).attr('test_board');2110 //var noOfQuest = $(this).attr('noOfQuest');2111 var noOfQuest = $("#txt_no_of_quests").val();2112 var subject_id = $(this).attr('subject_id');2113 var noOfYrs = $("#txtyears").val();2114 var schs = $(this).attr('schs');2115 var ids = $(this).attr('ids');2116 var subjects_caption = $(this).attr('subjects_caption');2117 //var txtans1 = $("#txtans1").val();2118 //var txtrandom_quiz = $("#txtrandom_quiz").val();2119 2120 continueTest(studid, id1, is_new_rec, self, instructn, set_time, test_types, test_board, noOfQuest, subject_id, noOfYrs, schs, txtrandom_quiz, txtpage_number, ids, subjects_caption);2121 });2122 function continueTest(studid, id1, is_new_rec, self, instructn, set_time, test_types, test_board, noOfQuest, subject_id, noOfYrs, schs, txtrandom_quiz, txtpage_number, ids, subjects_caption){2123 //setTimeout(function(){2124 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).val("Please wait...");2125 2126 $('.cmd_trigger').trigger('click');2127 var datastring='id1='+id12128 +'&schs='+schs2129 +'&set_time='+set_time2130 +'&test_types='+test_types2131 +'&test_board='+test_board2132 +'&noOfQuest='+noOfQuest2133 +'&subject_id='+subject_id2134 +'&noOfYrs='+noOfYrs2135 +'&studid='+studid2136 +'&ids='+ids2137 +'&subjects_caption='+subjects_caption2138 +'&instructn='+instructn2139 +'&is_new_rec='+is_new_rec;2140 //alert(datastring)2141 $.ajax({2142 type: "POST",2143 url : site_urls+"node/getUnanswered",2144 data: datastring,2145 success : function(data){2146 $("html, body").animate({ scrollTop: 0 }, "fast");2147 $('.fade_questions').fadeOut('fast');2148 var txtpage_number1 = parseInt(txtpage_number) + 1;2149 $('.subject_instruc').hide();2150 if(txtpage_number < noOfQuest){2151 $("#txtpage_number").val(txtpage_number1);2152 $('.cmd_next_quiz').show();2153 $('.cmd_next_quiz1').hide();2154 $('.fade_questions').show();2155 //setTimeout(function(){2156 $('.start_main_test1').hide();2157 $('.start_main_test').show();2158 $('.main_test_page').fadeIn('fast').html(data);2159 //},500);2160 //alert('sss')2161 }else{ // if the total question is equal to the page number, show done and submit to database2162 2163 $('.cmd_next_quiz').hide();2164 $('.cmd_next_quiz1').show();2165 $('.cmd_next_quiz2').show();2166 2167 clearThisSession(id1, subject_id, test_board, ids);2168 }2169 2170 $('#txtans1').val('');2171 $('.fade_questions').fadeOut('fast');2172 //$('.scroll_inner_quiz').fadeIn('fast').html('data');2173 $("#txtpage_number_h").html(txtpage_number1+".");2174 $(".loaders").hide();2175 //alert('sss')2176 setTimeout(function(){2177 $("html, body").animate({ scrollTop: 0 }, "fast");2178 },300);2179 }2180 });2181 2182 //},1500);2183 }2184 function clearThisSession(id_sch, subject_id, test_board, ids_arr){2185 var txt_time_finished = $("#txt_time_finished").val();2186 var tminus = $("#tminus").val();2187 create_cookie('onGoingTest', 0);2188 create_cookie('s_id1', '');2189 create_cookie('s_selected_subjs', '');2190 create_cookie('s_test_board2', '');2191 create_cookie('s_txtcollege1', '');2192 create_cookie('s_name_of_sch', '');2193 create_cookie('s_arrays', '');2194 create_cookie('s_counts', '');2195 create_cookie('s_memid', '');2196 create_cookie('txtpage_number', '');2197 create_cookie('txttotalquiz', '');2198 create_cookie('subjects', '');2199 create_cookie('selected_subjs', '');2200 create_cookie('counts', '');2201 create_cookie('id1', '');2202 create_cookie('test_types', '');2203 totalAmount = 0;2204 clearTimeout(timeloop);2205 localStorage.removeItem('countDown');2206 var datastring2='id_sch='+id_sch2207 +'&subject_id='+subject_id2208 +'&test_board='+test_board2209 +'&ids_arr='+ids_arr2210 +'&txt_time_finished='+txt_time_finished;2211 $.ajax({2212 type: "POST",2213 url : site_urls+"node/save_my_ansas",2214 data: datastring2,2215 success : function(data){2216 //alert(data)2217 $('.cmd_next_quiz').show();2218 $('.cmd_next_quiz1').hide();2219 $('.cmd_next_quiz2').hide();2220 $('.subject_instruc').hide();2221 $('.main_test_page').show();2222 $('.quiz_starts').hide();2223 //alert(tminus+"tminus")2224 if(tminus=="0:00")2225 $('.div_success_test_timeout').fadeIn('fast');2226 else2227 $('.div_success_test').fadeIn('fast');2228 }2229 });2230 }2231 2232 $('.kingster-copyright-left').html("<font style='line-height:24px;'>Copyright © 2019. TestPort.ng<br><font style='color:#999; font-size:14px;'>Developed by <a href='mailto:donchibobo@gmail.com'>CATech</a></font></font>");2233 $('body').on('click', '.quiz_options li input', function () {2234 var class1 = $(this).attr("value");2235 $('#txtans1').val(class1);2236 });2237 2238 $('body').on('click', '.view_answers', function () {2239 var id_sch = $(this).attr("id_sch");2240 var ids_arr = $(this).attr("ids_arr");2241 var subject_id = $(this).attr("subject_id");2242 $('.view_answers').hide();2243 $('.view_answers1').show();2244 var datastring='id_sch='+id_sch2245 +'&ids_arr='+ids_arr2246 +'&subject_id='+subject_id;2247 $.ajax({2248 type: "POST",2249 url : site_urls+"node/show_my_answers",2250 data: datastring,2251 timeout: 30000, // 30 second timeout2252 success : function(data){2253 $('.view_answers').show();2254 $('.view_answers1').hide();2255 $('.div_success_test_timeout, .div_success_test').hide();2256 2257 $('.div_show_perfomance').html(data).fadeIn('fast');2258 2259 },error : function(data, timeouts){2260 $('.view_answers').show();2261 $('.view_answers1').hide();2262 if(timeouts==="timeout"){2263 alert("Time out, please try again later");2264 }else{2265 $(".err_msg").show().html('<div class="Errormsg">Poor Network Connection!</div>');2266 }2267 }2268 });2269 });2270 $('body').on('click', '.btn_delete', function () {2271 $('#delete_dv').show();2272 $('.cover_body').show();2273 var for_id = $(this).attr("for_id");2274 var for_page = $(this).attr("for_page");2275 $('#txtall_id').val(for_id);2276 $('#txtall_page').val(for_page);2277 });2278 $('body').on('click', '.cmd_next_quiz', function () {2279 var isitChecked = $('.quiz_options li input').is(":checked");2280 if(isitChecked == true){2281 var checkedIds = $(".chk:checked").map(function() {2282 return this.value;2283 }).toArray();2284 $('#txtans1').val(checkedIds.join(", "));2285 }2286 var txtans1 = $("#txtans1").val();2287 var txtrandom_quiz = $("#txtrandom_quiz").val();2288 var txttotalquiz = $("#txttotalquiz").val();2289 var txtpage_number = $("#txtpage_number").val();2290 var qid_intro = $("#qid_intro").val();2291 var subject_id = $(this).attr("subject_id");2292 var test_types = $(this).attr("test_types");2293 var test_board = $(this).attr("test_board");2294 var ids_arr = $(this).attr("ids_arr");2295 var noOfYrs = $(this).attr("noOfYrs");2296 var txtpage_number1 = retrieve_cookie('txtpage_number');2297 var txttotalquiz1 = retrieve_cookie('txttotalquiz');2298 if(txtpage_number1!="" && txttotalquiz1!=""){ // incase i refresh, it shud retain the page num2299 var txttotalquiz = txttotalquiz1;2300 var txtpage_number = txtpage_number1;2301 }2302 $(".alert_msg").hide();2303 create_cookie('onGoingTest', 1);2304 2305 // if(txtans1==""){2306 // $(".alert_msg").fadeIn('fast').html('<div>Please select an answer!</div>');2307 // return false;2308 // }else{2309 $('.fade_questions').show();2310 $('.cmd_next_quiz').hide();2311 $('.cmd_next_quiz1').show();2312 var datastring='txtans1='+txtans12313 +'&txtrandom_quiz='+txtrandom_quiz2314 +'&qid_intro='+qid_intro2315 +'&test_types='+test_types2316 +'&test_board='+test_board2317 +'&noOfYrs='+noOfYrs2318 +'&ids_arr='+ids_arr2319 +'&tasks=nexts'2320 +'&subject_id='+subject_id;2321 // alert(txtpage_number)2322 // alert(txttotalquiz)2323 create_cookie('txtpage_number', parseInt(txtpage_number)+1);2324 create_cookie('txttotalquiz', txttotalquiz);2325 $.ajax({2326 type: "POST",2327 url : site_urls+"node/store_my_ansa",2328 data: datastring,2329 timeout: 30000, // 30 second timeout2330 success : function(data){2331 $('.cmd_prev_quiz_i').show();2332 $('.cmd_prev_quiz_j').hide();2333 var txtpage_number1 = parseInt(txtpage_number) + 1;2334 if(parseInt(txtpage_number) < parseInt(txttotalquiz)){2335 $("#txtpage_number").val(txtpage_number1);2336 $('.cmd_next_quiz').show();2337 $('.cmd_next_quiz1').hide();2338 }else if(parseInt(txtpage_number) >= parseInt(txttotalquiz)){ // if the total question is equal to the page number, show done and submit to database2339 //}else{2340 // alert(txtpage_number)2341 // alert(txttotalquiz)2342 $('.cmd_next_quiz').hide();2343 $('.cmd_next_quiz1').show();2344 $('.cmd_next_quiz2').show();2345 //alert('ddd')2346 //$(".cmd_sub_answers").click();2347 //clearThisSession(id1, subject_id);2348 clearThisSession(qid_intro, subject_id, test_board, ids_arr);2349 }2350 2351 $('#txtans1').val('');2352 setTimeout(function(){2353 $('.fade_questions').fadeOut('fast');2354 $('.scroll_inner_quiz').fadeIn('fast').html(data);2355 $("#txtpage_number_h").html(txtpage_number1+".");2356 //$('.cmd_prev_quiz_i').show();2357 // $('.cmd_prev_quiz_i').hide();2358 // $('.cmd_prev_quiz_j').hide();2359 },200);2360 setTimeout(function(){2361 $("html, body").animate({scrollTop:$('.scroll_inner_quiz').offset().top-200}, 300);2362 },700);2363 // clear the cookies bcos im active again2364 //create_cookie('txtpage_number', '');2365 //create_cookie('txttotalquiz', '');2366 2367 },error : function(data, timeouts){2368 if(timeouts==="timeout"){2369 alert("Time out, please try again later");2370 }else{2371 $(".err_msg").show().html('<div class="Errormsg">Poor Network Connection!</div>');2372 }2373 $('.cmd_next_quiz').show();2374 $('.cmd_next_quiz1').hide();2375 }2376 });2377 //}2378 });2379 $('body').on('click', '.cmd_prev_quiz', function () {2380 var txtans1 = $("#txtans1").val();2381 var txtrandom_quiz = $("#txtrandom_quiz").val();2382 var txttotalquiz = $("#txttotalquiz").val();2383 var txtpage_number = $("#txtpage_number").val();2384 var qid_intro = $("#qid_intro").val();2385 var subject_id = $(this).attr("subject_id");2386 var test_types = $(this).attr('test_types');2387 var test_board = $(this).attr('test_board');2388 var ids_arr = $(this).attr("ids_arr");2389 var noOfYrs = $("#txtyears").val();2390 var txtpage_number1 = retrieve_cookie('txtpage_number');2391 var txttotalquiz1 = retrieve_cookie('txttotalquiz');2392 if(txtpage_number1!="" && txttotalquiz1!=""){ // incase i refresh, it shud retain the page num2393 var txttotalquiz = txttotalquiz1;2394 var txtpage_number = txtpage_number1;2395 }2396 $(".alert_msg").hide();2397 2398 $('.cmd_prev_quiz').hide();2399 $('.cmd_prev_quiz1').show();2400 var datastring='txtans1='+txtans12401 +'&txtrandom_quiz='+txtrandom_quiz2402 +'&qid_intro='+qid_intro2403 +'&test_types='+test_types2404 +'&test_board='+test_board2405 +'&noOfYrs='+noOfYrs2406 +'&ids_arr='+ids_arr2407 +'&tasks=prevs'2408 +'&subject_id='+subject_id;2409 //alert(txtpage_number)2410 //alert(txttotalquiz)2411 create_cookie('txtpage_number', parseInt(txtpage_number)-1);2412 create_cookie('txttotalquiz', txttotalquiz);2413 if(txtpage_number == 2){2414 $('.cmd_prev_quiz1').hide();2415 }2416 $.ajax({2417 type: "POST",2418 //url : site_urls+"node/store_my_ansa_prev", // for prev2419 url : site_urls+"node/store_my_ansa",2420 data: datastring,2421 timeout: 30000, // 30 second timeout2422 success : function(data){2423 $('.cmd_prev_quiz_i').hide();2424 $('.cmd_prev_quiz_j').hide();2425 if(txtpage_number == 2){2426 $('.cmd_prev_quiz1').hide();2427 }else{2428 if(txtpage_number < txttotalquiz){2429 var txtpage_number1 = parseInt(txtpage_number) - 1;2430 if(txtpage_number1 <= 1) txtpage_number1 = 1;2431 $("#txtpage_number").val(txtpage_number1);2432 $('.cmd_prev_quiz').show();2433 $('.cmd_prev_quiz1').hide();2434 $('.fade_questions').show();2435 $('.cmd_prev_quiz_i').show();2436 $('.cmd_prev_quiz_j').hide();2437 }else{ // if the total question is equal to the page number, hide the prev btn2438 $('.cmd_prev_quiz').hide();2439 $('.cmd_prev_quiz1').show();2440 //$('.cmd_next_quiz2').show();2441 //$(".cmd_sub_answers").click();2442 $('.cmd_prev_quiz_i').show();2443 $('.cmd_prev_quiz_j').hide();2444 }2445 }2446 if(txtpage_number1==undefined){2447 txtpage_number1 = 1;2448 }2449 2450 $('#txtans1').val('');2451 setTimeout(function(){2452 $('.fade_questions').fadeOut('fast');2453 $('.scroll_inner_quiz').fadeIn('fast').html(data);2454 $("#txtpage_number_h").html(txtpage_number1+".");2455 },200);2456 setTimeout(function(){2457 $("html, body").animate({scrollTop:$('.scroll_inner_quiz').offset().top-200}, 300);2458 },700);2459 // clear the cookies bcos im active again2460 create_cookie('txtpage_number', '');2461 create_cookie('txttotalquiz', '');2462 2463 },error : function(data, timeouts){2464 $('.cmd_prev_quiz').show();2465 $('.cmd_prev_quiz1').hide();2466 if(timeouts==="timeout"){2467 alert("Time out, please try again later");2468 }else{2469 $(".err_msg").show().html('<div class="Errormsg">Poor Network Connection!</div>');2470 }2471 }2472 });2473 });2474 $('body').on('click', '.start_main_test', function () {2475 var self = this;2476 $('.tawk_to').hide();2477 $('.started_text_value').val(1);2478 create_cookie('onGoingTest', 1);2479 //resize_me();2480 $('.cmd_trigger').trigger('click');2481 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'});2482 var studid = $(this).attr('studid');2483 var id1 = $(this).attr('id1');2484 var is_new_rec = $(this).attr('is_new_rec');2485 var instructn = $(this).attr('instructn');2486 var set_time = $(this).attr('set_time');2487 var test_types = $(this).attr('test_types');2488 var test_board = $(this).attr('test_board');2489 2490 //var noOfQuest = $(this).attr('noOfQuest');2491 var noOfQuest = $("#txt_no_of_quests").val();2492 var subject_id = $(this).attr('subject_id');2493 var noOfYrs = $("#txtyears").val();2494 var schs = $(this).attr('schs');2495 var ids = $(this).attr('ids');2496 var subjects_caption = $(this).attr('subjects_caption');2497 //var txtrandom_quiz = $("#txtrandom_quiz").val();2498 testStart(studid, id1, is_new_rec, self, instructn, set_time, test_types, test_board, noOfQuest, subject_id, noOfYrs, schs, ids, subjects_caption);2499 //alert('Still in progress.....');2500 });2501 function testStart(studid, id1, is_new_rec, self, instructn, set_time, test_types, test_board, noOfQuest, subject_id, noOfYrs, schs, ids, subjects_caption){2502 //setTimeout(function(){2503 $(".loaders").hide();2504 //$('.subject_instruc').hide();2505 //$('.main_test_page').fadeIn('fast');2506 2507 totalAmount = 0;2508 clearTimeout(timeloop);2509 localStorage.removeItem('countDown');2510 var datastring='id1='+id12511 +'&schs='+schs2512 +'&set_time='+set_time2513 +'&test_types='+test_types2514 +'&test_board='+test_board2515 +'&noOfQuest='+noOfQuest2516 +'&subject_id='+subject_id2517 +'&noOfYrs='+noOfYrs2518 +'&studid='+studid2519 +'&ids='+ids2520 +'&subjects_caption='+subjects_caption2521 //+'&txtrandom_quiz='+txtrandom_quiz2522 +'&instructn='+instructn2523 +'&is_new_rec='+is_new_rec;2524 //alert(datastring);2525 $.ajax({2526 type : "POST",2527 url : site_urls+"node/start_main_quiz",2528 data : datastring,2529 timeout: 30000, // 30 second timeout2530 success : function(data){2531 $("html, body").animate({ scrollTop: 0 }, "fast");2532 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'});2533 $('.subject_instruc').hide();2534 $('.main_test_page').html(data).fadeIn('fast');2535 var reqVal = $('#request').val();2536 var parAmt = parseInt(reqVal);2537 if (timeloop) {2538 clearTimeout(timeloop);2539 }2540 totalAmount = parAmt * 60;2541 $('#request').val(" ");2542 timeSet();2543 2544 setTimeout(function(){2545 $('.fade_questions').fadeOut('fast');2546 },400);2547 },error : function(data, timeouts){2548 if(timeouts==="timeout"){2549 alert("Time out, please try again later");2550 }2551 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'});2552 }2553 });2554 }2555 $('body').on('click', '.blog_pagn a', function (e) {2556 e.preventDefault();2557 var self = $(this);2558 var pageNum = self.attr('data-ci-pagination-page');2559 var isitChecked = $('.quiz_options li input').is(":checked");2560 if(isitChecked == true){2561 var checkedIds = $(".chk:checked").map(function() {2562 return this.value;2563 }).toArray();2564 $('#txtans1').val(checkedIds.join(", "));2565 }2566 var txtans1 = $("#txtans1").val();2567 var txtrandom_quiz = $("#txtrandom_quiz").val();2568 var txttotalquiz = $("#txttotalquiz").val();2569 var txtpage_number = $("#txtpage_number").val();2570 var qid_intro = $("#qid_intro").val();2571 var subject_id = $('.blog_pagn span').attr("subject_id");2572 var test_types = $('.blog_pagn span').attr("test_types");2573 var test_board = $('.blog_pagn span').attr("test_board");2574 var ids_arr = $('.blog_pagn span').attr("ids_arr");2575 var noOfYrs = $('.blog_pagn span').attr("noOfYrs");2576 var actns = $(this).attr("actns");2577 $(".alert_msg").hide();2578 create_cookie('onGoingTest', 1);2579 //alert(actns)2580 2581 $('.fade_questions').show();2582 // $('.cmd_next_quiz').hide();2583 // $('.cmd_next_quiz1').show();2584 //$('.next_prev_btn').removeClass('next_prev_btn').addClass('next_prev_btn1');2585 var datastring='txtans1='+txtans12586 +'&txtrandom_quiz='+txtrandom_quiz2587 +'&qid_intro='+qid_intro2588 +'&test_types='+test_types2589 +'&test_board='+test_board2590 +'&noOfYrs='+noOfYrs2591 +'&ids_arr='+ids_arr2592 +'&tasks='+actns2593 +'&subject_id='+subject_id;2594 //alert(pageNum);2595 //alert(datastring);2596 $.ajax({2597 type: "POST",2598 //url : site_urls+"node/store_my_ansa",2599 url: site_urls+'node/questions/'+pageNum,2600 data: datastring,2601 timeout: 30000, // 30 second timeout2602 success : function(data){2603 var txtpage_number1 = parseInt(pageNum) + 1;2604 // if(pageNum <= 1){2605 // $('.include_class').addClass('next_prev_btn_no_radius');2606 // }2607 if(parseInt(pageNum) < parseInt(txttotalquiz)){2608 $("#txtpage_number").val(txtpage_number1);2609 }else if(parseInt(pageNum) > parseInt(txttotalquiz)){ // if the total question is equal to the page number, show done and submit to database2610 clearThisSession(qid_intro, subject_id, test_board, ids_arr);2611 return false;2612 }2613 2614 $('#txtans1').val('');2615 setTimeout(function(){2616 $('.fade_questions').fadeOut('fast');2617 $('.scroll_inner_quiz').fadeIn('fast').html(data);2618 //$("#txtpage_number_h").html(txtpage_number1+".");2619 $("#txtpage_number_h").html(pageNum+".");2620 },200);2621 setTimeout(function(){2622 $("html, body").animate({scrollTop:$('.scroll_inner_quiz').offset().top-200}, 300);2623 },700);2624 2625 },error : function(data, timeouts){2626 if(timeouts==="timeout"){2627 alert("Time out, please try again later");2628 }else{2629 $(".err_msg").show().html('<div class="Errormsg">Poor Network Connection!</div>');2630 }2631 $('.cmd_next_quiz').show();2632 $('.cmd_next_quiz1').hide();2633 }2634 });2635 });2636 var totalAmount = localStorage.getItem('countDown') || 0,2637 timeloop;2638 if (totalAmount) {2639 timeSet();2640 }2641 function timeSet () {2642 totalAmount--;2643 // Refresh value in localStorage2644 localStorage.setItem('countDown', totalAmount);2645 // If countdown is over, then remove value from storage and clear timeout2646 if (totalAmount < 0 ) {2647 localStorage.removeItem('countDown');2648 totalAmount = 0;2649 clearTimeout(timeloop);2650 //$('.subject_instruc').hide();2651 //$('.main_test_page').show();2652 //$('.quiz_starts').show();2653 //$('.div_success_test_timeout').fadeIn('fast');2654 $('#txt_time_finished').val(0);2655 setTimeout(function(){2656 $("html, body").animate({scrollTop:$('.scroll_inner_quiz').offset().top-240}, 300);2657 $('#cmd_submit_answers_timeout').trigger('click');2658 //alert('sssddd');2659 },400);2660 return;2661 }2662 $('#txt_time_finished').val(totalAmount);2663 var minutes = parseInt(totalAmount/60);2664 var seconds = parseInt(totalAmount%60);2665 if(seconds < 10)2666 seconds = "0"+seconds;2667 if(minutes == 0 && seconds == 5){2668 $('.contd_quiz').trigger('click');2669 }2670 if(minutes <= 0 && seconds <= 59){2671 $('#tminus_1').css('color', 'red');2672 $('#tminus_2').css('color', 'red');2673 }else{2674 $('#tminus_1').css('color', '#5AF');2675 $('#tminus_2').css('color', '#093');2676 }2677 $('#tminus').val(minutes + ":" + seconds);2678 $('#tminus_1').html(minutes + "mins, " + seconds+"secs");2679 $('#tminus_2').html(minutes + "mins, " + seconds+"secs");2680 timeloop = setTimeout(timeSet, 1000);2681 }2682 $("#resets").click(function(){2683 totalAmount = 0;2684 clearTimeout(timeloop);2685 localStorage.removeItem('countDown');2686 });2687 $('body').on('click', '.login_btn_i', function () {2688 $('.div_contents').hide();2689 $('#div_contents, .choose_subjects').hide();2690 $('.div_reg_login').fadeIn('fast');2691 $(this).html('« BACK').removeClass('login_btn_i').addClass('back_to_main');2692 });2693 $('body').on('click', '.back_to_main', function () {2694 $('.div_reg_login').hide();2695 $('.div_contents, .choose_subjects').fadeIn('fast');2696 $('.back_to_main').removeClass('back_to_main').addClass('login_btn').html('<i class="fa fa-lock"></i> Login');2697 $('.back_to_main1').removeClass('login_btn').addClass('back_to_main').html('« BACK');2698 });2699 2700 $('body').on('mousedown', '.create_acct', function () {2701 myMaths1();2702 $('.from_login').hide();2703 $('.from_reg').fadeIn('fast');2704 });2705 $('body').on('mousedown', '.forgot_pass', function () {2706 $('.from_login').hide();2707 $('.from_f_password').fadeIn('fast');2708 });2709 $('body').on('mousedown', '.login_here', function () {2710 $('.from_reg, .from_f_password').hide();2711 $(".alert_msg1").hide();2712 $('.from_login').fadeIn('fast');2713 });2714 $('body').on('click', '.cmd_done', function () {2715 $(".sec_form, .sec_form_resp").hide();2716 $(".alert_msg1").hide();2717 $(".first_form").fadeIn('fast');2718 // direct me to the test to pertake on it2719 });2720 $('body').on('click', '.cmd_done_buy, .cmd_back_lists', function () {2721 window.location = site_urls+"resources/past-questions/";2722 });2723 $('body').on('click', '.cmd_back_lists1', function () {2724 window.location = site_urls+"resources/tutorial-videos/";2725 });2726 $('body').on('click', '.click_link', function () {2727 var sources = $(this).attr('sources');2728 var id1 = $(this).attr('id1');2729 window.location = site_urls+"resources/view/"+sources+"/"+id1+"/";2730 });2731 $('body').on('click', '.cmd_create_acct', function () {2732 var self = this;2733 $(".alert_msg1").hide();2734 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).val("Please wait...");2735 $.ajax({2736 type : "POST",2737 url : site_urls+"node/signup_acct",2738 data: $(".form_acct").serialize(),2739 cache : false,2740 dataType: 'json',2741 timeout: 30000, // 30 second timeout2742 success : function(data){2743 //alert(data.msg)2744 if(data.type=="success"){2745 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("Create Account");2746 $(".first_form").hide();2747 $(".sec_form").fadeIn('slow');2748 $(".alert_msg1").hide();2749 //var names = $("#txtnames").val();2750 var names = data.msg;2751 var firstWord = names.split(' ')[0];2752 $(".php_login, .php_login1, .login_btn_j").hide();2753 $(".java_login1").show().html('<i class="fa fa-user"></i> '+firstWord);2754 $(".java_login2").show();2755 $(".java_login").show();2756 $(".java_login a").html('<i class="fa fa-user"></i> '+firstWord);2757 $(".java_logout, .java_logout1").show();2758 $(".form_acct")[0].reset();2759 $(".java_login_show").show();2760 $(".java_login_show").attr('memid', data.memid);2761 setTimeout(function(){2762 myMaths1();2763 },400);2764 }else{2765 $(".alert_msg1").show().html('<div class="Errormsg">'+data.msg+'</div>').addClass('alert-danger');2766 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("Create Account");2767 }2768 },error : function(data, timeouts){2769 if(timeouts==="timeout"){2770 alert("Time out, please try again later");2771 }else{2772 //$(".alert_msg1").show().html('<div class="Errormsg">Poor Network Connection!</div>').addClass('alert-danger');2773 $(".alert_msg1").show().html('<div class="Errormsg">'+data.msg+'</div>').addClass('alert-danger');2774 }2775 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("Create Account");2776 }2777 });2778 });2779 $('body').on('click', '.cmd_res_pass', function () {2780 var self = this;2781 $(".alert_msg1").hide();2782 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).val("Please wait...");2783 $.ajax({2784 type : "POST",2785 url : site_urls+"node/send_pass_code",2786 data: $(".form_resp").serialize(),2787 cache : false,2788 timeout: 30000, // 30 second timeout2789 success : function(data){2790 if(data=="msg_sent"){2791 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("Reset Password");2792 $(".first_form_resp").hide();2793 $(".sec_form_resp").fadeIn('slow');2794 $(".alert_msg1").hide();2795 $(".form_resp")[0].reset();2796 }else{2797 $(".alert_msg1").show().html('<div class="Errormsg">'+data+'</div>').addClass('alert-danger');2798 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("Reset Password");2799 }2800 },error : function(data, timeouts){2801 if(timeouts==="timeout"){2802 alert("Time out, please try again later");2803 }else{2804 $(".alert_msg1").show().html('<div class="Errormsg">'+data+'</div>').addClass('alert-danger');2805 }2806 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("Reset Password");2807 }2808 });2809 });2810 var unames = retrieve_cookie('unames');2811 var pass1 = retrieve_cookie('pass1');2812 var isitChecked = retrieve_cookie('isitChecked');2813 if(unames!="") $("#txtuser").val(unames); else $("#txtuser").val('');2814 if(pass1!="") $("#txtpass").val(pass1); else $("#txtpass").val('');2815 if(isitChecked!="") $("#rememberme").prop('checked', true); else $("#rememberme").prop('checked', false);2816 $(".cmd_signin").click(function(){2817 var self = this;2818 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).val("Please wait...");2819 $(".alert_msg_login").hide();2820 var txtuser = $("#txtuser").val();2821 var txtpass = $("#txtpass").val();2822 2823 $.ajax({2824 type : "POST",2825 url : site_urls+"node/logmein",2826 data: $(".login_form").serialize(),2827 cache : false,2828 dataType: 'json',2829 timeout: 30000, // 30 second timeout2830 success : function(data){2831 if(data.type=="success"){2832 var isitChecked = $('#rememberme').is(":checked");2833 if(isitChecked == true){2834 create_cookie('unames', txtuser);2835 create_cookie('pass1', txtpass);2836 create_cookie('isitChecked', isitChecked);2837 }else{2838 create_cookie('unames', "");2839 create_cookie('pass1', "");2840 create_cookie('isitChecked', "");2841 }2842 //alert(isitChecked)2843 $(".login_form")[0].reset();2844 $(".php_login, .php_login1, .login_btn_j").hide();2845 $(".java_login1").show().html('<i class="fa fa-user"></i> '+data.msg);2846 $(".java_login2").show();2847 $(".java_login").show();2848 $(".java_login_show").show();2849 $(".java_logout, .java_logout1").show();2850 $(".back_to_main").click();2851 $(".java_login a").html('<i class="fa fa-user"></i> '+data.msg);2852 $(".java_login_show").attr('memid', data.memid);2853 2854 setTimeout(function(){2855 $(".alert_msg_login").hide();2856 },700);2857 }else{2858 $(".alert_msg_login").show().html('<div class="Errormsg">'+data.msg+'</div>').addClass('alert-danger');2859 }2860 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("LOGIN");2861 },error : function(data, timeouts){2862 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("LOGIN");2863 if(timeouts==="timeout"){2864 alert("Time out, please try again later");2865 }else{2866 $(".alert_msg_login").show().html('<div class="Errormsg">Poor Network Connection!</div>').addClass('alert-danger');2867 }2868 }2869 });2870 });2871 $(".cmd_res_pass1").click(function(){2872 var self = this;2873 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).val("Please wait...");2874 $(".alert_msg_res").hide();2875 2876 $.ajax({2877 type : "POST",2878 url : site_urls+"node/logmein_reset",2879 data: $(".reset_form").serialize(),2880 cache : false,2881 timeout: 30000, // 30 second timeout2882 success : function(data){2883 if(data=="success"){2884 $(".reset_form")[0].reset();2885 setTimeout(function(){2886 $(".alert_msg_res").hide();2887 },700);2888 $(".from_reset").hide();2889 $(".from_reset1").fadeIn('fast');2890 }else{2891 $(".alert_msg_res").show().html('<div class="Errormsg">'+data+'</div>').addClass('alert-danger');2892 }2893 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("RESET PASSWORD");2894 },error : function(data, timeouts){2895 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("RESET PASSWORD");2896 if(timeouts==="timeout"){2897 alert("Time out, please try again later");2898 }else{2899 $(".alert_msg_res").show().html('<div class="Errormsg">Poor Network Connection!</div>').addClass('alert-danger');2900 }2901 }2902 });2903 });2904 $(".send_message").click(function(){2905 var self = this;2906 $(self).attr('disabled', true).css({'opacity': '0.6', 'color': '#ccc'}).val("Please wait...");2907 $(".alert_msg_contact").hide();2908 2909 $.ajax({2910 type : "POST",2911 url : site_urls+"node/send_contact_msg",2912 data: $(".contact_msg").serialize(),2913 cache : false,2914 timeout: 30000, // 30 second timeout2915 success : function(data){2916 if(data=="msg_sent"){2917 $(".contact_msg")[0].reset();2918 $(".alert_msg_contact").show().html('<div class="Errormsg"><b>Your message has been sent!</b></div>').removeClass('alert-danger').addClass('alert-success');2919 2920 setTimeout(function(){2921 $(".alert_msg_contact").hide();2922 },1500);2923 }else{2924 $(".alert_msg_contact").show().html('<div class="Errormsg">'+data+'</div>').addClass('alert-danger');2925 }2926 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("SEND MESSAGE");2927 },error : function(data, timeouts){2928 $(self).removeAttr('disabled').css({'opacity': '1', 'color': '#fff'}).val("SEND MESSAGE");2929 if(timeouts==="timeout"){2930 alert("Time out, please try again later");2931 }else{2932 $(".alert_msg_contact").show().html('<div class="Errormsg">Poor Network Connection!</div>').addClass('alert-danger');2933 }2934 }2935 });2936 });2937 /**2938 * Disable right-click of mouse, F12 key, and save key combinations on page2939 * By Arthur Gareginyan (arthurgareginyan@gmail.com)2940 * For full source code, visit https://mycyberuniverse.com2941 */2942 window.onload = function() {2943 document.addEventListener("contextmenu", function(e){2944 e.preventDefault();2945 }, false);2946 document.addEventListener("keydown", function(e) {2947 //document.onkeydown = function(e) {2948 // "I" key2949 if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {2950 disabledEvent(e);2951 }2952 // "J" key2953 if (e.ctrlKey && e.shiftKey && e.keyCode == 74) {2954 disabledEvent(e);2955 }2956 // "S" key + macOS2957 if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {2958 disabledEvent(e);2959 }2960 // "U" key2961 if (e.ctrlKey && e.keyCode == 85) {2962 disabledEvent(e);2963 }2964 // "F12" key2965 if (event.keyCode == 123) {2966 disabledEvent(e);2967 }2968 }, false);2969 function disabledEvent(e){2970 if (e.stopPropagation){2971 e.stopPropagation();2972 } else if (window.event){2973 window.event.cancelBubble = true;2974 }2975 e.preventDefault();2976 return false;2977 }2978 };2979 2980 2981 2982 // $(function() {2983 // var f = function() {2984 // $(this).next().text($(this).is(':checked') ? ' ON' : ' OFF');2985 // };2986 // $('input').change(f).trigger('change');2987 // });2988 $('body').on('change', '#rememberme', function () {2989 $(this).next().text($(this).is(':checked') ? ' ON' : ' OFF');2990 });2991 setTimeout(function(){2992 //$('#rememberme').trigger('change');2993 $("#rememberme").prop('checked', true);2994 },300);2995 function myMaths1(){2996 var rndnum=Math.random()*(9-1)+1;2997 var rndnum1=Math.random()*(9-1)+1;2998 rndnum=Math.ceil(rndnum);2999 rndnum1=Math.ceil(rndnum1);3000 document.getElementById('txtsum1').value = rndnum+rndnum1;3001 $("#txtmaths").attr("placeholder", 'What is '+rndnum+'+'+rndnum1+'=?');3002}3003})3004})(jq);3005function create_cookie(name, value, days2expire, path) {3006 var date = new Date();3007 date.setTime(date.getTime() + (days2expire * 24 * 60 * 60 * 1000));3008 var expires = date.toUTCString();3009 document.cookie = name + '=' + value + ';' +3010 'expires=' + expires + ';' +3011 'path=' + path + ';';3012}3013function retrieve_cookie(name) {3014 var cookie_value = "",3015 current_cookie = "",3016 name_expr = name + "=",3017 all_cookies = document.cookie.split(';'),3018 n = all_cookies.length;3019 ...
Cookies.js
Source:Cookies.js
1function create_cookie(key,value,Expflage)2{3 4 if(Expflage)5 { var dat = new Date();6 dat.setMonth(dat.getMonth()+1);7 document.cookie = key+"="+value+"; expires="+dat.toUTCString();8 }9 else document.cookie = key+"="+value;10}11function delete_cookie(key)12{13 var dat = new Date();14 dat.setMonth(dat.getMonth()-3);15 document.cookie = key+"="+"; expires="+dat.toUTCString();16}17function get_all_cookies()18{19 var assArray =[];20 var allCookies = document.cookie.split("; ");21 for(var i=0;i<allCookies.length;++i)22 {23 var ourkey = allCookies[i].split("=")[0];24 var value = allCookies[i].split("=")[1];25 assArray[ourkey] = value;26 }27 return assArray;28}29function get_cookie(key)30{31 var all_cookies = get_all_cookies();32 console.log(all_cookies[key]);33 return all_cookies[key];34}35function del_cookies()36{37 var all_cookies = get_all_cookies();38 for(var i in all_cookies)39 {40 delete_cookie(i);41 }42}43/** */44function save_date()45{46 var value = document.getElementById("username").value;47 console.log(value);48 create_cookie("username",value,1);49 value = document.getElementById("age").value;50 create_cookie("userage",value);51 create_cookie("vis","0",1);52 if(document.getElementsByName("gender")[0].checked)53 {54 create_cookie("gender","1",1);55 56 }57 else if(document.getElementsByName("gender")[1].checked)58 {59 create_cookie("gender","2",1);60 }61 var col = document.getElementById("color").value;62 create_cookie("color",col);63 window.location.href="profile.html";64}...
check-time.js
Source:check-time.js
...12}13function clock_button() {14 window.theme_override = false;15 window.theme = lightp();16 create_cookie('theme_override', window.theme_override, 7);17 create_cookie('theme', window.theme, 7);18 check_time();19}20function toggle_button() {21 window.theme_override = true;22 window.theme = !window.theme;23 create_cookie('theme_override', window.theme_override, 7);24 create_cookie('theme', window.theme, 7);25 check_time();26}27function day_button() {28 // reset override if its already active29 window.theme_override = !(window.theme && window.theme_override);30 window.theme = true;31 create_cookie('theme_override', window.theme_override, 7);32 create_cookie('theme', window.theme, 7);33 check_time();34}35function night_button() {36 window.theme_override = !(!window.theme && window.theme_override);37 window.theme = false;38 create_cookie('theme_override', window.theme_override, 7);39 create_cookie('theme', window.theme, 7);40 check_time();41}42var cookie1 = read_cookie('theme_override')==null ? false : read_cookie('theme_override') == "true";43var cookie2 = read_cookie('theme')==null ? false : read_cookie('theme') == "true";44window.theme_override = cookie1;45window.theme = window.theme_override ? cookie2 : lightp()...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3 if (err) return console.log(err);4 console.log(data);5});6var wpt = require('webpagetest');7var test = new wpt('www.webpagetest.org');8 if (err) return console.log(err);9 console.log(data);10});
Using AI Code Generation
1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3api.createCookie('www.webpagetest.org', 'cookie1', 'value1', function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var api = new wpt('www.webpagetest.org');12api.createScript('document.write("Hello World");', function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var wpt = require('webpagetest');20var api = new wpt('www.webpagetest.org');21api.deleteScript('scriptId', function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var api = new wpt('www.webpagetest.org
Using AI Code Generation
1var wpt = require('./wpt.js');2var wpt = new wpt('API_KEY');3 if (err) {4 console.log(err);5 }6 console.log(data);7});8var wpt = require('./wpt.js');9var wpt = new wpt('API_KEY');10 if (err) {11 console.log(err);12 }13 console.log(data);14});15var wpt = require('./wpt.js');16var wpt = new wpt('API_KEY');17 if (err) {18 console.log(err);19 }20 console.log(data);21});22var wpt = require('./wpt.js');23var wpt = new wpt('API_KEY');24wpt.get_locations(function(err, data) {25 if (err) {26 console.log(err);27 }28 console.log(data);29});30var wpt = require('./wpt.js');31var wpt = new wpt('API_KEY');32wpt.get_location('Dulles:Chrome', function(err, data) {33 if (err) {34 console.log(err);35 }36 console.log(data);37});38var wpt = require('./wpt.js');39var wpt = new wpt('API_KEY');40wpt.get_tests(function
Using AI Code Generation
1var wpt = require('wpt');2 if(err){3 console.log(err);4 }5 else{6 console.log(data);7 }8});9var wpt = require('wpt');10 if(err){11 console.log(err);12 }13 else{14 console.log(data);15 }16});17var wpt = require('wpt');18 if(err){19 console.log(err);20 }21 else{22 console.log(data);23 }24});25var wpt = require('wpt');26 if(err){27 console.log(err);28 }29 else{30 console.log(data);31 }32});33var wpt = require('wpt');34 if(err){35 console.log(err);36 }37 else{38 console.log(data);39 }40});41var wpt = require('wpt');42 if(err){43 console.log(err);44 }45 else{46 console.log(data);47 }48});49var wpt = require('wpt');
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.b5f5e5c0f8c5d5c5e5b5f5e5c5b5f5e5');3wpt.createCookie('www.webpagetest.org', 'foo', 'bar', function(err, data) {4 console.log(data);5});6var wpt = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org', 'A.b5f5e5c0f8c5d5c5e5b5f5e5c5b5f5e5');8wpt.createCookie('www.webpagetest.org', 'foo', 'bar', function(err, data) {9 console.log(data);10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org', 'A.b5f5e5c0f8c5d5c5e5b5f5e5c5b5f5e5');13wpt.createCookie('www.webpagetest.org', 'foo', 'bar', function(err, data) {14 console.log(data);15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org', 'A.b5f5e5c0f8c5d5c5e5b5f5e5c5b5f5e5');18wpt.createCookie('www.webpagetest.org', 'foo', 'bar', function(err, data) {19 console.log(data);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org', 'A.b5f5e5c0f8c5d5c5e5b5f5e5c5b5f5e5');23wpt.createCookie('www.webpagetest.org', 'foo',
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!