$(function(){ $("#tb1 tr").click(function(){ $(this).css("background-color", "#e5e5e5").siblings().css("background-color", "#fff"); return true; }); }); var gotoPage; function switchLanguage(lang,pGotoPage){ gotoPage = pGotoPage; ajaxTemplate( baseUrl+'/switchLanguage', "request_locale="+lang, "processSwitchLanguageResult" ); } function processSwitchLanguageResult(result){ location.href=gotoPage; } function ajaxTemplate(url,data,funcname){ showProcessing(); $.ajax({ type:"post", url: url, data: data, //dataType:'json', success: function(result){ hideProcessing(); if (funcname in window) { window[funcname](result); } } }); } function ajaxTemplate(url,data,funcname){ showProcessing(); $.ajax({ type:"post", url: url, data: data, //dataType:'json', success: function(result){ hideProcessing(); if(jQuery.type(result)==="string" && result.indexOf("PLATFORM-LOGIN-PAGE")>=0){ location.href = baseUrl+'/wholesaler/login?wn='+userUUID; }else if(jQuery.type(result)==="string" && result.indexOf("ERROR-PAGE")>=0){ location.href = baseUrl+'/platformError?wn='+userUUID; }else{ if (funcname in window) { window[funcname](result); } } } }); } function checkRequired(obj, name) { if ( obj.val().length <= 0) { obj.addClass( "ui-state-error" ); show_message("'" + name + "' is required." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkPositiveNumber(obj, name) { if (!obj.val().match(new RegExp(/^\+?[0-9]*\.?[0-9]+$/))) { obj.addClass( "ui-state-error" ); show_message("'" + name + "' should be a positive number." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkPositiveInteger(obj, name) { if (!obj.val().match(new RegExp(/^(?!^0)\d{1,9}$/))) { obj.addClass( "ui-state-error" ); show_message("'" + name + "' should be a positive integer." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkLe100NaturalNumber(obj, name) { if (!obj.val().match(new RegExp(/^\d+$/)) || obj.val()>100 || obj.val()<0) { obj.addClass( "ui-state-error" ); show_message("'" + name + "' should be between 0 and 100." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkLength(obj, name, min, max) { if ( obj.val().length > max || obj.val().length < min ) { obj.addClass( "ui-state-error" ); show_message("Length of '" + name + "' must be between " + min + " and " + max + "." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkValidUserUuid(obj, name){ var reg = /^[a-zA-Z0-9_]+$/; // or /^\w+$/ as mentioned if ( obj.val().length < 3) { obj.addClass( "ui-state-error" ); show_message("The length of '"+name+"' should be equal or greater than 3." ); return false; }else if(!reg.test(obj.val())){ obj.addClass( "ui-state-error" ); show_message("Only letter [a-z A-Z], digit number [0-9] and underscore are allowed in '"+name+"'." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkValidPasswordAndConfirmPassword(password, passwordConfirm, password_label,passwordConfirm_label ){ if (password.val().length < 6) { password.addClass("ui-state-error"); show_message("Length of '" + password_label + "' must be greater than 6."); return false; } var re = /[0-9]/; if(!re.test(password.val())) { show_message(password_label+" must contain at least one number (0-9)!"); password.addClass( "ui-state-error" ); return false; } re = /[a-zA-Z]/; if(!re.test(password.val())) { show_message(password_label+" must contain at least one letter (a-zA-Z)!"); password.addClass( "ui-state-error" ); return false; } if( password.val() != passwordConfirm.val()) { password.addClass( "ui-state-error" ); show_message("'" + password_label + "' and '"+passwordConfirm_label+"' should be the same."); return false; } password.removeClass( "ui-state-error" ); return true; } function checkValidEmail(obj, name){ if (!obj.val().match(new RegExp(/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi))) { obj.addClass( "ui-state-error" ); show_message("Please enter valid '" + name + "'." ); return false; } else { obj.removeClass( "ui-state-error" ); return true; } } function checkValidMultiEmail(obj, name){ var arrEmail = obj.val().split(","); for(var i=0;i'); return newData; } function reverse(data){ var newData = data.replace(/(
)/g,'\r\n'); return newData; } function show_message(show_message,show_time,show_title,tigBoxClass) { var show_message = (undefined==show_message ? '' : show_message); if(show_message) { var show_time = (undefined==show_time ? 4 : show_time); var show_title = (undefined==show_title ? 'Message' : show_title); var tigBoxClass = (undefined==tigBoxClass ? 'tigBox' : tigBoxClass); var smaHTML = '
'; $('#show_message_area').html(smaHTML); var tigBoxObj = document.getElementById("tigBox"); tigBoxObj.style.visibility = "visible"; var i=0; setTimeout(function() { i += 1; tigBoxObj.style.visibility= "hidden"; $('#show_message_area').html(""); },(show_time * 1000)); } } function closeMessage(){ var tigBoxObj = document.getElementById("tigBox"); tigBoxObj.style.visibility= "hidden"; $('#show_message_area').html(""); return false; } function show_message_withok(show_message,show_title,tigBoxClass) { var show_message = (undefined==show_message ? '' : show_message); if(show_message) { var show_title = (undefined==show_title ? 'Message' : show_title); var tigBoxClass = (undefined==tigBoxClass ? 'tigBox' : tigBoxClass); var smaHTML = '
'+ '
'; $('#show_message_area').html(smaHTML); var tigBoxObj = document.getElementById("tigBox"); tigBoxObj.style.visibility = "visible"; $('#qr').click(function(){tigBoxObj.style.visibility= "hidden";}); } } function showProcessing() { document.getElementById('processingModal').style.display = 'block'; } function hideProcessing() { document.getElementById('processingModal').style.display = 'none'; }