///////////////////////////////// GRIDS ////////////////////////////// var prevID, prevIDtd, mobileUser var cssColor="Green"; var inputButtonTheme = "green"; // CUSTOM ERROR HANDLING WILL HAPPEN HERE window.onerror = function() { console.log("Error caught, FORCING the script to work...."); $(".myLoadingDiv").fadeOut(300); }; $(window).load(function() { if($("testlabel").length){ $("testlabel").replaceWith(" - This page comes up only in TEST mode"); }; $(".mrEdit").wrap("
").addClass("form-control") if( typeof testMode !== 'undefined' && testMode == true){ $(".float-right").append("
TEST MODE
") } if ($(".panel").length > 1){ $(".panel:not(:last)").addClass("marginBottom") } $(".panel:last").addClass("lastPanel") //$(".panel:eq(0),.panel:eq(1)").parent().removeClass("col-sm-12").addClass("col-sm-8") // getting location of the project var Image_Location = window.location.hostname if (Image_Location == ""){ Image_Location = "file:///k:/_USEFUL STUFF/Working flow/_Template development/" jsProj = "" }else{Image_Location = "https://" + Image_Location + "/SPSSMR/ImageCache/ImageCache.aspx?Project="} //DEBUGGER!!!!!!!!!!! $("debugger").hide() $(".sidebar-content").append($("debugger").html()) // Interviewer CSS $("int").addClass("deInt") /*******************************/ $(".mrQuestionTable").children().addClass("clickable") $(".mrQuestionTable").addClass("table table-hover").css({"display":"table","width": "auto"}) $(".mrQuestionText").eq(0).addClass("QuestionText") $("span.mrQuestionTable").each(function(){$(this).replaceWith( "
"+$(this).html()+"
" );}); $("span.clickable").each(function(){$(this).replaceWith( "
"+$(this).html()+"
" );}); $(".categories").parent().contents().unwrap() // INITIALIZING CUSTOM RADIO AND CHECKBOXES $(document).ready(function(){ $('input[type=radio],input[type=checkbox]').each(function(){ if ($(this).css("visibility") !== "hidden"){ $(this).iCheck({ checkboxClass: 'icheckbox_square-'+inputButtonTheme, radioClass: 'iradio_square-'+inputButtonTheme }); } }); }); $(".content_container").addClass("container").css("margin","0 auto") if ($(".mrPrev").length) $(".nav").append("") if ($(".mrNext").length) $(".nav").append("") $(".mrNext2,.mrPrev2").click(function(){ $("."+$(this).attr("origi")).click() }); var rownum = 0 var tempid = null $('input[type="radio"]').on('ifChecked', function(event){ if ($(this).closest("td").length){ tempid = $(this).closest("td").attr("id").split(".") rownum = tempid[2] $(this).closest(".qst").find("[id$='."+rownum+"'] input[type='checkbox']").iCheck('uncheck'); } else { $(this).closest(".qst").find("input[type='checkbox']").iCheck('uncheck'); } }); $('input[type="checkbox"]').on('ifChecked', function(event){ if ($(this).closest("td").length){ tempid = $(this).closest("td").attr("id").split(".") rownum = tempid[2] $(this).closest(".qst").find("[id$='."+rownum+"'] input[type='radio']").iCheck('uncheck'); } else { $(this).closest(".qst").find("input[type='radio']").iCheck('uncheck'); } }); $( "input[type='radio']" ).parent().parent().hover( function() { $( this ).children().next().addClass("hover") }, function() { $( this ).children().next().removeClass("hover") } ); ////////////////////////////////////////////////////////////////////// $("qstname").each(function(){ $(this).parent().attr("id",$(this).text()) $(this).remove() }); if ($("select").length){ $("option").each(function(){ $(this).attr("catID", $(this).parent().attr("name") + $(this).attr("value")) }) } ////////////////////////////////////////////////////////////////////// if( typeof totalStat !== 'undefined'){ var i,j,k,pos for (i=0;i
") }else if(i>currentStat-1){ $(".statusBar").append("
") }else if(i==currentStat-1){ $(".statusBar").append("
") } } $(".actSt").append("") } /* Color Schemes */ $(".mrNext2,.mrPrev2,.mrStop2,.actSt").addClass("gradient" + cssColor) // FANCY ERROR if ($(".mrErrorText").length) { $(".modal-title").html($(".mrErrorText").eq(0).html()) $('.errormodal') .modal('show'); } //SYNTAX ERRORS if ($(".errorContainer").length){ $(".syntaxmodal .modal-body").append($(".errorContainer")) $(".float-right button").after("") $(".showError").addClass("shake") $(".showError").click(function(){ $(".syntaxmodal").modal("show") }); } //REMOVING USELESS ITEMS $(".mrErrorText").prev().remove() $(".qstBody").prevAll("br").remove() $(".mrErrorText").next("br").hide() $(".mrErrorText").hide() //*** HIGHLIGHTING ERRORS --> FIELDS var AfterError $(".qstBody .mrErrorText").each(function(){ AfterError = $(this).next().next() if (AfterError.find(".mrEdit").not(".mrOtherEdit").not("[name*='Other']").length){ AfterError.find(".mrEdit").closest(".form-group").addClass("has-error") return false; } if ($(this).next().hasClass("form-group")){ $(this).next().addClass("has-error") return false; } if (AfterError.find(".mrSingle,.mrMultiple").not("[id$='X0']").length){ AfterError.find(".mrSingle,.mrMultiple").closest("tr").addClass("fieldError error") return false; } if (AfterError.children().attr("class")=="mrSingle"){ $("[name='"+AfterError.children().attr("name")+"']").parent().parent().addClass("fieldError error") } if (AfterError.closest(".mrQuestionTable").length){ $("[name='"+AfterError.children().attr("name")+"']").parent().parent().addClass("fieldError error") } }); $(".mrEdit").closest("td").addClass("inputBoxTD") // COLOR THEME $("head").append(""); //$(".mrGridQuestionText").parent().addClass("firstRowGrid"); if ($(".qst tr:first-child").find(".mrGridQuestionText .mrQuestionText").text() != ""){ $(".qst tr:first-child:not(:has(.mrEdit))").addClass("firstRowGrid"); $(".qst tr:first-child:not(:has(.mrEdit))").closest("table").addClass("unstackable") } /******* MAKING THINGS MORE MOBILE FRIENDLY *******/ var cccnt = 0; var grTxt; $(".mrQuestionTable .mrGridQuestionText .mrQuestionText").each(function(){ cccnt ++; grTxt = $(this).html() $(".mrQuestionTable td.mrGridCategoryText").each(function(){ $(this).addClass("mobHelp") $(this).parent().find("td").eq(cccnt).append("" + grTxt.replace("
"," - ") + "
") }); }); $("input[type=checkbox],input[type=radio]").closest("td").css("text-align","left").addClass("dataCell") $("input[type=checkbox],input[type=radio]").closest("td").click(function(){ $(this).find("input[type=checkbox],input[type=radio]").iCheck("toggle") }); $(".mrQuestionText").parent().not("label").addClass("gridCatText"); $(".gridCatText").eq(1).prevAll("br").remove() /* NEW ---- Before ---- FUNCTIONS */ var qstName,addBefore $("before").each(function(){ addBefore = $(this).html() qstName = $(this).attr("class") $(".mrEdit:visible").each(function(){ if ($(this).attr("name").indexOf(qstName) != -1) { $(this).closest(".form-group").addClass("input-group") $(this).before(""+addBefore+"") } }); }); /* NEW ---- AFTER ---- FUNCTIONS */ var qstName,addAfter $("after").each(function(){ addAfter = $(this).html() qstName = $(this).attr("class") $(".mrEdit:visible").each(function(){ if ($(this).attr("name").indexOf(qstName) != -1) { $(this).closest(".form-group").addClass("input-group") $(this).after(""+addAfter+"") } }); }); //SETTING THE CATI QUESTION $(".CatiLayout .containItem span").hide() $(".CatiLayout").removeClass("templateUL") $("typ").each(function(){ if ($(this).text() == "long"){ qst($(this).attr("id")).find(".mrEdit:not('[name*=\"OtherResp\"],[name*=\"otherResp\"]')").attr({"type":"number","step":"any"}) } }); $(".mrQuestionTable .mrOtherEdit").closest("div").prev("label").remove() $(".mrOtherEdit").keyup(function(){ if ($(this).val() == ""){ $(this).closest(".containItem,td").find("input").iCheck("uncheck") }else{ $(this).closest(".containItem,td").find("input").iCheck("check") } }); //fixes - 2018.03.26. $(".form-group").prev().find(".mrOtherText").remove() $(".mrQuestionTable .inputBoxTD label").hide() }); // CUSTOM KEY FUNCTIONS var gridTextArr,cntGrid $(window).load(function() { $(document).ready(function () { $("#sidebar").mCustomScrollbar({ theme: "minimal" }); $('#dismiss, .overlay').on('click', function () { $('#sidebar').removeClass('active'); $('.overlay').fadeOut(); }); $('#sidebarCollapse').on('click', function () { $('#sidebar').addClass('active'); $('.overlay').fadeIn(); $('.collapse.in').toggleClass('in'); $('a[aria-expanded=true]').attr('aria-expanded', 'false'); }); }); if (isIE () && isIE () < 9) { //lower versions - as IE s* sometimes } else { window.addEventListener('orientationchange', doOnOrientationChange); } $(window).keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); if (!$("textarea").length) $(".mrNext").click() return false; } }); $("input").keydown(function (e) { var key = e.which ? e.which : event.keyCode; if (key == 110 || key == 188) { var value = $(this).val(); if (!isNaN(value)) { e.preventDefault(); $(this).val(value + "."); } } }); $(".mrNext,.mrPrev").click(function(){ $(".navButtons").fadeOut() }); if(typeof keycodeSupport != 'undefined'){ var lastTXT; $(".mrEdit:not('.mrOtherEdit')").eq(0).focus() $(".mrSingleText").each(function(){ $(this).append(" [" + Number($(".mrSingleText").index(this)+1) + "]") }) $(".mrMultipleText").each(function(){ $(this).append(" [" + Number($(".mrMultipleText").index(this)+1) + "]") }) $("body").keyup(function (e) { if ($(e.target).hasClass('mrEdit')) { return false; } var key = e.which ? e.which : event.keyCode; if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) { var value = e.key || String.fromCharCode(e.keyCode); if (value > 0){ $("input[type=radio]").eq(value-1).iCheck("toggle") $("input[type=checkbox]").eq(value-1).iCheck("toggle") } } }); } $('[data-toggle="tooltip"]').tooltip(); }); $(window).load(function(){ $(".myLoadingDiv").fadeOut(300); }); function replaceASCII(variable){ variable = variable.replace(/&/g, '&'); console.log(variable) } function openNav() { if (document.getElementById("debugside").style.width == "250px"){ document.getElementById("debugside").style.width = "0"; document.getElementById("full").style.marginLeft = "0"; }else{ document.getElementById("debugside").style.width = "250px"; document.getElementById("full").style.marginLeft = "250px"; } } function closeNav() { document.getElementById("debugside").style.width = "0"; document.getElementById("full").style.marginLeft = "0"; } function qst(QuestionNameInDimensions){ return $(".qst[id$='Q"+QuestionNameInDimensions.replace("_","__")+"']") } function cat(catNameInDImensions){ return $("[name$='"+catNameInDImensions.replace(/_/g, '__')+"']") } function doOnOrientationChange() { try { //if (qst("Q1").length){ $("body").removeClass("respbody") switch(window.orientation) { case -90: case 90: //$(".turnOverlay").hide() break; case 0: case 180: //$(".turnOverlay").remove() //$("body").append('
For this trend exercise please turn your device to landscape orientation to continue. (Please check if orientation change is switched on, on your device.)

