// JavaScript Document
var merchantid = "308550001";
var group = {
"p" : "portal",
"a" : "account"
} ;
function pad(num, size) {
// Adds leading zeros to a number
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
function separateThousands(x) {
// function to show numbers with separated thousands
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
};
function toSqlDate (p_date) {
dl = new Date(p_date);
dd = pad(dl.getDate(),2);
dm = pad(dl.getMonth()+1,2);
dy = dl.getFullYear();
date = dy + "-" + dm + "-" + dd;
return date;
};
function toSqlTime (p_time) {
dl = new Date(p_time);
ho = pad(dl.getHours(),2);
mi = pad(dl.getMinutes(),2);
time = ho + ":" + mi + ":00";
return time;
}
function mysqlCzDate( mysql_string ) {
if(typeof mysql_string === 'string') {
total = 0;
var t = mysql_string.split(/[- :]/);
//when t[3], t[4] and t[5] are missing they defaults to zero
d = new Date(t[0], t[1] - 1, t[2], t[3] || 0, t[4] || 0, t[5] || 0);
for (var i = 0; i < t.length; i++) {
total += parseInt(t[i]);
}
if (total > 0) {
date_cz = pad(d.getDate(),2) + "." + pad((d.getMonth()+1),2) + "." + d.getFullYear();
} else {
date_cz = "";
}
return date_cz;
}return null;
}
function loginMember(account, pin, page) {
member_acc = account;
member_pin = pin;
$.ajax({
type: 'POST',
url: "/api",
data: { member_acc: member_acc, member_pin: member_pin, action:"login_member"},
dataType: "json"
}).done(function(res){
if (res) {
if (res.success) {
$(".dialog-error").hide();
$(".dialog-error-text").text("");
location.reload()
} else {
console.log(res);
$(".dialog-error").show();
switch (res.status){
case ('ACCOUNT_BLOCKED') :
e_text = "Váš účet je zablokovaný.
"+
"Přejděte na tento odkaz a postupujte dle pokynů. ";
break;
case ('CARD_BLOCKED') :
e_text = "Tato karta je zablokovaná.
"+
"Pokud jste kartu zablokovali omylem, přejděte na tento odkaz a po přihlášení ke svému účtu můžete kartu odblokovat. ";
break;
case ('PREREGISTERED_ACCOUNT') :
e_text = "Tato karta doposud nebyla aktivována.
"+
"Kartu si aktivujete pomocí SMS ve tvaru AKT " + member_acc + ".
"+
"SMS odešlete na číslo 724 80 20 20 a během pár vteřit Vám příjde potvrzovací SMS s Vaším PINem.
";
break;
case ('WRONG_CREDENTIALS') :
case ('INVALID_CREDENTIALS') :
case ('NOT_MEMBER') :
e_text = "Neplatné přihlašovací údaje";
break;
default :
e_text = "Přihlášení se nezdařilo";
}
$(".dialog-error-text").html(e_text);
}
}
});
};
function logoutMember() {
$.ajax({
type: 'POST',
url: "/api",
data: {action: "logout_member"},
dataType: "json"
}).done(function(res){
if (res) {
if (res.success) {
location.reload()
} else {
alert("Odhlášení se nezdařilo");
}
}
});
};
function activateBenefits(code) {
$.ajax({
type: 'POST',
url: "/api",
data: { code:code, action:"activate_benefits"},
dataType: "json"
}).done(function(res){
if (res) {
if (res.success) {
$(".dialog-error").hide();
$(".dialog-error-text").text("");
location.reload()
} else {
console.log(res);
$(".dialog-error").show();
switch (res.status){
case ('BAD_CODE') :
case ('NICK_CODE_MISMATCH'):
e_text = "Neplatný aktivační kód balíčku." +
""
break;
case ('CHANGE_TIMELOCK') :
e_text = "Máte již aktivní jiný benefitní balíček.
" +
"Balíček nelze změnit až do " + res.timelock_to + ".";
break;
default :
e_text = "Aktivace nabídky balíčku se nezdařila
"
"";
}
$(".dialog-error-text").html(e_text);
}
}
});
};
function get_show_balance(element) {
balance = 0
$.ajax({
type: 'POST',
url: '/api',
data: {action: 'get_balance'},
dataType: 'json'
}).done( function(res){
balance = res || 0;
if (element != undefined) {
$(element).text(separateThousands(balance));
}
});
return parseInt(balance);
};
function showDialog(id) {
$(".dialog input").val('');
dialog = $(id).dialog({
appendTo: "body",
position: {my: "center top", at: "center top+50", of: "body"},
dialogClass: "web-dialog",
width: 500,
modal: true
});
$(".dialog-error-text").html('');
$(".dialog-error").hide();
$(".dialog-help-body").css("display","none");
$(".dialog-help-title").removeClass("active");
}
function gpProxyForm() {
frm = "