You\'ve already applied for this job. Please wait for a reply from the employer shortly.";
} else if(reply.indexOf('RES[OK')>-1) {
document.getElementById('biscuitsDialog').innerHTML = "
Application sent successfully!";
} else {
document.getElementById('biscuitsDialog').innerHTML = "
Sorry, we couldnt process your application right now, please try again.";
}
if(reply.indexOf('ERROR:notloggedin')==-1) {
window.loggedin = true;
}
try {
centerDialog('biscuitsDialog');
} catch(err) {
console.log("Dialog Error check")
}
};
function isLoggedIn() {
if(!window.loggedin) {
return window.loggedin;
} else {
return true;
}
};
function closeRegister() {
if(document.getElementById('biscuitsDialog')) {
var elem = document.getElementById("biscuitsDialog");
elem.parentElement.removeChild(elem);
}
};
function doFinalizeAccount() {
//handle file
var fileSelect = document.getElementById('cv');
var files = fileSelect.files;
var formData = new FormData();
var validated = true;
var validationErrors = '';
// Loop through each of the selected files.
var filesAttachedCount = 0;
for (var i = 0; i < files.length; i++) {
var file = files[i];
// Check the file type.
if (file.name.indexOf('.doc')==-1&&file.name.indexOf('.docx')==-1&&file.name.indexOf('.pdf')==-1&&file.name.indexOf('*.txt')==-1&&file.name.indexOf('.odt')==-1) {
validationErrors += 'Sorry, could not add file: '+file.name+' because it is not a .doc, .docx, .pdf, .odt or .txt file';
continue;
}
// Add the file to the request.
formData.append('cvs[]', file, file.name);
filesAttachedCount++;
}
//sort out qualification and nationality
nationality = document.getElementById('lbnationality').value;
if(document.getElementById('lbnationality').value=='other') {
nationality = document.getElementById('lbnationalitycustom').value;
}
qualification = document.getElementById('lbqualification').value;
if(document.getElementById('lbqualification').value=='other') {
qualification = document.getElementById('lbqualificationcustom').value;
}
//validation
if(!(qualification.length>1)) {
validated = false;
validationErrors += 'You must select a qualification ';
} else if(!(nationality.length>3)) {
validated = false;
validationErrors += 'You must select your nationality ';
} else if(!(filesAttachedCount>0)) {
validated = false;
validationErrors += 'You must choose your C.V. or resume ';
}
if(validated) {
// add nationality and qualification
formData.append('nationality', nationality);
formData.append('qualification', qualification);
formData.append('id', window.account_id);
//send data
AjaxPostCall('?upload_cv_nationality_qualification',formData,'doAccountFinalStep');
} else {
document.getElementById('code_error').innerHTML = "Sorry, please check the following and click done again: "+validationErrors;
}
};
function doAccountFinalStep(res) {
if (res.indexOf('RES[OK')>-1) {
//handle final action
if(window.job_id>0) {
sendAccountDetailsToClient(window.job_id,window.employer_id,window.account_id);
} else {
//show success message
document.getElementById('biscuitsDialog').style.textAlign = 'center';
document.getElementById('biscuitsDialog').style.padding = '8px';
document.getElementById('biscuitsDialog').innerHTML = "
Registration success!";
}
} else {
document.getElementById('code_error').innerHTML = 'Sorry, that didn\'t work, please try again.';
}
};
function doNationality() {
if(document.getElementById('lbnationality').value=='other') {
document.getElementById('lbnationality').style.display = 'none';
document.getElementById('lbnationalitycustom').style.display = 'block';
}
};
function doQualification() {
if(document.getElementById('lbqualification').value=='other') {
document.getElementById('lbqualification').style.display = 'none';
document.getElementById('lbqualificationcustom').style.display = 'block';
}
};
function showFinalStep() {
//go to next step
div_html = "Your nationality: Highest qualification: Upload C.V. or Resume
";
try {
document.getElementById('registration_fields').innerHTML = div_html;
} catch(err) {
document.getElementById('biscuitsDialog').innerHTML = ' Please complete your details to continue:
'+div_html;
document.getElementById('biscuitsDialog').style.width = '200px';
document.getElementById('biscuitsDialog').style.textAlign = 'left';
}
detectKeyPress('cv','doFinalizeAccount');
};
function _accountSettings(title, contentHtmlorLink) {
//open a popup and point it at core
createWindow(title, contentHtmlorLink);
};
function codeReply(res) {
if (res.indexOf('RES[ERROR:wait 60 seconds')>-1) {
if(document.getElementById('code_error')) {
document.getElementById('code_error').innerHTML = 'Code was sent, Please wait 60 seconds before sending another code';
} else {
alert('Code was sent, Please wait 60 seconds before sending another code');
}
}
};
function sendCode() {
phone = document.getElementById('lbemail').value;
if(phone.startsWith("+")) { phone = phone.replace('+',"00"); }
if(/^\d+$/.test(phone)&&phone.length>6) {
document.getElementById('lbpass').setAttribute('type','text'); //type=text needed for tulkan, add support on other sites, need to detect type=input
placeholder = 'Enter the code sent to your phone';
sent_message = 'Code Sent!';
if(document.getElementById('lbpass').placeholder=='密码'||window.lang=='cn') {
placeholder = '输入发送到您手机的代码';
sent_message = '验证码已发送至您的手机,请查收!';
window.lang = 'cn';
}
document.getElementById('lbpass').setAttribute('placeholder',placeholder);
document.getElementById('code_error').innerHTML = ""+sent_message+"";
AjaxCall("?new_code_request&contact="+btoa(encodeURIComponent(phone))+(window.lang?"&lang="+window.lang:""),false,"codeReply");
} else {
message = "Please enter a numeric value for the Phone number, at least 6 digits long";
if(document.getElementById('lbpass').placeholder=='密码'||window.lang=='cn') {
message = "请输入电话号码的数值,至少6位数字";
}
if(document.getElementById('code_error')) {
document.getElementById('code_error').innerHTML = message;
} else {
alert(message);
}
}
};
function showConversation(html) {
$('#previous_conversations').hide();
document.getElementById('result').innerHTML = JSON.parse(atob(html));
}
function previousConversations(res) {
killWindows();
windowShow('previous_conversations');
document.getElementById('previous_conversations_content').innerHTML = res;
}
function handleCode() {
document.getElementById('login_div_password_div').style.display = 'block';
document.getElementById('login_div_new_password_div').style.display = 'block';
document.getElementById('lbpass').type = 'text';
document.getElementById('login_button').value = (window.lang=='en'?"Register":"注册");
document.getElementById('login_div1').setAttribute('onsubmit','checkCode();event.preventDefault();');
sendCode();
}
function checkCode() {
error = '';
if(document.getElementById('new_lbpass').value.length<5) {
error += 'Password must be longer than 4 characters ';
}
if(document.getElementById('new_lbpass_2').value!=document.getElementById('new_lbpass').value) {
error += 'Password and Confirm Password must be the same ';
}
if(document.getElementById('lbpass').value.length!=4) {
error += "Code must be 4 characters long, please check";
}
if(error=='') {
//login
AjaxCall("/?atf_do_login&username="+btoa(document.getElementById('lbemail').value)+"&password="+btoa(document.getElementById('lbpass').value),false,'setPassword');
document.getElementById('login_button').value = (window.lang=='en'?"Saving...":"请稍等。。。");
} else {
document.getElementById('code_error').innerHTML = error;
}
}
function setPassword() {
AjaxCall("?atf_resetpassword="+document.getElementById('lbemail').value+"&code="+document.getElementById('new_lbpass').value,false,"passwordSetFinish");
}
function passwordSetFinish() {
window.location.href = '/';
}
function registerReply(res) {
//+"&new_password="+btoa(encodeURIComponent(document.getElementById('new_lbpass').value)
if(res.indexOf('[OK:')>-1) {
tmp = res.split('[OK:');
tmp = tmp[1].split(']]');
AjaxCall("?atf_resetpassword="+document.getElementById('lbemail').value+"&reset_code="+tmp[0]+"&new_password="+document.getElementById('lbpass').value,false,"registerReply");
} else {
document.getElementById('code_error').innerHTML = (window.lang=='en'?"Sorry, an error occured, please try again":"抱歉,发生错误,请重试");
}
}
function showRegister() {
windowShow('login_div');
document.getElementById('login_div_title').innerHTML = (window.lang=='en'?"Register":"注册账户");
document.getElementById('code_text').innerHTML = (window.lang=='en'?"Enter the code sent to your phone":"输入发送到您手机的验证码");
document.getElementById('lbpass').placeholder = (window.lang=='en'?"Enter code":"输入验证码");
windowHide("login_div_password_div");
document.getElementById('register_text').style.display = 'none';
document.getElementById('login_button').value = (window.lang=='en'?"Send Code":"发送验证码");
document.getElementById('login_div1').setAttribute('onsubmit', 'handleCode();event.preventDefault();');
}
function windowShow(id){
document.getElementById(id).style.display='flex';
}
function windowHide(id){
document.getElementById(id).style.display='none';
}
function createWindow(title, contentHtmlorLink) {
var div = document.createElement('div');
var div_id = 'contentDiv_'+Date.now();
div.setAttribute('id',div_id);
div.style.position = 'fixed';
div.style.zIndex = '2000';
div.style.background = '#fff';
div.style.boxShadow = '2px 3px 2px #dde2ea';
div.style.color = 'black';
div.style.transform = 'scale(1)';
div.style.transition = 'opacity .2s ease-in-out,transform .2s ease-in-out,-webkit-transform .2s ease-in-out';
div.style.outline = '0';
div.style.backgroundColor = '#fff';
div.style.opacity = '1';
div.style.WebkitTapHighlightColor = 'transparent';
div.style.boxShadow = '0 12px 50px 0 rgba(37,32,31,.25)';
div.style.borderRadius = '.375rem';
div.style.padding = '1rem';
document.body.appendChild(div);
if(contentHtmlorLink.substring(0,4)=='http') {
//fetching link
AjaxCall(contentHtmlorLink,"content_"+div_id,"centerContentWindow");
contentHtmlorLink = "Loading... Please wait";
}
document.getElementById(div_id).innerHTML = ''+title+'X
'+contentHtmlorLink+'
';
if(window.is_mobile) {
initializeMoveToCenter("lbemail",div_id);
initializeMoveToCenter("lbpass",div_id);
}
try {
centerDialog(div_id);
} catch(err) {}
//save the id for later if we need to clear everything
if(typeof window.div_id_log == "undefined") {
window.div_id_log = '';
}
window.div_id_log += div_id+',';
showNewOverlay();
return div_id;
}
function centerContentWindow() {
tmp = window.div_id_log.split(',');
for(i=0; i-1&&typeof document.getElementById(tmp[i]) != "null") {
centerDialog(tmp[i]);
}
}
}
function showNewOverlay() {
var div = document.createElement('div');
var div_id = 'overlayDiv_'+Date.now();
div.setAttribute('id',div_id);
div.style.position = 'fixed';
div.style.top = '0';
div.style.right = '0';
div.style.bottom = '0';
div.style.left = '0';
div.style.zIndex = '1900';
div.style.WebkitTransition = 'opacity .2s ease-in-out';
div.style.OTransition = 'opacity .2s ease-in-out';
div.style.transition = 'opacity .2s ease-in-out';
div.style.backgroundColor = '#b2aebd';
div.style.opacity = '.7';
div.style.overflow = 'hidden';
document.body.appendChild(div);
window.div_id_log += div_id+',';
document.getElementById(div_id).onclick = function() {
killNewWindows();
}
}
function killNewWindows() {
tmp = window.div_id_log.split(',');
for(i=0; i