function ajaxpopulate( data ) {
jQuery('.vin').addClass('success');
jQuery('#error').removeClass('activeError');
jQuery('.loading').removeClass('activeLoading');
jQuery('#stm_sell_a_car_form').removeClass('activeSell');
jQuery('#stm_motors_vin_decoder span').addClass('activeSpan');
let html = '
';
let count = 0;
jQuery.each(data, function (title, colum) {
let ctr = 0;
let classeqip = '';
let _head = '';
let _class = count === 0 ? 'vc_toggle_active' : '';
html += '
' + title.toUpperCase() + '
';
html += '
';
html += '
';
let trin = [];
count++;
classeqip = title;
jQuery.each(colum, function (index, elem) {
let elemlength = Object.keys(elem).length;
for (i = 0; i -1) _head += '';
_head += '| ';
_head += '' + key.split(/(?=[A-Z])/).join(" ").toUpperCase() + ' | ';
_head += '' + value + ' |
| | ';
ctr++;
if (jQuery.inArray(ctr , trin)> -1) _head += '
';
}
});
});
html += _head + '
';
});
stm_show_modal(html);
}
function stm_show_modal(html) {
jQuery('.stm_vin_info').html(html);
jQuery('.vc_toggle, .vc_toggle_').click(function () {
jQuery(this).toggleClass('vc_toggle_active');
});
jQuery('#stm_vim_history').show();
jQuery('#request-stm_vim_history .vc_toggle ').click(function (event) {
if (event.target.className !== 'vc_toggle_title' && event.target.className !== 'vc_toggle_icon' && event.target.className !== 'accordion__title') {
jQuery(this).addClass('vc_toggle_active');
}
});
}
(function ($) {
$('.vin').on('input', function () {
$('.vin').removeClass('error_vin success');
$('#error').removeClass('activeError');
$('#stm_motors_vin_decoder').removeClass('activeVin');
$('#stm_motors_vin_decoder span').removeClass('activeSpan');
$('.error_message').css('display', 'none');
});
document.getElementsByClassName("sample_vin")[0].addEventListener('click', function () {
$(".vin").val('WBABW33426PX70804');
});
function stm_vin_error() {
$('.vin').addClass('error_vin');
$('#error').addClass('activeError');
$('#stm_motors_vin_decoder').addClass('activeVin');
$('.loading').removeClass('activeLoading');
$('.error_message').css('display', 'block');
stm_not_obj();
}
function stm_not_obj() {
let html = '
Whoops, looks like something went wrong. Please and try again
';
stm_show_modal(html);
}
$('#checkVin').click(function (e) {
e.preventDefault();
let vin = $('.vin').val();
if(!vin.trim()) return;
$('.loading').addClass('activeLoading');
$('#stm_sell_a_car_form').addClass('activeSell');
var ajaxurl = 'https://detalshop.az/wp-admin/admin-ajax.php';
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
'vin': vin,
'shortcode': 'yes',
'action': 'stm_vin_decoder_ajax_callback',
},
success: function (data) {
var dataspec = {};
var dt = [];
$('#checkVin').text("Recheck");
if (data == null || data == 'undefined' ) {
stm_vin_error();
return;
}
if ((typeof data) === "object" && Object.keys(data).length) {
ajaxpopulate( data );
} else {
stm_vin_error();
}
},
error: function () {
stm_vin_error();
}
});
});
})(jQuery)