Por favor inicie sesión
Recuérdame
Iniciar sesión
/**
* Submit default login form
*/
function wpsc_submit_login_form(el) {var dataform = new FormData(jQuery(el).closest('form')[0]);
var username = dataform.get('username').trim();
var password = dataform.get('password').trim();
if (!username || !password) {
alert(supportcandy.translations.req_fields_missing);
return;
}
wpsc_post_login_form(el, dataform);
}/**
* Submit login form
*/
function wpsc_post_login_form(el, dataform) {jQuery(el).text(supportcandy.translations.please_wait);
jQuery.ajax({
url: supportcandy.ajax_url,
type: 'POST',
data: dataform,
processData: false,
contentType: false
}).done(function (response) {
if (response.success != 1) alert(supportcandy.translations.incorrect_login);
}).fail(function (res) {
alert(supportcandy.translations.something_wrong);
}).always(function () {
window.location.reload();
});
}/**
* Custom login
*/
function wpsc_custom_login(el, url) {jQuery(el).text(supportcandy.translations.please_wait);
window.location.href = url;
}/**
* Get default registration page
*/
function wpsc_get_default_registration() {jQuery('.auth-inner-container').html(supportcandy.loader_html);
var data = { action: 'wpsc_get_default_registration' };
jQuery.post(supportcandy.ajax_url, data, function (response) {
jQuery('.auth-inner-container').html(response);
});
}/**
* Set default registration form
*/
function wpsc_set_default_registration(el) {var dataform = new FormData(jQuery(el).closest('form')[0]);
var firstname = dataform.get('firstname').trim();
var lastname = dataform.get('lastname').trim();
var username = dataform.get('username').trim();
var email_address = dataform.get('email_address').trim();
var password = dataform.get('password').trim();
var confirm_password = dataform.get('confirm_password').trim();
var isUsername = dataform.get('is_username').trim();
var isEmail = dataform.get('is_email').trim();
if (!firstname || !lastname || !username || !email_address || !password || !confirm_password) {
alert(supportcandy.translations.req_fields_missing);
return;
}if (!validateEmail(email_address)) {
alert(supportcandy.translations.incorrect_email);
return;
}if (isUsername != 1) {
alert(supportcandy.translations.unsername_unavailable);
return;
}if (isEmail != 1) {
alert(supportcandy.translations.email_unavailable);
return;
}if (password !== confirm_password) {
alert(supportcandy.translations.incorrect_password);
return;
}
wpsc_authenticate_registration(el, dataform);
}/**
* Post registration form
*/
function wpsc_authenticate_registration(el, dataform) {jQuery('.auth-inner-container').html(supportcandy.loader_html);
jQuery.ajax({
url: supportcandy.ajax_url,
type: 'POST',
data: dataform,
processData: false,
contentType: false
}).done(function (res) {
if (typeof(res) == "object") {
alert(supportcandy.translations.something_wrong);
wpsc_get_default_registration();
} else {
jQuery('.auth-inner-container').html(res);
}
}).fail(function (res) {
alert(supportcandy.translations.something_wrong);
window.location.reload();
});
}/**
* Register user
*/
function wpsc_confirm_registration(el) {jQuery('.auth-inner-container').html(supportcandy.loader_html);
var dataform = new FormData(jQuery(el).closest('form')[0]);
jQuery.ajax({
url: supportcandy.ajax_url,
type: 'POST',
data: dataform,
processData: false,
contentType: false
}).done(function (res) {
if (res.isSuccess == 1) {
window.location.reload();
} else {
alert(supportcandy.translations.something_wrong);
wpsc_get_default_registration();
}
});
}/**
* Get guest otp login screen
*
* @return void
*/
function wpsc_get_guest_sign_in() {jQuery('.auth-inner-container').html(supportcandy.loader_html);
var data = { action: 'wpsc_get_guest_sign_in' };
jQuery.post(supportcandy.ajax_url, data, function (res) {
if (typeof(res) == "object") {
alert(supportcandy.translations.something_wrong);
window.location.reload();
} else {
jQuery('.auth-inner-container').html(res);
}
});
}/**
* Send login OTP
*
* @return void
*/
function wpsc_authenticate_guest_login(el) {var dataform = new FormData(jQuery(el).closest('form')[0]);var email_address = dataform.get('email_address').trim();
if ( ! email_address ) {
alert(supportcandy.translations.req_fields_missing);
return;
}if (!validateEmail(email_address)) {
alert(supportcandy.translations.incorrect_email);
return;
}jQuery(el).text(supportcandy.translations.please_wait);
jQuery.ajax({
url: supportcandy.ajax_url,
type: 'POST',
data: dataform,
processData: false,
contentType: false
}).done(function (res) {
if (typeof(res) == "object") {
alert(supportcandy.translations.something_wrong);
wpsc_get_guest_sign_in();
} else {
jQuery('.auth-inner-container').html(res);
}
}).fail(function (res) {
alert(supportcandy.translations.something_wrong);
window.location.reload();
});
}/**
* Confirm guest login auth
*
* @return void
*/
function wpsc_confirm_guest_login(el) {jQuery('.auth-inner-container').html(supportcandy.loader_html);
var dataform = new FormData(jQuery(el).closest('form')[0]);
jQuery.ajax({
url: supportcandy.ajax_url,
type: 'POST',
data: dataform,
processData: false,
contentType: false
}).done(function (res) {
if (res.isSuccess == 1) {
window.location.reload();
} else {
alert(supportcandy.translations.something_wrong);
wpsc_get_guest_sign_in();
}
});
}
/**
* Get ticket list
*/
function wpsc_get_ticket_list(is_humbargar = false) {supportcandy.current_section = 'ticket-list';if (is_humbargar) wpsc_toggle_humbargar();if (wpsc_is_description_text()) {
if ( !confirm(supportcandy.translations.warning_message)){
return;
} else {
var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden();
if (is_tinymce && tinymce.get('description')) {
var description = tinyMCE.get('description').setContent('');
} else {
var description = jQuery('#description').val('');
}
ticket_id = jQuery('#wpsc-current-ticket').val();
wpsc_clear_saved_draft_reply( ticket_id );
}
}var id = supportcandy.current_ticket_id;
if (id) {
delete supportcandy.current_ticket_id;
wpsc_get_individual_ticket(id);
return;
}wpsc_update_live_agents();// set flag to differenciate between ticket list and individual ticket
supportcandy.ticketListIsIndividual = false;jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active');
jQuery('.wpsc-tickets-nav.ticket-list, .wpsc-humbargar-menu-item.ticket-list').addClass('active');
jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.ticket_list);// set url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('wpsc-section', 'ticket-list');
search_params.delete('ticket-id');
url.search = search_params.toString();
window.history.replaceState({}, null, url.toString());jQuery('.wpsc-body').html(supportcandy.loader_html);var data = {
action: 'wpsc_get_ticket_list',
_ajax_nonce: supportcandy.nonce,
is_frontend: supportcandy.is_frontend
};
search_params.forEach(function(value, key) {
data[key] = value;
});
if (typeof supportcandy.ticketList != 'undefined' && typeof supportcandy.ticketList.filters != 'undefined') {
data.filters = supportcandy.ticketList.filters;
}
jQuery.post(supportcandy.ajax_url, data, function (response) {
jQuery('.wpsc-body').html(response);
wpsc_reset_responsive_style();
});
wpsc_delete_auto_draft();
}/**
* Get individual ticket
*/
function wpsc_get_individual_ticket(id) {jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active');
jQuery('.wpsc-tickets-nav.ticket-list, .wpsc-humbargar-menu-item.ticket-list').addClass('active');
jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.ticket_list);// set url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('wpsc-section', 'ticket-list');
search_params.set('ticket-id', id);
url.search = search_params.toString();
window.history.replaceState({}, null, url.toString());jQuery('.wpsc-body').html(supportcandy.loader_html);// set flag to differenciate between ticket list and individual ticket
supportcandy.ticketListIsIndividual = true;var data = {
action: 'wpsc_get_individual_ticket',
ticket_id: id,
};
search_params.forEach(function(value, key) {
data[key] = value;
});
jQuery.post(supportcandy.ajax_url, data, function (response) {
jQuery('.wpsc-body').html(response);
wpsc_reset_responsive_style();
});
}/**
* Get create ticket form
*/
function wpsc_get_ticket_form(is_humbargar = false) {
supportcandy.current_section = 'new-ticket';if (is_humbargar) wpsc_toggle_humbargar();if (wpsc_is_description_text()) {
if ( confirm(supportcandy.translations.warning_message)){
current_ticket = jQuery('#wpsc-current-ticket').val();
wpsc_clear_saved_draft_reply( current_ticket );
} else{
return;
}
}jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active');
jQuery('.wpsc-tickets-nav.new-ticket, .wpsc-humbargar-menu-item.new-ticket').addClass('active');
jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.new_ticket);wpsc_update_live_agents();// set url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('wpsc-section', 'new-ticket');
search_params.delete('ticket-id');
url.search = search_params.toString();
window.history.replaceState({}, null, url.toString());jQuery('.wpsc-body').html(supportcandy.loader_html);var data = {
action: 'wpsc_get_ticket_form',
_ajax_nonce: supportcandy.nonce
};
search_params.forEach(function(value, key) {
data[key] = value;
});
jQuery.post(supportcandy.ajax_url, data, function (response) {
jQuery('.wpsc-body').html(response);
wpsc_reset_responsive_style();
});
}/**
* Get agent settings
*/
function wpsc_get_user_profile(is_humbargar = false) {supportcandy.current_section = 'my-profile';if (is_humbargar) wpsc_toggle_humbargar();jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active');
jQuery('.wpsc-tickets-nav.my-profile, .wpsc-humbargar-menu-item.my-profile').addClass('active');
jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.my_profile);wpsc_update_live_agents();// set url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('wpsc-section', 'my-profile');
search_params.delete('ticket-id');
url.search = search_params.toString();
window.history.replaceState({}, null, url.toString());jQuery('.wpsc-body').html(supportcandy.loader_html);var data = { action: 'wpsc_get_user_profile' };
search_params.forEach(function(value, key) {
data[key] = value;
});
jQuery.post(supportcandy.ajax_url, data, function (response) {
jQuery('.wpsc-body').html(response);
wpsc_reset_responsive_style();
});
}/**
* Get agent settings
*/
function wpsc_get_agent_profile(is_humbargar = false) {supportcandy.current_section = 'agent-profile';if (is_humbargar) wpsc_toggle_humbargar();jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active');
jQuery('.wpsc-tickets-nav.agent-profile, .wpsc-humbargar-menu-item.agent-profile').addClass('active');
jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.agent_profile);wpsc_update_live_agents();// set url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('wpsc-section', 'agent-profile');
search_params.delete('ticket-id');
url.search = search_params.toString();
window.history.replaceState({}, null, url.toString());jQuery('.wpsc-body').html(supportcandy.loader_html);var data = { action: 'wpsc_get_agent_profile' };
search_params.forEach(function(value, key) {
data[key] = value;
});
jQuery.post(supportcandy.ajax_url, data, function (response) {
jQuery('.wpsc-body').html(response);
wpsc_reset_responsive_style();
jQuery('.wpsc-ap-nav.general').trigger('click');
});
}/**
* Get agent dashboard
*/
function wpsc_get_agent_dashboard(is_humbargar = false) {supportcandy.current_section = 'dashboard';if (is_humbargar) {
wpsc_toggle_humbargar();
}jQuery( '.wpsc-tickets-nav, .wpsc-humbargar-menu-item' ).removeClass( 'active' );
jQuery( '.wpsc-tickets-nav.dashboard, .wpsc-humbargar-menu-item.dashboard' ).addClass( 'active' );
jQuery( '.wpsc-humbargar-title' ).html( supportcandy.humbargar_titles.dashboard );wpsc_update_live_agents();// set url
var url = new URL(window.location.href);
var search_params = url.searchParams;
search_params.set('wpsc-section', 'dashboard');
search_params.delete('ticket-id');
url.search = search_params.toString();
window.history.replaceState({}, null, url.toString());
jQuery( '.wpsc-body' ).html( supportcandy.loader_html );var data = { action: 'wpsc_get_agent_dashboard' };
search_params.forEach(function(value, key) {
data[key] = value;
});jQuery.post(
supportcandy.ajax_url,
data,
function (response) {
jQuery( '.wpsc-body' ).html( response );
wpsc_reset_responsive_style();
jQuery( '.wpsc-ap-nav.general' ).trigger( 'click' );
}
);
}/**
* Get create ticket as guest
*/
function wpsc_get_guest_ticket_form() {jQuery('.wpsc-shortcode-container').html('
');
wpsc_get_ticket_form();
}/**
* Update live agents
*/
function wpsc_update_live_agents() {if (!supportcandy.ticketListIsIndividual) {
return;
}
agent_id = jQuery("#wpsc-current-agent").val();
if (!agent_id) {
return;
}
if (typeof supportcandy.agent_collision === "undefined" || !supportcandy.agent_collision) {
return;
}ticket_id = jQuery("#wpsc-current-ticket").val();
var data = { action: 'wpsc_check_live_agents', agent_id, ticket_id, operation: 'leave', _ajax_nonce: supportcandy.nonce };
jQuery.post(
supportcandy.ajax_url,
data,
function (response) {
}
);
}