first commit
This commit is contained in:
44
wp-content/plugins/fb-messenger-live-chat/assets/js/main.js
Normal file
44
wp-content/plugins/fb-messenger-live-chat/assets/js/main.js
Normal file
@@ -0,0 +1,44 @@
|
||||
jQuery(window).ready(function(){
|
||||
|
||||
jQuery('#connect-ztb, [zb-plugin="zb_fbc"]').click(function(){
|
||||
setTimeout(function(){
|
||||
checkToken();
|
||||
},3000);
|
||||
});
|
||||
|
||||
function checkToken(){
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ZTB_BASE_URL+'/customer/access/checkAuth?callback=?',
|
||||
data: {type:'check auth'},
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
dataType: "jsonp",
|
||||
success: function(response){
|
||||
if(response.auth == true){
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ZBT_WP_ADMIN_URL+'admin-ajax.php?action=update_zb_fbc_code',
|
||||
data: {
|
||||
domain:response.domain,
|
||||
access:response.access,
|
||||
customer:response.customer,
|
||||
email:response.email,
|
||||
token:response.token,
|
||||
},
|
||||
success: function(response){
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
setTimeout(function(){
|
||||
checkToken();
|
||||
},3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user