function list_cookies()
{
var all_cookies = document.cookie.split(';');
var a_string = '';
for (var i = 1 ; i <= all_cookies.length; i++) {
a_string += all_cookies[i-1] + "&";
}
return a_string;
}
function check_and_get(elementId)
{
var element = document.getElementById(elementId);
if (typeof(element) != 'undefined' && element != null)
{
return document.getElementById(elementId).value;
}
else
{
return "";
}
}
function get_group_items(ele,item)
{
var element = document.getElementById("tx_container_"+ele);
if (typeof(element) != 'undefined' && element != null)
{
//let rates = document.getElementsByName();
var alltable = document.querySelectorAll('*[name^="tx_item_'+ele+'"]');
var alltableArray= Array.prototype.slice.call(alltable);
alltableArray.forEach(function(element) {
if(element.checked)
{
element.checked = false;
}
});
item.checked = true;
}
}
function check_mandatory(obj)
{
var status = 1;
for (var key in obj)
{
if (obj.hasOwnProperty(key))
{
var element = document.getElementById(key);
if (typeof(element) != 'undefined' && element != null)
{
mandatory = element.getAttribute("mandatory");
if(mandatory == "1" && element.value == "")
{
status++;
element.style.border = "1px solid red";
}
else
{
element.style.border = "1px solid #CCC";
}
}
}
}
if(status == "1")
{
return true;
}
return false;
}
function check_empty(ele)
{
if(document.getElementById(ele) && document.getElementById(ele).value.length > 0)
{
document.getElementById(ele).style.border = "1px solid #CCC";
return true;
}
else
{
document.getElementById(ele).style.border = "1px solid red";
return false;
}
}
function check_same(ele1, ele2)
{
if(document.getElementById(ele1).value != document.getElementById(ele2).value)
{
document.getElementById(ele1).style.border = "1px solid red";
document.getElementById(ele2).style.border = "1px solid red";
return false;
}
else
{
document.getElementById(ele1).style.border = "1px solid #CCC";
document.getElementById(ele2).style.border = "1px solid #CCC";
return true;
}
}
function set_cookie(name,value,days)
{
var expires = "";
if (days)
{
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function get_cookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function erase_cookie(name)
{
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
//document.cookie = name+'=; Max-Age=-99999999;';
}
function get_url_vars(url) {
var vars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function handle_group_click(b,groupid)
{
var x = document.getElementsByClassName('interest_group_'+groupid);
var i;
for (i = 0; i < x.length; i++)
{
if(x[i].value != b) x[i].checked = false;
}
}
function push_form(form_layer)
{
//document.getElementById('tx_account').innerHTML= '
';
var tx_cid = '';
var tx_id = '';
var url_referer = window.location.href;
var send_request = 0;
// always push data to server
var http = new XMLHttpRequest();
var url = form_layer;
var url_params = get_url_vars(window.location.href);
//var tx_identifier = get_cookie('tx_identifier');
send_request = 1;
if(typeof(url_params['tx_cid']) != 'undefined' && typeof(url_params['tx_id']) != 'undefined')
{
tx_id = url_params['tx_id'];
tx_cid = url_params['tx_cid'];
}
console.log("Send request=="+send_request);
if(send_request==1)
{
var params = list_cookies()+'&tx_id='+tx_id+'&tx_cid='+tx_cid+'&url_referer='+url_referer.replace(/&/g,"$");
console.log("Send request=="+params);
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
//http.setRequestHeader('url_referer',url_referer);
http.onreadystatechange = function()
{
//console.log(http.status);
//console.log(http.readyState);
if(http.readyState == 4 && http.status == 200)
{
//console.log(http.responseText);
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
var forms = document.getElementsByTagName('form');
found_form = 0;
var extra_form_tag = '';
for (i = 0; i < forms.length; i++)
{
found_form = 1;
}
if (found_form == 1)
extra_form_tag = "";
document.getElementById('tx_account').innerHTML=extra_form_tag+tx_arr.form_html;
if(tx_arr.tx_identifier=='')
{
//alert(1);
erase_cookie('tx_identifier');
}
else
{
set_cookie('tx_identifier',tx_arr.tx_identifier,365);
}
//var session_hour = 1/24;
//set_cookie('tx_session',tx_arr.tx_session,session_hour);
}
}
http.send(params);
}
}
function submit_register_2()
{
var ele = document.getElementsByName("tx_gender");
var tx_gender = "";
for(i = 0; i < ele.length; i++)
{
if(ele[i].checked)
{
tx_gender = ele[i].value;
}
}
var mandatoryObj ={};
mandatoryObj['tx_login_company'] = "1";
mandatoryObj['tx_login_givenname'] = "1";
mandatoryObj['tx_login_initials'] = "1";
mandatoryObj['tx_login_surname'] = "1";
mandatoryObj['tx_login_zipcode'] = "1";
mandatoryObj['tx_login_streetnumber'] = "1";
mandatoryObj['tx_login_address'] = "1";
mandatoryObj['tx_login_city'] = "1";
mandatoryObj['tx_country'] = "1";
mandatoryObj['tx_login_telephone'] = "1";
mandatoryObj['tx_login_middle_name'] = "1";
mandatoryObj['tx_login_mobile_number'] = "1";
var tx_login_company = check_and_get("tx_login_company");
var tx_login_givenname = check_and_get("tx_login_givenname");
var tx_login_initials = check_and_get("tx_login_initials");
var tx_login_surname = check_and_get("tx_login_surname");
var tx_login_zipcode = check_and_get("tx_login_zipcode");
var tx_login_streetnumber = check_and_get("tx_login_streetnumber");
var tx_login_address = check_and_get("tx_login_address");
var tx_login_city = check_and_get("tx_login_city");
var tx_country = check_and_get("tx_country");
var tx_login_telephone = check_and_get("tx_login_telephone");
var tx_login_middle_name = check_and_get("tx_login_middle_name");
var tx_login_mobile_number = check_and_get("tx_login_mobile_number");
var tx_day = check_and_get("tx_day");
var tx_month = check_and_get("tx_month");
var tx_year = check_and_get("tx_year");
var tx_register_email = document.getElementById("tx_register_email").value;
var tx_token_frm = document.getElementById("tx_token_frm").value;
var http = new XMLHttpRequest();
var obj ={};
obj['tx_login_givenname'] = tx_login_givenname;
obj['tx_login_initials'] = tx_login_initials;
obj['tx_login_middle_name'] = tx_login_middle_name;
obj['tx_gender'] = tx_gender;
obj['tx_login_surname'] = tx_login_surname;
obj['tx_login_zipcode'] = tx_login_zipcode;
obj['tx_login_streetnumber']= tx_login_streetnumber;
obj['tx_login_address'] = tx_login_address;
obj['tx_login_city'] = tx_login_city;
obj['tx_country'] = tx_country;
obj['tx_login_company'] = tx_login_company;
obj['tx_login_telephone'] = tx_login_telephone;
obj['tx_login_mobile_number'] = tx_login_mobile_number;
obj['tx_register_email'] = tx_register_email;
obj['tx_token_frm'] = tx_token_frm;
obj['tx_login_dob'] = tx_year+"-"+tx_month+"-"+tx_day;
if(!check_mandatory(mandatoryObj))
{
return;
}
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_register_2_form_url").value;
console.log(url);
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
if(tx_arr.response_status==1 && tx_arr.response_msg != '')
{
set_cookie('tx_profile',1,1);
//document.getElementById('tx_account').innerHTML=tx_arr.response_msg;
window.location.href = tx_arr.response_page;
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_form_error').style.display = "block";
}
}
}
http.send(params);
}
function submit_register_1()
{
//alert(document.getElementById("tx_form_url").value);
//alert(document.getElementById("tx_form_id").value);
//return false;
if(check_empty("tx_reg_password") && check_empty("tx_reg_password2"))
{
var tx_reg_password = document.getElementById("tx_reg_password").value;
var tx_reg_password2 = document.getElementById("tx_reg_password2").value;
var tx_register_email = document.getElementById("tx_register_email").value;
var http = new XMLHttpRequest();
var obj ={};
var interest ={};
var i_cnt=0
obj['tx_reg_password'] = tx_reg_password;
obj['tx_reg_password2'] = tx_reg_password2;
obj['tx_register_email'] = tx_register_email;
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_register_1_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
if(tx_arr.response_status==1 && tx_arr.response_data != '')
{
set_cookie('tx_token',tx_arr.response_data,1);
document.getElementById('tx_account').innerHTML=tx_arr.response_msg;
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_form_error').style.display = "block";
}
}
}
http.send(params);
}
else
{
check_empty("tx_reg_password");
check_empty("tx_reg_password2");
}
}
function reset_password_submit()
{
if(check_empty("tx_login_password") && check_empty("tx_login_password2"))
{
var tx_login_password = document.getElementById("tx_login_password").value;
var tx_login_password2 = document.getElementById("tx_login_password2").value;
var tx_login_email = document.getElementById("tx_login_email").value;
var http = new XMLHttpRequest();
var obj ={};
var interest ={};
var i_cnt=0
obj['tx_login_password'] = tx_login_password;
obj['tx_login_password2'] = tx_login_password2;
obj['tx_login_email'] = tx_login_email;
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_reset_password_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
if(tx_arr.response_status==1 && tx_arr.response_data != '')
{
document.getElementById('tx_message').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "block";
document.getElementById('tx_form_error').style.display = "none";
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "none";
document.getElementById('tx_form_error').style.display = "block";
}
}
}
http.send(params);
}
else
{
check_empty("tx_reg_password");
check_empty("tx_reg_password2");
}
}
function submit_register()
{
//alert(document.getElementById("tx_form_url").value);
//alert(document.getElementById("tx_form_id").value);
//return false;
if(check_empty("tx_register_username"))
{
document.getElementById("tx_register_username").style.border = "1px solid #CCC";
var tx_register_username = document.getElementById("tx_register_username").value;
var http = new XMLHttpRequest();
var obj ={};
var interest ={};
var i_cnt=0
obj['tx_register_username'] = tx_register_username;
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_register_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
if(tx_arr.response_status==1 && tx_arr.response_data != '')
{
children = document.getElementById('wiz_page_ul').children;
children[0].classList.remove("tx_current");
children[1].classList.add("tx_current");
document.getElementById('tx_form_error').style.display = "none";
document.getElementById('tx_wiz_content_page').innerHTML=tx_arr.response_msg;
set_cookie('tx_user_register',tx_arr.response_data,1);
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_form_error').style.display = "block";
//load_profile_page('register_1');
}
}
}
http.send(params);
}
else
{
check_empty("tx_register_username");
}
}
function submit_forgot_password()
{
if(check_empty("tx_login_username"))
{
document.getElementById("tx_login_username").style.border = "1px solid #CCC";
var tx_login_username = document.getElementById("tx_login_username").value;
var http = new XMLHttpRequest();
var obj ={};
var interest ={};
var i_cnt=0
obj['tx_login_username'] = tx_login_username;
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_forgotpassword_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
if(tx_arr.response_status==1 && tx_arr.response_msg != '')
{
document.getElementById('tx_message').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "block";
document.getElementById('tx_form_error').style.display = "none";
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "none";
document.getElementById('tx_form_error').style.display = "block";
}
}
}
http.send(params);
}
else
{
check_empty("tx_register_username");
}
}
function submit_update_profile()
{
var ele = document.getElementsByName("tx_gender");
var tx_gender = "";
for(i = 0; i < ele.length; i++)
{
if(ele[i].checked)
{
tx_gender = ele[i].value;
}
}
var tx_address_id = document.getElementById("tx_address_id").value;
var mandatoryObj ={};
mandatoryObj['tx_company'] = "1";
mandatoryObj['tx_givenname'] = "1";
mandatoryObj['tx_initials'] = "1";
mandatoryObj['tx_surname'] = "1";
mandatoryObj['tx_zipcode'] = "1";
mandatoryObj['tx_streetnumber'] = "1";
mandatoryObj['tx_address'] = "1";
mandatoryObj['tx_city'] = "1";
mandatoryObj['tx_country'] = "1";
mandatoryObj['tx_telephone'] = "1";
mandatoryObj['tx_mobile_number'] = "1";
mandatoryObj['tx_middle_name'] = "1";
mandatoryObj['tx_day'] = "1";
mandatoryObj['tx_month'] = "1";
mandatoryObj['tx_year'] = "1";
var tx_login_company = check_and_get("tx_company");
var tx_login_givenname = check_and_get("tx_givenname");
var tx_login_initials = check_and_get("tx_initials");
var tx_login_surname = check_and_get("tx_surname");
var tx_login_zipcode = check_and_get("tx_zipcode");
var tx_login_streetnumber = check_and_get("tx_streetnumber");
var tx_login_address = check_and_get("tx_address");
var tx_login_city = check_and_get("tx_city");
var tx_country = check_and_get("tx_country");
var tx_login_telephone = check_and_get("tx_telephone");
var tx_middle_name = check_and_get("tx_middle_name");
var tx_mobile_number = check_and_get("tx_mobile_number");
var tx_day = check_and_get("tx_day");
var tx_month = check_and_get("tx_month");
var tx_year = check_and_get("tx_year");
var tx_register_email = document.getElementById("tx_email_address").value;
var http = new XMLHttpRequest();
var obj ={};
obj['tx_address_id'] = tx_address_id;
obj['tx_middle_name'] = tx_middle_name;
obj['tx_login_givenname'] = tx_login_givenname;
obj['tx_login_initials'] = tx_login_initials;
obj['tx_gender'] = tx_gender;
obj['tx_login_surname'] = tx_login_surname;
obj['tx_login_zipcode'] = tx_login_zipcode;
obj['tx_login_streetnumber']= tx_login_streetnumber;
obj['tx_login_address'] = tx_login_address;
obj['tx_login_city'] = tx_login_city;
obj['tx_country'] = tx_country;
obj['tx_login_company'] = tx_login_company;
obj['tx_login_telephone'] = tx_login_telephone;
obj['tx_register_email'] = tx_register_email;
obj['tx_mobile_number'] = tx_mobile_number;
if(tx_day != '')
{
obj['tx_login_dob'] = tx_year+"-"+tx_month+"-"+tx_day;
}
else
{
obj['tx_login_dob'] = "";
}
if(!check_mandatory(mandatoryObj))
{
return;
}
document.getElementById("tx_save_profile_details").classList.add("active-animatioon");
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(params);
var url = document.getElementById("tx_update_form_url").value;
console.log(url);
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
if(tx_arr.response_status==1 && tx_arr.response_data != '')
{
document.getElementById('tx_message').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "block";
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
}
document.getElementById("tx_save_profile_details").classList.remove("active-animatioon");
}
}
http.send(params);
}
function submit_change_password()
{
if(check_empty("tx_login_password_old") && check_empty("tx_login_password") && check_empty("tx_login_password2") && check_same("tx_login_password", "tx_login_password2"))
{
var tx_login_password_old = document.getElementById("tx_login_password_old").value;
var tx_login_password = document.getElementById("tx_login_password").value;
var tx_login_password2 = document.getElementById("tx_login_password2").value;
document.getElementById("tx_update_profile_password").classList.add("active-animatioon");
var http = new XMLHttpRequest();
var obj ={};
var interest ={};
var i_cnt=0
obj['tx_login_password'] = tx_login_password;
obj['tx_login_password_old'] = tx_login_password_old;
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_change_password_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
if(tx_arr.response_status==1)
{
document.getElementById('tx_message').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "block";
document.getElementById('tx_form_error').style.display = "none";
}
else
{
document.getElementById('tx_message').style.display = "none";
document.getElementById('tx_form_error').style.display = "block";
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
}
document.getElementById("tx_update_profile_password").classList.remove("active-animatioon");
}
}
http.send(params);
}
}
function check_for_multiple(ele)
{
var datamultiple = ele.getAttribute("data-multiple");
console.log(datamultiple);
var divClone = myDiv.cloneNode(true); // the true is for deep cloning
}
function change_user_interest()
{
var interest_final ={};
var main_loop = 0;
let rates = document.getElementsByName("tx_invulvelden_grp_items");
const item_Ele = document.querySelectorAll(".tx_invulvelden_grp_items");
console.log(item_Ele.length);
for (var i = 0; i < item_Ele.length; i++)
{
console.log('fakeImage: ', item_Ele[i]);
rate = item_Ele[i];
var interest ={};
var datatype = rate.getAttribute("data-type");
var dataid = rate.getAttribute("data-id");
var datadesc = rate.getAttribute("data-desc");
var ext_datadesc = rate.getAttribute("data-ext-datadesc");
var selectedid = rate.getAttribute("selected-id");
var multipledata = rate.getAttribute("data-multiple");
console.log(datatype);
console.log(dataid);
console.log(datadesc);
console.log(ext_datadesc);
if(datatype == "checkbox")
{
var interest_data = new Array();
//let tx_items = document.getElementsByName("tx_item_"+dataid);
var loop = 0;
var alltable = document.querySelectorAll('*[name^="tx_item_'+dataid+'"]');
var alltableArray= Array.prototype.slice.call(alltable);
alltableArray.forEach(function(element) {
if(element.checked)
{
console.log(element.value);
interest_data[loop] = element.value;
loop++;
}
});
console.log(interest_data);
interest['ext_interest_type'] = interest_data.join(";");
interest['ext_interest_id'] = dataid;
interest['ext_interest_description'] = ext_datadesc;
interest['description'] = datadesc;
interest['data_selected_id'] = selectedid;
interest_final[main_loop] = interest;
console.log(interest_final);
}
else if (datatype == "radio")
{
var interest_data = new Array();
let tx_items = document.getElementsByName("tx_item_"+dataid);
var loop = 0;
var alltable = document.querySelectorAll('*[name^="tx_item_'+dataid+'"]');
var alltableArray= Array.prototype.slice.call(alltable);
alltableArray.forEach(function(element) {
if(element.checked)
{
console.log(element.value);
interest_data[loop] = element.value;
loop++;
}
});
interest['ext_interest_type'] = interest_data.join(";");
interest['ext_interest_id'] = dataid;
interest['ext_interest_description'] = ext_datadesc;
interest['description'] = datadesc;
interest['data_selected_id'] = selectedid;
interest_final[main_loop] = interest;
console.log(interest_final);
}
else if (datatype == "select")
{
if(multipledata == "multiple")
{
var tx_items_val = $("#tx_item_"+dataid).chosen().val();
console.log( "Multiple " + tx_items_val);
if(tx_items_val !== null)
{
tx_items_val = tx_items_val.toString().split(",").join(";");
}
else
{
tx_items_val = "";
}
console.log( "Multiple " + tx_items_val);
}
else
{
var tx_items_val = document.getElementById("tx_item_"+dataid).value;
console.log( " Single " + tx_items_val);
}
var interest_data = new Array();
interest['ext_interest_type'] = tx_items_val;
interest['ext_interest_id'] = dataid;
interest['ext_interest_description'] = ext_datadesc;
interest['description'] = datadesc;
interest['data_selected_id'] = selectedid;
interest_final[main_loop] = interest;
console.log(interest_final);
}
main_loop++;
}
document.getElementById("tx_save_interests").classList.add("active-animatioon");
var http = new XMLHttpRequest();
var obj ={};
var i_cnt=0
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(interest_final)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(interest_final));
var url = document.getElementById("tx_interest_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
if(tx_arr.response_status==1 && tx_arr.response_data != '')
{
document.getElementById('tx_message').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "block";
document.getElementById('tx_form_error').style.display = "none";
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_message').style.display = "none";
document.getElementById('tx_form_error').style.display = "block";
}
document.getElementById("tx_save_interests").classList.remove("active-animatioon");
}
}
http.send(params);
}
function submit_login()
{
//alert(document.getElementById("tx_form_url").value);
//alert(document.getElementById("tx_form_id").value);
//return false;
if(check_empty("tx_login_username") && check_empty("tx_login_password"))
{
var tx_login_username = document.getElementById("tx_login_username").value;
var tx_login_password = document.getElementById("tx_login_password").value;
var http = new XMLHttpRequest();
var obj ={};
var interest ={};
var i_cnt=0
obj['tx_login_username'] = tx_login_username;
obj['tx_login_password'] = tx_login_password;
var url_referer = window.location.href;
var params = list_cookies()+'&profile_fields='+JSON.stringify(obj)+'&url_referer='+url_referer.replace(/&/g,"$");;
console.log(JSON.stringify(obj));
var url = document.getElementById("tx_login_form_url").value;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200)
{
var tx_arr = JSON.parse(http.responseText);
if(tx_arr.response_status==1)
{
document.getElementById('tx_account').innerHTML=tx_arr.response_msg;
set_cookie('tx_token',tx_arr.response_data,1);
window.location.href = tx_arr.response_page;
}
else
{
document.getElementById('tx_form_error').innerHTML=tx_arr.response_msg;
document.getElementById('tx_form_error').style.display = "block";
}
}
}
http.send(params);
}
}
function show_profile_overview()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/profile/';
}
else
{
window.location.href = '/account_pagina?profile';
}
}
function show_login()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/login/';
}
else
{
window.location.href = '/account_pagina?login';
}
}
function show_registerform()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/register/';
}
else
{
window.location.href = '/account_pagina?register';
}
}
function show_forgotpass()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/forgot_password/';
}
else
{
window.location.href = '/account_pagina?forgot_password';
}
}
function show_profile_list_transactions()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/get_transactions/';
}
else
{
window.location.href = '/account_pagina?get_transactions';
}
}
function show_profile_interest()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/interests/';
}
else
{
window.location.href = '/account_pagina?interests';
}
}
function show_profile_edit_user()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/update_profile/';
}
else
{
window.location.href = '/account_pagina?update_profile';
}
}
function change_password()
{
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
window.location.href = '/account_pagina/change_password/';
}
else
{
window.location.href = '/account_pagina?change_password';
}
}
function tx_loggout()
{
erase_cookie('tx_token');
erase_cookie('tx_token');
var tx_identifier = get_cookie('tx_identifier');
if(tx_identifier == '1')
{
erase_cookie('tx_identifier');
window.location.href = '/account_pagina/login/';
}
else
{
erase_cookie('tx_identifier');
window.location.href = '/account_pagina?login';
}
}
function show_transaction_details(ele)
{
if(document.getElementById('tx_transaction_'+ele).style.display == "table-cell")
{
document.getElementById('tx_transaction_'+ele).style.display = "none";
document.getElementById('show_transaction_details_'+ele).innerHTML = "+";
}
else
{
document.getElementById('tx_transaction_'+ele).style.display = "table-cell";
document.getElementById('show_transaction_details_'+ele).innerHTML = "-";
}
}
function load_profile_page(txpage)
{
console.log('Came to profile overview ');
var tx_cid = '';
var tx_id = '';
var url_referer = window.location.href;
var send_request = 0;
// always push data to server
var http = new XMLHttpRequest();
var url = form_layer;
var url_params = get_url_vars(window.location.href);
//var tx_identifier = get_cookie('tx_identifier');
send_request = 1;
if(typeof(url_params['tx_cid']) != 'undefined' && typeof(url_params['tx_id']) != 'undefined')
{
tx_id = url_params['tx_id'];
tx_cid = url_params['tx_cid'];
}
console.log("Send request=="+send_request);
if(send_request==1)
{
var params = list_cookies()+'&tx_page_req='+txpage+'&tx_cid='+tx_cid+'&url_referer='+url_referer.replace(/&/g,"$");
console.log("Send request=="+params);
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
//http.setRequestHeader('url_referer',url_referer);
http.onreadystatechange = function()
{
//console.log(http.status);
//console.log(http.readyState);
if(http.readyState == 4 && http.status == 200)
{
//console.log(http.responseText);
var tx_arr = JSON.parse(http.responseText);
console.log(tx_arr);
var forms = document.getElementsByTagName('form');
found_form = 0;
var extra_form_tag = '';
document.getElementById('tx_account').innerHTML= tx_arr.form_html;
}
}
http.send(params);
}
}
function include_js(filename,onload) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
script.onload = script.onreadystatechange = function() {
onload();
};
head.appendChild(script);
}
function include_css(filename) {
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = filename;
head.appendChild(link);
}
include_css('//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css');
include_css('https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.css');
include_css('https://jqueryui.com/resources/demos/style.css');
include_css('https://account-page.tritonx.nl/tx_css/profile.css?v='+Math.floor(Math.random() * 100));
include_js('https://code.jquery.com/jquery-1.12.4.js',function() {});
include_js('https://code.jquery.com/ui/1.12.1/jquery-ui.js',function() {
$(document).ready(function() {
//$( "#datepicker" ).datepicker({ changeMonth: true,changeYear: true,dateFormat: 'yy-mm-dd',maxDate: 0});
setTimeout(setmultiselect,2000);
});
});
function setmultiselect()
{
include_js('https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.js',function() {
$('.tx_interest_select_single').chosen({'placeholder_text_multiple':"Maak uw keuze"});
$('.tx_interest_select_multiple').chosen({'placeholder_text_multiple':"Maak uw keuze"});
});
}
////////////////////////////////////////////////////////////////////////////////////////
var form_layer = "https://account-page.tritonx.nl/index.php/forms/push_form/";
console.log(form_layer) ;
push_form(form_layer);
// push every 5 seconds data
window.setInterval(function()
{
//push_data();
}, 5000);