// JavaScript Document
function Transfer(){
this.viewPrompt = function(msg){
$('#promptMessage').show();
$('#promptMessage').html(msg);
},
this.removeError = function(msg){
$('#product').parent().parent().removeClass('error');
$('#code').parent().removeClass('error');
$('#email').parent().removeClass('error');
$('#captcha').parent().removeClass('error');
$('.errormsg').remove();
},
this.checkForm = function(){
transferObj.removeError();
var next = true;
this.product = $('#product').text();
if (MApp(2.2).check.isNull(this.product) || this.product == transfer_option_product){
$('#product').parent().parent().addClass('error');
$('#product').parent().after('
'+transfer_checkForm_product+'
');
next = false;
}
this.code = $('#code').val();
this.code = MApp(2.2).packages.trim(this.code);
this.code = MApp(2.2).packages.replaceoto0(this.code);
$('#code').val(this.code);
if (MApp(2.2).check.isNull(this.code) || this.code == 'e.g: F4B1D-ACAB1-A84FF-5FDC6'){
$('#code').parent().addClass('error');
$('#code').after(' '+transfer_checkForm_isNull+'
');
next = false;
} else if (!MApp(2.2).check.isCode(this.code)){
$('#code').parent().addClass('error');
$('#code').after(' '+transfer_checkForm_isCode+'
');
next = false;
}
this.email = $('#email').val();
this.email = MApp(2.2).packages.trim(this.email);
$('#email').val(this.email);
if (!MApp(2.2).check.isEmail(this.email)){
$('#email').parent().addClass('error');
$('#email').after(' '+transfer_checkForm_isEmail+'
');
next = false;
}
this.captcha = $('#captcha').val();
if (MApp(2.2).check.isNull(this.captcha)){
$('#captcha').parent().addClass('error');
$('#captcha').parent().append(' '+transfer_checkForm_captcha+'
');
next = false;
}
if(next) return true;
else return false;
},
this.request = function(){
$.ajax({
type: "POST",
url: "transferproduct.php?a=transfer",
data: "captcha="+this.captcha+"&product="+this.product+"&code="+this.code+"&email="+this.email,
success: function(response){
var promptText;
if (response == '1'){
promptText = transfer_request_1_1+transferObj.email+transfer_request_1_2;
$('#product').text('');
$('#captcha').val('');
$('#code').val('');
$('#email').val('');
MApp(2.2).packages.refreshCaptcha('captchaImg', 'seccode.php?1');
$('#promptMessage').html(promptText);
$('#promptMessage').removeClass('warning').addClass('success').addClass('active');
transferObj.removeError();
} else {
if (response == '-7') {
$('#captcha').parent().addClass('error');
$('#captcha').parent().append(' '+transfer_request_07+'
');
$('#captcha').val('');
MApp(2.2).packages.refreshCaptcha('captchaImg', 'seccode.php?1');
}else{
if (response == '-1') {
promptText = reinstall_request_01;
} else if (response == '-2') {
promptText = transfer_request_02;
} else if (response == '-3') {
promptText = transfer_request_03;
} else if (response == '-4') {
promptText = transfer_request_04;
} else if (response == '-5') {
promptText = transfer_request_05;
} else if (response == '-6') {
promptText = transfer_request_06;
} else if (response == '2') {
promptText = transfer_request_2;
}
//$('#product').text('');
$('#captcha').val('');
$('#code').val('');
$('#email').val('');
MApp(2.2).packages.refreshCaptcha('captchaImg', 'seccode.php?1');
$('#promptMessage').addClass('warning').addClass('active');
$('#promptMessage').html(promptText);
lostcodeObj.removeError();
}
}
}
});
},
this.submit = function(){
if (!this.checkForm()){
return false;
}
this.request();
}
}
transferObj = new Transfer();
$(function(){
$("#transfer").click(function(){
if ($(this).next().attr("style") == "display: block;") {
$(this).next().hide();
} else {
$(this).next().show();
}
});
});