function errorAlert(errors,errorAlertCallback,className,isKeepPassword){ blockUI(); try{ if ( ! errors.join ){ // not is array errors = errors.split(","); } //var currLang = whichLang(); if (className == undefined){ className=""; } errors=uniqueArray(errors); //remove duplicates var data = '
'; //data+=''; for ( var i = 0; i < errors.length; i ++ ){ data += '

' + errors[i] + '

'; } //data+='
'; var anchor="#close"; data += '

'; data += '
'; if ( errorAlertCallback ){ errorAlertCallback(data); }else{ $(".error").remove(); $('#wrapper').children().first().before(data); } var pos = $("#bgSpan").offset(); $("#divCover").height(pos.top+26); $("#divCover").css("width",$("#wrapper").outerWidth(true)); //avoid scroll without opacity $("#error").css("top",$("#error").offset().top+5); //space between the header and the alert box $(".error").draggable(); $("#error #dummyBtn").focus(); var curLocation = window.location + ""; if (curLocation.indexOf("#")==-1){ if ( errorAlertCallback ){ window.location= curLocation + "#"; }else{ window.location= curLocation + anchor; } }else{ var tempArray = curLocation.split("#"); if ( errorAlertCallback ){ window.location= tempArray.length==0?curLocation:tempArray[0] + "#"; }else{ window.location= tempArray.length==0?curLocation:tempArray[0] + anchor; } } if(!isKeepPassword) { $("input[type=password]").val(""); } }catch(ex){ } } function uniqueArray(a){ temp = new Array(); for(var i = 0; i < a.length; i ++){ if(!contains(temp, a[i])){ temp.length+=1; temp[temp.length-1] = a[i]; } } return temp; } function contains(a, e){ for(j=0;j auto submit e.preventDefault(); } }); }); var currentEvent; function errorConfirm(functionName,errors,errorConfirmCallback,className,customRemoveConfirm, isLocateCenter, imageYes, imageNo, showCloseIcon){ blockUI(); if ( ! errors.join ){ // not is array errors = errors.split(","); } //var currLang = whichLang(); if (className == undefined){ className=""; } var removeConfirmName='removeConfirm'; if (customRemoveConfirm) { removeConfirmName=customRemoveConfirm; } if (isLocateCenter == undefined || isLocateCenter === ''){ isLocateCenter = true; } if (imageYes == undefined || imageYes == ''){ imageYes=''; } if (imageNo == undefined || imageNo == ''){ imageNo=''; } //var data = "
"; var data = '
'; } for ( var i = 0; i < errors.length; i ++ ){ data += '

' + errors[i] + '

'; } data += '

'+imageYes+''+imageNo+'

'; data += '
'; if ( errorConfirmCallback ){ errorConfirmCallback(data); }else{ $(".error").remove(); $('#wrapper').children().first().before(data); } var pos = $("#bgSpan").offset(); $("#divCover").height(pos.top+26); $("#divCover").css("width",$("#wrapper").outerWidth(true)); //avoid scroll without opacity /* var curLocation = window.location + ""; if (curLocation.indexOf("#")==-1){ window.location= curLocation + "#infoAlert"; }else{ var tempArray = curLocation.split("#"); window.location= tempArray.length==0?curLocation:tempArray[0] + "#infoAlert"; } */ scroll(0,0); $(".info").draggable(); $(".info a").focus().blur(); } function removeConfirm(functionName,confirmBox, isConfirm){ submitConfirmLeaveButtonLog(functionName,isConfirm); $(confirmBox.parentNode.parentNode).remove(); //remove all divCover(s) $.each( $('.confirmDivCover') , function(idx, obj){ $(obj).remove(); }); //$('#divCover').remove(); if ($.isFunction(window.localRemoveConfirm)){ localRemoveConfirm(isConfirm); } unblockUI(); } function closeConfirm(functionName,confirmBox, isConfirm){ var buttonLog = functionName+"_CONFIRM_LEAVE_CLOSE"; ajaxButtonLog(buttonLog); $(confirmBox.parentNode.parentNode).remove(); //remove all divCover(s) $.each( $('.confirmDivCover') , function(idx, obj){ $(obj).remove(); }); unblockUI(); } function registerConfirmDialog(dialogCallback, confirmMsg) { $("a").click(function (e) { currentEvent = e; var isExclude=$(this).attr('excludeConfirm'); // fix Issue #44 - this function must ignore "a" with target="_blank" // otherwise both browser and popup window loads the PDF form when clicking on the link // if (isExclude==undefined || isExclude!='true' ){ if (this.target!='_blank' && (isExclude==undefined || isExclude!='true') ){ currentEvent.preventDefault(); // block default action, i.e. go to the specified URL baseURI = window.location.href; // check if it is a tab click, now no blocking on tab click href = currentEvent.currentTarget.href; if (baseURI!=undefined){ baseURI = baseURI.toString().split("#")[0]; } if (href!=undefined){ href = href.toString().split("#")[0]; } indexOf = href.indexOf(baseURI); if (indexOf<0){ dialogCallback(currentEvent, confirmMsg); } } /* else{ window.location = currentEvent.currentTarget.href; } */ }); } function submitConfirmLeaveButtonLog(functionName, isConfirm){ var buttonLog = functionName+"_CONFIRM_LEAVE_"+isConfirm ajaxButtonLog(buttonLog); } function ajaxButtonLog(buttonLogName){ var ajaxButtonLogForm = document.createElement('form'); $(ajaxButtonLogForm).attr("action", "/bct/common/buttonLogAjax.htm"); $(ajaxButtonLogForm).attr("method", "post"); var bottonLogHtml=$(''); $(ajaxButtonLogForm).append(bottonLogHtml); var accessPage=$(''); $(ajaxButtonLogForm).append(accessPage); AjaxForm(ajaxButtonLogForm , function(){}); $(ajaxButtonLogForm).submit(); } function anchor(anchorName){ var curLocation = window.location + ""; if (anchorName!=undefined && anchorName!=""){ if (curLocation.indexOf("#")==-1){ window.location= curLocation + "#"+anchorName; }else{ var tempArray = curLocation.split("#"); window.location= tempArray.length==0?curLocation:tempArray[0] + "#"+anchorName; } } } function blockUI() { $.blockUI({ message: "" }); } function unblockUI() { $.unblockUI(); } function errorRemind(functionName,errors,errorRemindCallback,isLocateCenter,className,customRemoveRemind){ blockUI(); if ( ! errors.join ){ // not is array errors = errors.split(","); } if (className == undefined){ className=""; } var removeRemindName='removeRemind'; if (customRemoveRemind) { removeRemindName=customRemoveRemind; } var data = '
'; } data += '

'; data += '
'; if ( errorRemindCallback ){ errorRemindCallback(data); }else{ $(".error").remove(); $('#wrapper').children().first().before(data); } var pos = $("#bgSpan").offset(); $("#divCover").height(pos.top+26); $("#divCover").css("width",$("#wrapper").outerWidth(true)); //avoid scroll without opacity scroll(0,0); $(".remind").draggable(); $(".remind a").focus().blur(); } function removeRemind(functionName,remindBox, isRemind){ submitRemindContinueButtonLog(functionName,isRemind); $(remindBox.parentNode.parentNode).remove(); //remove all divCover(s) $.each( $('.remindDivCover') , function(idx, obj){ $(obj).remove(); }); //$('#divCover').remove(); if ($.isFunction(window.localRemoveRemind)){ localRemoveRemind(isRemind); } unblockUI(); } function submitRemindContinueButtonLog(functionName, isRemind){ var buttonLog = functionName+"_REMIND_CONTINUE_"+isRemind; ajaxButtonLog(buttonLog); } function getInternetExplorerVersion() // Returns the version of Internet Explorer or a -1 // (indicating the use of another browser). { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv; } function isIE7OrAbove() { return (getInternetExplorerVersion() >= 7.0); } function loadingBlockUI(){ $.blockUI({ css: { border: 'none', width: '800px', padding: '15px', top: $(window).height()/2 + 'px', left: '50px', backgroundColor: '#F0F0F0', color: '#000' }, overlayCSS: { backgroundColor: '#FFFFFF', opacity:.3 }, //timeout: 2000, message: 'Loading data .... Please wait' }); } function showPromotion(){ } function attachPromotionBox(){ var boxWidth=740; var boxHeight=430; var url="https://www.e-mpfhk.com/promotion/eng/Webbanner_740x430.gif"; var popupUrl=" "; var isImage=/jpg$/i.test(url) || /jpeg$/i.test(url) || /gif$/i.test(url); var data=''; data+=''; $('#wrapper').children().first().before(data); $("#highlightFrame").bind('load', loadPromotion); } function loadPromotion(){ $("#highlightFrame").unbind('load'); var boxWidth=740; var boxHeight=430; var fadeoutTime=15000; var top=($(window).height() - boxHeight) /2; var left=($(window).width() - boxWidth) /2; //var top=($(window).height() - boxHeight) /2; //var left=(($("#bgSpan").offset().left-boxWidth)/2); if (top<0) {top=0;} if (left<0) {left=0;} $.blockUI({ css: { //border: '3px solid #5C5C5C', border: '0px', width: boxWidth+'px', height: boxHeight+'px', top: top + 'px', left: left + 'px', backgroundColor: '#FFFFFF' }, overlayCSS: { //disable the blockui layer width: '0px', height: '0px', backgroundColor: '#FFFFFF', opacity:.3 }, //timeout: 10000, fadeIn: 200, fadeOut: 200, message: $('#promotionBox') }); setTimeout(closePromotion, fadeoutTime); if($("iframe.blockUI").length>0) { $("iframe.blockUI").css("width",0); $("iframe.blockUI").css("height",0); } } function closePromotion(){ $.unblockUI({ fadeOut: 200 }); } function errorRemindForMember(errors,errorAlertCallback,className){ blockUI(); try{ if ( ! errors.join ){ // not is array errors = errors.split(","); } //var currLang = whichLang(); if (className == undefined){ className=""; } errors=uniqueArray(errors); //remove duplicates var data = '
'; for ( var i = 0; i < errors.length; i ++ ){ data += '

' + errors[i] + '

'; } var anchor="#close"; data += '

'; data += '
'; if ( errorAlertCallback ){ errorAlertCallback(data); }else{ $(".remind").remove(); $('#wrapper').children().first().before(data); } var pos = $("#bgSpan").offset(); $("#divCover").height(pos.top+26); $("#divCover").css("width",$("#wrapper").outerWidth(true)); //avoid scroll without opacity $("#remind").css("top",$("#remind").offset().top+5); //space between the header and the alert box $(".remind").draggable(); $("#remind #dummyBtn").focus(); var curLocation = window.location + ""; if (curLocation.indexOf("#")==-1){ if ( errorAlertCallback ){ window.location= curLocation + "#"; }else{ window.location= curLocation + anchor; } }else{ var tempArray = curLocation.split("#"); if ( errorAlertCallback ){ window.location= tempArray.length==0?curLocation:tempArray[0] + "#"; }else{ window.location= tempArray.length==0?curLocation:tempArray[0] + anchor; } } }catch(ex){ } } function attachOverlayBox(url, boxWidth, boxHeight){ var data=''; data+=''; $('body').append(data); $("#highlightFrame").bind('load', function() {loadOverlayBoxContent(boxWidth, boxHeight);}); } function loadOverlayBoxContent(boxWidth, boxHeight){ $("#highlightFrame").unbind('load'); var fadeoutTime=15000; var top=($(window).height() - boxHeight) /2; var left=($(window).width() - boxWidth) /2; //var top=($(window).height() - boxHeight) /2; //var left=(($("#bgSpan").offset().left-boxWidth)/2); if (top<0) {top=0;} if (left<0) {left=0;} $.blockUI({ css: { border: '1px #C2E6Ba solid', //border: '0px', width: boxWidth+'px', height: boxHeight+'px', top: top + 'px', left: left + 'px', backgroundColor: '#FFFFFF' }, overlayCSS: { width: '100%', height: '100%', backgroundColor: '#FFFFFF', opacity:.3 }, //timeout: 10000, fadeIn: 200, fadeOut: 200, message: $('#overlayBox') }); if($("iframe.blockUI").length>0) { $("iframe.blockUI").css("width",0); $("iframe.blockUI").css("height",0); } } function doRefreshDate(formName) { var formObj = document.createElement('form'); $(formObj).attr("action", "/bct/INTRANET/common/refreshDateAjax.htm"); $(formObj).attr("method", "post"); AjaxForm(formObj , refreshDateCallback); $(formObj).submit(); } function refreshDateCallback(data, textStatus, XMLHttpRequest){ $.each(data, function(key, value){ if(value==undefined || value.result!=true) { $('#refreshDateResult').html('Error'); } else { $('#refreshDateResult').html('Date Refreshed'); var currentDateMap = value.currentDateStringMap; var currentDateMapHtml = ''; $.each(currentDateMap, function(env,dateMapData) { currentDateMapHtml += env + ' - ' + dateMapData + '
'; }); $('#currentDateMap').html(currentDateMapHtml); } }); } function isNativeApp() { return /BCTMPFAPP\/[0-9\.]+$/.test(navigator.userAgent); }