') //$(".turnOverlay").show() break; } //} } catch(err) { //document.getElementById("bo").innerHTML = err.message; alert(err.message) } } // function containsAny(qst,elements){ var e,i,contains; e = elements.split("/"); for (i = 0; i < e.length; i++) { if (qst.find("[name$='" + e[i] + "']").prop("checked") == true){ return true } } return false } function setScreenWidth(width){ $(".statusBar,.content_container,.nav,.row-fluid,.statusContainer").css("max-width",width) } function MakeLastLine_Exclusive(){ $("table tr:last input").on("ifChecked",function(){ var currTD = $(this).closest("td") var currColArr = currTD.attr("id").split(".") var currColStr = currColArr[0] + "." + currColArr[1] + "." $("[id*='"+currColStr+"']").not(currTD).find("input").iCheck("uncheck") }); $("table tr:not(:last-child) input").on("ifChecked",function(){ var currTD = $(this).closest("td") var currColArr = currTD.attr("id").split(".") var currColStr = currColArr[0] + "." + currColArr[1] + "." $("tr:last [id*='"+currColStr+"']").find("input").iCheck("uncheck") }); } ////////////////////////////////////// //CUSTOM FUNCTION LIBRARY ////////////////////////////////////// jQuery.fn.extend({ containsAny: function (elements) { var e,i,contains; e = elements.split(","); for (i = 0; i < e.length; i++) { if ($(this).find("[name$='" + e[i] + "']").length){ if ($(this).find("[name$='" + e[i] + "']").prop("checked") == true){ return true } }else{ //RADIO if ($(this).find("[value$='" + e[i] + "']").prop("tagName") == "INPUT"){ if ($(this).find("[value$='" + e[i] + "']").prop("checked") == true){ return true } } //DROPDOWN if ($(this).find("[value$='" + e[i] + "']").prop("tagName") == "OPTION"){ if ($(this).find("[value$='" + e[i] + "']").is(":selected")){ return true } } } } return false }, loopCat: function (category) { return $(this).find("input[name*='_Q"+category+"_']") }, label: function(){ return $("[for='"+$(this).attr("id")+"'").html() }, cwidth: function (width) { $(this).find(".col-sm-12").removeClass("col-sm-12").addClass("col-sm-"+width) }, alignHeight: function(secondelem){ if ($(this).find(".panel-body").height() > secondelem.find(".panel-body").height()){ secondelem.find(".panel-body").height($(this).find(".panel-body").height()) }else{ $(this).find(".panel-body").height(secondelem.find(".panel-body").height()) } }, hideFill: function(){ if ($(this).find(".mrSingle,.mrMultiple").length && !$(this).find(".mrEdit").not(".mrOtherEdit").length){ if ($(this).find(".mrSingle:checked,.mrMultiple:checked").length == 0){ $(this).find(".mrSingle,.mrMultiple").eq(0).iCheck("check") $(this).find(".mrSingle,.mrMultiple").eq(0).addClass("weCheckedIt") } $(this).hide() } if ($(this).find(".mrEdit").not(".mrOtherEdit").length && !$(this).find(".mrSingle,.mrMultiple").length){ $(this).find(".mrEdit").eq(0).val(123456789) $(this).hide() } if ($(this).find(".mrEdit").not(".mrOtherEdit").length && $(this).find(".mrSingle,.mrMultiple").length){ $(this).find(".mrEdit").eq(0).val(123456789) $(this).hide() } }, showEmpty: function(){ if ($(this).find(".mrSingle,.mrMultiple").length){ if ($(this).find(".weCheckedIt").length > 0){ $(this).find(".weCheckedIt").eq(0).iCheck("uncheck") $(this).find(".weCheckedIt").removeClass("weCheckedIt") } $(this).show() } if ($(this).find(".mrEdit").not(".mrOtherEdit").length){ if ($(this).find(".mrEdit").val() == 123456789) $(this).find(".mrEdit").eq(0).val("") $(this).show() } }, // THIS IS FOR SEPARATE QUESTIONS, DOES NOT WORK IN LOOPS showIfContains: function(mainQuestion,response){ var showHideQuestion = $(this) if(qst(mainQuestion).containsAny(response)){ showHideQuestion.showEmpty() }else{ showHideQuestion.hideFill() } qst(mainQuestion).find("input").on("ifChanged",function(){ if(qst(mainQuestion).containsAny(response)){ showHideQuestion.showEmpty() }else{ showHideQuestion.hideFill() } }) }, // THIS IS FOR SEPARATE QUESTIONS, DOES NOT WORK IN LOOPS hideIfContains: function(mainQuestion,response){ var showHideQuestion = $(this) if(!qst(mainQuestion).containsAny(response)){ showHideQuestion.hideFill() }else{ showHideQuestion.showEmpty() } qst(mainQuestion).find("input").on("ifChanged",function(){ if(qst(mainQuestion).containsAny(response)){ showHideQuestion.hideFill() }else{ showHideQuestion.showEmpty() } }) }, showIfCheckedGrid: function(mainQuestion,response){ } }); function isIE () { var myNav = navigator.userAgent.toLowerCase(); return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false; alert(myNav) }