var isiOS = (/iPad|iPhone|iPod/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream; var isiPad = isiOS && !/iPhone|iPod/i.test(navigator.userAgent); var appGlobalVarsObject = undefined; iframeScrollFix(); CheckSuccCallBackValidate(); function CheckSuccCallBackValidate() { var returnValue = false; var pervsid = eval(callParent('hdnpsid')); if (typeof pervsid != "undefined" && pervsid != "") { getSession("nsessionid", function (data) { if (data.d != undefined && data.d != pervsid) { var cllMainPage = callParentNew("", "getParent"); cllMainPage.location.href = "../aspx/mainnew.aspx"; returnValue = true; } }); } return returnValue; } function SuccCallBackValidate(result) { if (typeof result != "undefined" && result == "Duplicate session") { CheckSuccCallBackValidate(); return true; } return false; } try { var mainPageUrl = ""; var isMainPage = true; var linkHref = window.location.href; if (!callParentNew("isDWB")){ if (linkHref.toLowerCase().indexOf("/aspx/tstruct.aspx") != -1 || linkHref.toLowerCase().indexOf("/aspx/iview.aspx") != -1 || linkHref.toLowerCase().indexOf("/aspx/ivtoivload.aspx") != -1 || linkHref.toLowerCase().indexOf("/aspx/ivtstload.aspx") != -1) { var parentPage = callParentNew("", "getParent"); if (parentPage != undefined && parentPage.document != undefined) mainPageUrl = parentPage.document.URL; if (mainPageUrl == undefined || mainPageUrl == "" || mainPageUrl.toLowerCase().indexOf("/aspx/mainnew.aspx") == -1) { isMainPage = false; mainPageUrl = GetMainPageUrl(); } if (!isMainPage && mainPageUrl.toLowerCase().indexOf("/aspx/mainnew.aspx") > -1) { LoadMainPage(mainPageUrl, linkHref); } } } } catch (ex) { console.warn("Error in GetMainPageUrl call : " + ex.message); } function LoadMainPage(mainPageUrl, linkHref) { try { //local storage for new tab pageload is not used since it is loading duplicate pages when multiple new tabs are opened simultaneously. var useLocalStorage = false; if (useLocalStorage && typeof (Storage) !== "undefined") { if (localStorage["PageToLoad_" + projName] == undefined || localStorage["PageToLoad_" + projName] == "") localStorage["PageToLoad_" + projName] = linkHref; else localStorage["PageToLoad_" + projName] = localStorage["PageToLoad_" + projName] + "♠" + linkHref; mainPageUrl += "#url=local"; } else { SetSession({ key: "PageToLoad", val: linkHref, appendVal: true, async: true, delimiter: "♠", cb: function (data) { mainPageUrl += "#url=sess"; window.location.href = mainPageUrl; } }) } } catch (ex) { console.warn("Error in LoadMainPage call : " + ex.message); } } function GetMainPageUrl() { var mainPageUrl = ""; try { var useLocalStorage = false; if (useLocalStorage && typeof (Storage) !== "undefined") { mainPageUrl = localStorage["MainPageUrl_" + projName]; } else { var appUrl = window.location.href; if (appUrl.indexOf("/aspx/") !== -1) { appUrl = appUrl.substring(0, appUrl.indexOf("/aspx/") + 6); mainPageUrl = appUrl + "Mainnew.aspx"; } } } catch (ex) { console.warn("Error in GetMainPageUrl call : " + ex.message); } return mainPageUrl; } function ClearRedisKeys(rsKeys) { var clearrsKeys = rsKeys.split("*"); var settings = redisNodeApiSettings(); settings.url = eval(callParent('nodeApi')) + "clearkeys"; settings.data.rKey = JSON.stringify(clearrsKeys); //keys to clear settings.data.rUtl = eval(callParent('redisUtl')); //reddis utl $.ajax(settings).done(function (response) { if (response.status == true) { } }); } function PeriodicRefreshCache() { var settings = redisNodeApiSettings(); settings.url = eval(callParent('nodeApi')) + "periodicrefresh"; settings.data.utl = eval(callParent('utl')); settings.data.rUtl = eval(callParent('redisUtl')); $.ajax(settings).done(function (response) { if (response.status == true) { } }); } var redisNodeApiSettings = function () { return { "async": true, "crossDomain": true, "method": "POST", "headers": { "content-type": "application/x-www-form-urlencoded" }, "data": {} } } var initReadyComplete = false; function commonReadyTasks() { if (!initReadyComplete) { if (typeof appGlobalVarsObject == "undefined") { appGlobalVarsObject = callParentNew("appGlobalVarsObject"); } closeParentFrame(); ShowDimmer("false"); checkSuccessAxpertMsg(); try { if (window.frameElement.id == "middle1") { callParentNew("middle1URL=", window.location.href); } } catch (ex) { } resetMainPageUI(); initReadyComplete = true; } else { ShowDimmer("false"); } } /** * @description * @author Prashik + Aarti * @date 2021-06-30 */ function iframeScrollFix(){ let iframeList = [ "iview.aspx", "tstruct.aspx", "ExportNew.aspx", "ImportNew.aspx", "adminconsole.aspx", "WorkflowNew.aspx" ]; if(iframeList.filter(list => window.location.href.toLowerCase().indexOf(`/${list.toLowerCase()}`) > -1).length > 0){ $("html").addClass("iframeScrollFix"); } } /** * @description: common main page reset functionality * @author Prashik * @date 2019-10-18 */ function resetMainPageUI() { try { $(callParentNew(appGlobalVarsObject._CONSTANTS.search.staging.div.substr(1), "id")).val(""); $(callParentNew(appGlobalVarsObject._CONSTANTS.search.staging.divparent.substr(1), "class")).removeClass("open"); } catch (ex) { } try { var homePageBody = $(callParentNew("homePageBody", "class")); if (homePageBody && !homePageBody.hasClass("enableExpandCollapse")) { homePageBody.removeClass("overlay-open"); homePageBody.find(".overlay").fadeOut(); } } catch (ex) { } } function validateFilesize() { var attachement = document.getElementById('filMyFile'); attachement.onchange = function () { var fileType = "File"; var attachmentSizeMB = callParentNew("axAttachmentSize", "axAttachmentSize") == undefined ? 1 : callParentNew("axAttachmentSize", "axAttachmentSize"); var fileUploadLimit = attachmentSizeMB * 1024 * 1024; if ($j("#imgUploadLimit").length) fileType = "Image"; for (var i = 0; i < attachement.files.length; i++) { var file = attachement.files[i]; if (file == null || file.size > fileUploadLimit) { if (file == null) { if (fileType == "File") $("#fileuploadsts").text("[" + eval(callParent('lcm[80]')).replace("{0}", attachmentSizeMB) + "]"); else $("#fileuploadsts").text("[" + eval(callParent('lcm[81]')).replace("{0}", attachmentSizeMB) + "]"); } else { if (fileType == "File") $("#fileuploadsts").text("[" + eval(callParent('lcm[82]')).replace("{0}", attachmentSizeMB) + "]"); else $("#fileuploadsts").text("[" + eval(callParent('lcm[83]')).replace("{0}", attachmentSizeMB) + "]"); } ResetFileUploadProperties(); } else { var fileName = file.name; if (fileName.indexOf("+") > -1) { $("#fileuploadsts").text("[FileName should not contain '+' character.]"); ResetFileUploadProperties(); } else if (fileName.indexOf(".") == -1) { $("#fileuploadsts").text(eval(callParent('lcm[362]'))); ResetFileUploadProperties(); } else { if (fileType == "File") $("#fileuploadsts").text("[Click 'Attach' button]"); else $("#fileuploadsts").text("[Click 'Upload' button]"); $("#fileuploadsts").css('color', 'Green'); $(".file-upload.active .file-select .file-select-button").css({ "background": "#3fa46a" }); $(".file-upload.active .file-select").css({ "border-color": "#3fa46a" }); } } } } } function ValidateFileExtension(filename, fileType, CustomList) { try { /** * @description change parameters hook for ValidateFileExtension function * @author Prashik * @date 27/05/2021 * @param {string} filename: name of file * @param {string} fileType: category of file * @param {string[]} CustomList: custom category array * @return {Object{filename, fileType, CustomList} / fileType} */ let paramObj = ax_changeValidateFileExtensionParams(filename, fileType, CustomList); if(typeof paramObj == "object"){ if(typeof paramObj.filename != "undefined"){ filename = paramObj.filename; } if(typeof paramObj.fileType != "undefined"){ fileType = paramObj.fileType; } if(typeof paramObj.CustomList != "undefined"){ CustomList = paramObj.CustomList; } }else if(typeof paramObj == "string"){ fileType = paramObj; } } catch (ex) { } var fileExtensionImage = ['gif', 'png', 'jpg', 'jpeg', 'bmp', 'tiff', 'tif', 'heic', 'jfif']; //var filename = $("#filMyFile").val(); var fileExtension = ['bmp', 'jpg', 'jpeg', 'pjpeg', 'png', 'doc', 'gif', 'docx', 'xml', 'xls', 'ppt', 'pdf', 'txt', 'xlsx', 'pwd', 'tiff', 'tif', 'dib', 'jfif', 'heic', 'xlxs', 'csv', 'html', 'css', 'js', 'htm','eml','msg','pptx']; var ext = filename.split('.').pop().toLowerCase(); if (fileType == "image") { if ($.inArray(ext, fileExtensionImage) == -1) return false; else return true; } if (fileType == "file") { if ($.inArray(ext, fileExtension) == -1) return false; else return true; } if (fileType == "CustomList") { if ($.inArray(ext, CustomList == -1)) return false; else return true; } } function ResetFileUploadProperties() { $("#fileuploadsts").css('color', '#DB2222'); $("#filMyFile")[0].value = ""; $("#noFile")[0].textContent = eval(callParent('lcm[66]')); $(".file-upload.active .file-select .file-select-button").css({ "background": "grey" }); $(".file-upload.active .file-select").css({ "border-color": "grey" }); } function checkSuccessAxpertMsg() { // window.content.localStorage["axpertSuccessMessage"]; var SuccessMsg = window.localStorage.getItem("axpertSuccessMessage"); if (SuccessMsg) { showAlertDialog('success', SuccessMsg) valoutput = window.localStorage.removeItem("axpertSuccessMessage"); } } $(document).click(function (e) { if (document.URL.indexOf("aspx/mainnew.aspx") === -1) { callParentNew("createMobileQRcode(destroy)", "function") } var container = $('#menuContentWrapper', window.parent.document); var btnContainer = $('#hamburgerMenuIcon', window.parent.document); //var themeContainer = $(".panel-control,#customizer", window.parent.document); // if the target of the click isn't the container nor a descendant of the container if (!$(e.target).hasClass('menuName') && !$(e.target).hasClass('hasSubChildIcon') && !$(e.target).hasClass('menuBgIcon') && !$(e.target).hasClass('hasSubChild') && !$(e.target).hasClass('hirarchy') && $(e.target).attr("id") != "menuContentWrapper" && $(e.target).attr("id") != "hamburgerMenuIcon" && $(e.target).parents("#hamburgerMenuIcon").length === 0 && $(e.target).parents("#menuContentWrapper").length === 0 && $(e.target).parents('.mnuPagination').length === 0) { if (btnContainer.hasClass('is-active')) { //container.hide(); btnContainer.find('button').click(); return; } } // if the target of the click isn't the container nor a descendant of the container try { if (window["currentThemeColor"] === undefined) { var themeContainer = $(".panel-control,#customizer", window.parent.document); if (!themeContainer.is(e.target) && themeContainer.has(e.target).length === 0) { if ($('#customizer', window.parent.document).hasClass('panel-open')) { $('#customizer', window.parent.document).removeClass('panel-open'); } }; } else if (window["currentThemeColor"]) { var themeContainer = $(".panel-control,#customizer"); if (!themeContainer.is(e.target) && themeContainer.has(e.target).length === 0) { if ($('#customizer').hasClass('panel-open')) { $('#customizer').removeClass('panel-open'); } }; } } catch (ex) { console.log(ex.message); } }); //disabling backdrop for jquery confirm boxes// function disableBackDrop(task, disESCKey) { if (task == "destroy") { jQuery(document).unbind("keyup.cnfrmPopupKU"); jQuery(document).unbind("keydown.cnfrmPopupKD") return; } jQuery(document).bind("keyup.cnfrmPopupKU", function (event) { }); jQuery(document).bind("keydown.cnfrmPopupKD", function (event) { var elemntsToCheck = 'button[tabindex!="-1"],a[tabindex!="-1"],input[tabindex!="-1"],select[tabindex!="-1"],textarea[tabindex!="-1"]'; if (!event.shiftKey && event.keyCode == 9) { //tab key if ($(document.activeElement)[0] == $(".jconfirm-buttons button:last")[0]) { event.preventDefault() $(".jconfirm-box").find(elemntsToCheck).first().focus(); } } else if (event.shiftKey && event.keyCode == 9) { if ($(document.activeElement)[0] == $(".jconfirm-box").find(elemntsToCheck).first()[0]) { event.preventDefault(); $(".jconfirm-box").find(elemntsToCheck).last().focus(); } } else if (event.keyCode == 27) { event.preventDefault(); if (disESCKey) $(".jconfirm-box .jconfirm-buttons .coldbtn").click(); } }) $(".jconfirm-buttons button").each(function () { var txt = $(this).text(); $(this).prop('title', txt.charAt(0).toUpperCase() + txt.slice(1)) }); $(".jconfirm-buttons .hotbtn").focus(); } function callParent(name, type) { var hirarchy = "window"; try { if (typeof eval(name) === "undefined") { hirarchy = hirarchy + ".parent"; } } catch (ex) { hirarchy = hirarchy + ".parent"; } var maxParentToCheck = 10; var reachedCntPlcHlder = false; for (var i = 0; i < maxParentToCheck; i++) { try { if (!reachedCntPlcHlder && checkForCntPlcHldrFrame(hirarchy)) { reachedCntPlcHlder = true; } else if (reachedCntPlcHlder) { break; return false; } if (type == "id" || type == "class") { var byName = ""; type == "id" ? byName = "Id" : byName = "sByClassName"; if (eval(hirarchy + ".document.getElementBy" + byName + "('" + name + "')") == null) { hirarchy = hirarchy + ".parent"; continue; } else { return hirarchy + ".document"; break; } } else { if (type == 'function') { //var fParams = name.substr(name.indexOf('(') + 1, name.indexOf(')')).slice(0, -1); var fParams = name.substr(name.indexOf('(') + 1, name.lastIndexOf(')')).slice(0, -1); var checkName = name.substr(0, name.indexOf('(')); //tst.substr(tst.indexOf('(') + 1, tst.indexOf(')')).slice(0, -1) } else { checkName = name; } if (typeof eval(hirarchy + "." + checkName) == 'undefined') { hirarchy = hirarchy + ".parent"; continue; } else { if (type == 'function') { return fParams == "" ? hirarchy + "." + checkName + "()" : hirarchy + "." + checkName + "('" + fParams + "')"; } else { return hirarchy + "." + name; } } } } catch (ex) { hirarchy = hirarchy + ".parent"; continue; //console.log(ex.message); } } } function checkForCntPlcHldrFrame(hirarchy) { return eval(hirarchy + ".leftMenuWrapper") != undefined ? true : false; } //Author - ManiKanta //changes //if type=id,class then instead of hirarchy elem will be returned ===> $("#mani",callParentNew("mani","id")) -> $(callParentNew("mani","id")); //to set the value to a variable need to call as callParentNew("varName=","value"); first parameter need to end with '=' //@usage //-->@function<-- type needs to be function ==> callParentNew("funcNam(withParams)","function") ==>@returns the executed value of the function //-->@elem/class<-- type need to be class ==> callParentNew("className","class") ==>@returns the *JAVASCRIPT* object //-->@elem/id<-- type need to be id ==> callParentNew("ID","id") ==>@returns the *JAVASCRIPT* object **To user both and class as JQUERY object need to call as $(callParentNew("idClassName","id/class")); //-->@variable<-- need to pass type ==> callParentNew("variableName") ==>@returns value of the variable function callParentNew(name = "", type) { var hirarchy = window; //verifying if name ends with equalto let isAssigningValue = false; name = name.trim(); if (name.substr(name.length - 1) === "=") { name = name.slice(0, -1); name = name.trim(); isAssigningValue = true; } try { if (typeof window[name] === "undefined") { hirarchy = window.parent; } } catch (ex) { hirarchy = window.parent; } var maxParentToCheck = 10; var reachedCntPlcHlder = false; for (var i = 0; i < maxParentToCheck; i++) { try { if (!reachedCntPlcHlder && checkForCntPlcHldrFrameNew(hirarchy)) { reachedCntPlcHlder = true; } else if (reachedCntPlcHlder) { break; return false; } if (type == "id" || type == "class") { var byName = type == "id" ? "ById" : "sByClassName"; var elem = hirarchy.document["getElement" + byName](name); if (elem == null) { hirarchy = hirarchy.parent; continue; } else { return elem; break; } } else { if (type == 'function') { //var fParams = name.substr(name.indexOf('(') + 1, name.last(')')).slice(0, -1); var fParams = name.substr(name.indexOf('(') + 1, name.lastIndexOf(')')).slice(0, -1); var checkName = name.substr(0, name.indexOf('(')); //tst.substr(tst.indexOf('(') + 1, tst.indexOf(')')).slice(0, -1) } else if (type == 'getParent') { checkName = name || 'leftMenuWrapper'; } else { checkName = name; } if (typeof hirarchy[checkName] === "undefined") { hirarchy = hirarchy.parent; continue; } else { if (type == 'function') { return hirarchy[checkName].apply(this, fParams.split(','));//This = > presetn context } else { if (type === 'getParent') { return hirarchy; } if (isAssigningValue) { hirarchy[name] = type; return true; } return hirarchy[name]; } } } } catch (ex) { hirarchy = hirarchy.parent; continue; //console.log(ex.message); } } } function checkForCntPlcHldrFrameNew(hirarchy) { return hirarchy.leftMenuWrapper != undefined ? true : false; } function chooseFileUpload(event) { if (event.keyCode == 13) $('#filMyFile').click(); }; function valSessByApi(response) { //if (response.statusCode == "401") // parent.location.href = "sess.aspx"; if ((response.statusCode === 401 && response.errMsg.toLowerCase() == "not a valid session") || response.statusCode === 403) { //for 403 access forbidden will come parent.location.href = "sess.aspx"; } } function closeRemodalPopupOnEsc() { if ($j("#popupIframeRemodal", parent.document).attr("src") != undefined) { $j(document).keyup(function (e) { if (e.keyCode === 27) { $j('.remodal-close', parent.document).click(); } }); } } function IFrameModalDialogTabEvents(inputFirst) { var elemntsToCheck = 'button[tabindex!="-1"],a[tabindex!="-1"],input[tabindex!="-1"],select[tabindex!="-1"],radio[tabindex!="-1"]'; var inputs = $('#form1').find(elemntsToCheck).filter(':visible').not(':disabled'); firstInput = inputs.first(); lastInput = inputs.last(); if (inputFirst != "") $("." + inputFirst).addClass("firstFocusable"); else firstInput.addClass("firstFocusable"); lastInput.addClass("lastFocusable"); $(".firstFocusable").focus(); $(".lastFocusable").on('keydown.tabRot', function (e) { if ((e.which === 9 && !e.shiftKey)) { e.preventDefault(); $(".firstFocusable").focus(); } }); $(".firstFocusable").on('keydown.tabRot', function (e) { if ((e.which === 9 && e.shiftKey)) { e.preventDefault(); $(".lastFocusable").focus(); } }); $('.file-select').on("keydown", function (event) { if (event.which == 13) { $('#filMyFile').click(); } }) } //------------- //To display an IFrame/HTML content in a Bootstrap modal dialog //parameters //------------- //header: header of the dialog //modalType: modal size - large(lg), medium(md), small(sm), extra small(xs) - optional - default: md //height: height of the modal(px or %) - optional - default: 250px //isIFrame: iframe or html content - true if it is iframe, false otherwise //htmlContentOriFrameUrl: iFrame url or html content //requiredConfirm: confirm option when click on cancel - true or false - optional - default: false //dialogLoadEvent: load event, triggers once the dialog loaded completely - optional //dialogUnloadEvent: unload event, triggers before the dialog closes - optional //------------- //example: displayBootstrapModalDialog("Change Password", "md","250px", true, "../aspx/cpwd.aspx?remark=chpwd") var dialogWindow = ""; function displayBootstrapModalDialog(header, modalType, height, isIFrame, htmlContentOriFrameUrl, requiredConfirm, dialogLoadEvent, dialogUnloadEvent) { height = height == "" || height == undefined ? "250px" : height; modalType = modalType == "" || modalType == undefined ? "md" : modalType; requiredConfirm = requiredConfirm == "" || requiredConfirm == undefined ? false : true; closeIcon = requiredConfirm ? "confirm-modal-close" : "modal"; langAlignment = eval(callParent('gllangType')) === "en" ? "right" : "left"; // modal close icon alignment - English(right) & Arabic(left) var modalId = "divModal" + header.split(" ").join(""); var iFrameId = "iFrame" + header.split(" ").join(""); if ($("#" + modalId).next().hasClass("modal-backdrop")) $("#" + modalId).next().remove(); $("#" + modalId).remove(); var modalHtml = ''; setTimeout(function () { modalHtml += '