/* CarClick Loader */ var CCLoader = { config: { facebook: false, cols: 4, row_delimiter: '
', loop_images_html: '
  • ', loop_accessories_html: '
  • {TEXT}
  • ', adwords_conversion: '{ADWORDS_CONVERSION_SCRIPT}' }, MEDIA_GALLERY_POSITION: 0, VIEW_ACTIVE: false, MAIN_ACTIVE: false, SEARCH_ACTIVE: '', ACTUAL_LIST_MODE: 'showroom', SHOW_ALL: false, SHOW_ONLY_NEW: false, SHOW_DEALERS_OPTIONS: false, SHOW_CMS_DEALERS_OPTIONS: false, SHOW_PAGE: false, IS_MOBILE: false, ACTUAL_ORDER: null, init: function(container){ //Verificamos se foi passado jma url por parametro e que a mesma seja valida para redirecionar a pagina, logo de todo o cadastro if(arguments[1]) { var urlregex = new RegExp( "^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$"); var urlregexAUX = new RegExp( "^([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$"); if(urlregex.test(arguments[1]) == false) { if(urlregexAUX.test(arguments[1]) == true) CCLoader.SHOW_PAGE = "http://" + arguments[1] ; } else { CCLoader.SHOW_PAGE = arguments[1] ; } } CCLoader.renderCSS(); CCLoader.config.container = jQuery(container).get(0); CCLoader.initNavigationHistory(); if(CCLoader.config.facebook){ CCLoader.config.cols = 3; } if(DataStore.show_dealers){ CCLoader.SHOW_DEALERS_OPTIONS = true; } if(DataStore.show_cms_dealers){ CCLoader.SHOW_CMS_DEALERS_OPTIONS = true; } }, renderCSS: function(){ if(CCLoader.config.facebook){ var style = ''; } else { var style = ''; } jQuery('body').append(style); }, renderMain: function(){ if(CCLoader.SEARCH_ACTIVE){ var query = CCLoader.SEARCH_ACTIVE CCLoader.search(query); } else { var template = MainTemplate.replace(/\[total\]/g,DataStore.total); template = template.replace(/\[from\]/g, 1); template = template.replace(/\[to\]/g, DataStore.total); template = template.replace(/\[query\]/g, ''); if(DataStore.show_all){ CCLoader.SHOW_ALL = true; CCLoader.SHOW_ONLY_NEW = false; template = template.replace(/\[PAGE_TITLE\]/g, 'Resultado da pesquisa'); } else { if(DataStore.show_new){ CCLoader.SHOW_ALL = false; CCLoader.SHOW_ONLY_NEW = true; template = template.replace(/\[PAGE_TITLE\]/g, 'Ofertas de veículos Zero KM'); } else { CCLoader.SHOW_ALL = false; CCLoader.SHOW_ONLY_NEW = false; template = template.replace(/\[PAGE_TITLE\]/g, 'Showroom de Veículos Seminovos'); } } CCLoader.config.container.innerHTML = template; CCLoader.renderList(); } CCLoader.renderFilters(); CC_Stats.addAction({action: 'render-website-list'}); }, renderFilters: function(){ var filter_item_template = '
  • {term}({count})
  • '; if(DataStore.filters){ // marca if(DataStore.filters.facet_manufacturer && DataStore.filters.facet_manufacturer.total){ var filter_manufacturer_html = ''; for(var i = 0; i < DataStore.filters.facet_manufacturer.terms.length; i++){ var item = DataStore.filters.facet_manufacturer.terms[i]; if(!CCLoader.hasFilterApplied(item.term)){ filter_manufacturer_html+= filter_item_template.replace(/\{term\}/g, item.term).replace(/\{count\}/g, item.count); } } var container = CCLoader.config.container; container.innerHTML = container.innerHTML.replace(/\[LOOP_MANUFACTURER_FILTER\]/g, filter_manufacturer_html); jQuery('.filter-manufacturer').show(); } // modelo if(DataStore.filters.facet_model && DataStore.filters.facet_model.total){ var filter_model_html = ''; for(var i = 0; i < DataStore.filters.facet_model.terms.length; i++){ var item = DataStore.filters.facet_model.terms[i]; if(!CCLoader.hasFilterApplied(item.term)){ filter_model_html+= filter_item_template.replace(/\{term\}/g, item.term).replace(/\{count\}/g, item.count); } } var container = CCLoader.config.container; container.innerHTML = container.innerHTML.replace(/\[LOOP_MODEL_FILTER\]/g, filter_model_html); jQuery('.filter-model').show(); } } }, hasFilterApplied: function(term){ var query = jQuery(CCLoader.config.container).find('form input[name=q]').val(); return query.indexOf(term) != -1 ? true : false; }, backToMain: function(){ CCLoader.VIEW_ACTIVE = false; CCLoader.MAIN_ACTIVE = true; document.location.hash = ''; CCLoader.renderMain(); }, renderList: function(){ CCLoader.MAIN_ACTIVE = true; CCLoader.VIEW_ACTIVE = false; var container = CCLoader.config.container; var cols = 0; var template_loop = ''; DataStore.hits.sort(function orderVehicles(a,b){ if(parseInt(a._source.sequence) < parseInt(b._source.sequence)) return -1; if(parseInt(a._source.sequence) > parseInt(b._source.sequence)) return 1; return 0; }); if(DataStore.hits.length){ for(var i = 0; i parseInt(b.order) ? 1 : -1 }); if(veiculo.sync_brdealer){ var template = ItemTemplate.replace('[url_imagem]', 'https://assets.disaltecnologia.com.br/inventory/53a1c0a85717d733e633b3bb/' + imagesArr[0].path); } else { var template = ItemTemplate.replace('[url_imagem]', 'https://assets.disaltecnologia.com.br/inventory/53a1c0a85717d733e633b3bb/' + DataStore.hits[i]._id + '/' + imagesArr[0].path.replace('.jpg','-2.jpg').replace('.png','-2.jpg').replace('.jpeg','-2.jpg').replace('.webp','-2.webp')); } } else { var template = ItemTemplate.replace('[url_imagem]', 'https://assets.disaltecnologia.com.br/no-image-g.jpg'); } template = template.replace(/\[id\]/g, DataStore.hits[i]._id); template = template.replace(/\[ano\]/g, veiculo.model_year); template = template.replace(/\[modelo\]/g, veiculo.name); template = template.replace(/\[cor\]\,/g, veiculo.color ? veiculo.color + ',' : ''); template = template.replace(/\[combustivel\]/g, veiculo.fuel); template = template.replace(/\[transmissao\]/g, veiculo.gearbox); template = template.replace(/\[portas\]/g, parseInt(veiculo.doors) ? veiculo.doors + ' portas,' : '') template = template.replace(/\[quilometragem\]/g, veiculo.odometer ? ', ' + CCLoader.number_format(veiculo.odometer, 0, ',', '.') + 'km' : (parseInt(veiculo.new) ? 'Zero KM' : '')); //Modificar aqui.. if(veiculo.price && parseFloat(veiculo.price) && veiculo.hide_price == false ){ template = template.replace(/\[preco\]/g, CCLoader.number_format(veiculo.price, 2, ',','.')); } else { if(veiculo.price && parseFloat(veiculo.price) && typeof veiculo.hide_price === 'undefined'){ template = template.replace(/\[preco\]/g, CCLoader.number_format(veiculo.price, 2, ',','.')); }else{ template = template.replace(/\[preco\]/g, 'consulte'); } } template = template.replace('[url_proposta]', 'javascript: CCLoader.contact(\''+DataStore.hits[i]._id+'\');'); template = template.replace('[url_veiculo]', document.location.href + '#!/view/' + DataStore.hits[i]._id); var accessories = ''; for(var a = 0; a < veiculo.accessories.slice(0,10).length; a++){ if(veiculo.accessories[a]){ accessories += CCLoader.config.loop_accessories_html.replace('{TEXT}', veiculo.accessories[a]); } } template = template.replace('[LOOP_ACESSORIOS]', accessories); var accessories_detailed = ''; for(var a = 0; a < veiculo.accessories.slice(0,20).length; a++){ if(veiculo.accessories[a]){ accessories_detailed += veiculo.accessories[a]; if(a < (veiculo.accessories.slice(0,20).length - 1)){ accessories_detailed+= ', '; } } } template = template.replace('[LOOP_ACESSORIOS_DETAILED]', accessories_detailed); template_loop += template; if(CCLoader.config.cols && CCLoader.config.row_delimiter){ if(cols == CCLoader.config.cols){ cols = 1; //template_loop += CCLoader.config.row_delimiter; } else { cols++; } } } jQuery('.cc-list-result, .cc-list-toolbar').show(); container.innerHTML = container.innerHTML.replace(/\[LOOP_ITEMS\]/g,template_loop); var _cols = 0; var max_cols = CCLoader.config.cols; // if(CCLoader.config.facebook){ // max_cols = max_cols - 1; // } jQuery('.cc-list-result .item-clear').each(function(){ jQuery(this).css('clear',''); }) jQuery('.cc-list-result .item-clear').each(function(){ if(_cols == max_cols - 1){ _cols = 0; jQuery(this).css('clear','both'); } else { _cols++; } }) } else { jQuery('.cc-list-result, .cc-list-toolbar').hide(); jQuery('#no-results').show(); } if(CCLoader.ACTUAL_ORDER){ jQuery('select#order-by option').each(function(){ if(jQuery(this).val() == CCLoader.ACTUAL_ORDER){ jQuery(this).attr('selected','selected'); } }); } if(CCLoader.ACTUAL_LIST_MODE != 'showroom'){ CCLoader.setListMode(jQuery('.list-modes a.link-mode-' + CCLoader.ACTUAL_LIST_MODE).get(), CCLoader.ACTUAL_LIST_MODE); } }, setListMode: function(target, mode){ CCLoader.ACTUAL_LIST_MODE = mode; jQuery('.cc-list-result').attr('class', 'cc-list-result'); jQuery('.cc-list-result').addClass('mode-' + mode); jQuery(target).parent().find('a').removeClass('active'); jQuery(target).addClass('active'); var _cols = 0; var max_cols = CCLoader.config.cols; if(mode == 'detailed'){ max_cols = max_cols - 1; } jQuery('.cc-list-result .item-clear').each(function(){ jQuery(this).css('clear',''); }) jQuery('.cc-list-result .item-clear').each(function(){ if(_cols == max_cols - 1){ _cols = 0; jQuery(this).css('clear','both'); } else { _cols++; } }) }, view: function(id){ CCLoader.VIEW_ACTIVE = true; CCLoader.MAIN_ACTIVE = false; document.location.hash = '!/view/' + id; container = CCLoader.config.container; var veiculo = CCLoader.getItem(id); var template = ViewTemplate; if(veiculo.images && veiculo.images.length){ var imagesArr = veiculo.images; imagesArr = imagesArr.sort(function(a, b){ return parseInt(a.order) > parseInt(b.order) ? 1 : -1 }); if(veiculo.sync_brdealer){ template = template.replace('[url_imagem]', 'https://assets.disaltecnologia.com.br/inventory/53a1c0a85717d733e633b3bb/' + imagesArr[0].path); } else { template = template.replace('[url_imagem]', 'https://assets.disaltecnologia.com.br/inventory/53a1c0a85717d733e633b3bb/' + id + '/' + imagesArr[0].path.replace('.jpg','-4.jpg').replace('.png','-4.jpg').replace('.jpeg','-4.jpg').replace('.webp','-4.webp')); } } else { veiculo.images = []; template = template.replace('[url_imagem]', 'https://assets.disaltecnologia.com.br/no-image-g.jpg'); } template = template.replace(/\[modelo\]/g, veiculo.name); template = template.replace(/\[id\]/g, id); template = template.replace(/\[veiculo_id\]/g, id); template = template.replace(/\[ano\]/g, veiculo.model_year); template = template.replace(/\[cor\]\,/g, veiculo.color ? veiculo.color + ',' : ''); template = template.replace(/\[portas\]/g, parseInt(veiculo.doors) ? veiculo.doors + ' portas,' : ''); if(veiculo.price && parseFloat(veiculo.price) && veiculo.hide_price == false ){ template = template.replace(/\[preco\]/g, CCLoader.number_format(veiculo.price, 2, ',','.')); } else { if(veiculo.price && parseFloat(veiculo.price) && typeof veiculo.hide_price === 'undefined'){ template = template.replace(/\[preco\]/g, CCLoader.number_format(veiculo.price, 2, ',','.')); }else{ template = template.replace(/\[preco\]/g, 'consulte'); } } template = template.replace(/\[combustivel\]/g, veiculo.fuel); template = template.replace(/\[quilometragem\]/g, veiculo.odometer ? ', ' + CCLoader.number_format(veiculo.odometer, 0, ',', '.') + 'km' : (parseInt(veiculo.new) ? ', Zero KM' : '')); template = template.replace(/\[transmissao\]/g, veiculo.gearbox); template = template.replace(/\[OBSERVATIONS\]/g, veiculo.observation ? veiculo.observation : ''); template = template.replace(/\[DETAILS\]/g, veiculo.details ? veiculo.details : ''); template = template.replace(/\[DEALER_NAME\]/g, veiculo.dealer_name ? veiculo.dealer_name : ''); template = template.replace(/\[DEALER_TELEPHONE\]/g, veiculo.dealer_telephone ? veiculo.dealer_telephone : ''); template = template.replace(/\[DEALER_STREET\]/g, veiculo.dealer_street ? veiculo.dealer_street : ''); template = template.replace(/\[DEALER_NUMBER\]/g, veiculo.dealer_street_number ? veiculo.dealer_street_number : ''); template = template.replace(/\[DEALER_NEIGHBORHOOD\]/g, veiculo.dealer_neighborhood ? veiculo.dealer_neighborhood : ''); template = template.replace(/\[DEALER_CITY\]/g, veiculo.dealer_city ? veiculo.dealer_city : ''); template = template.replace(/\[DEALER_REGION\]/g, veiculo.dealer_region ? veiculo.dealer_region : ''); template = template.replace(/\[DEALER_POSTCODE\]/g, veiculo.dealer_postal_code ? veiculo.dealer_postal_code : ''); if(CCLoader.SHOW_DEALERS_OPTIONS){ var dealer_options = ''; for(var i = 0; i < DataStore.dealers.length; i++){ dealer_options += ''; } template = template.replace(/\[LOOP_OPTIONS_DEALERS\]/, dealer_options); } else if(CCLoader.SHOW_CMS_DEALERS_OPTIONS){ var dealer_options = ''; for(var i = 0; i < DataStore.dealers.length; i++){ dealer_options += ''; } template = template.replace(/\[LOOP_OPTIONS_DEALERS\]/, dealer_options); } var template_thumbs = ''; veiculo.images.sort(function orderImages(a,b){ if (parseInt(a.order) < parseInt(b.order)) return -1; if (parseInt(a.order) > parseInt(b.order)) return 1; return 0; }); for(var i = 0; i < veiculo.images.length; i++){ if(veiculo.sync_brdealer){ template_thumbs += CCLoader.config.loop_images_html.replace('{URL}', 'https://assets.disaltecnologia.com.br/inventory/53a1c0a85717d733e633b3bb/' + veiculo.images[i].path); } else { template_thumbs += CCLoader.config.loop_images_html.replace('{URL}', 'https://assets.disaltecnologia.com.br/inventory/53a1c0a85717d733e633b3bb/' + id + '/' + veiculo.images[i].path.replace('.jpg','-4.jpg').replace('.png','-4.jpg').replace('.jpeg','-4.jpg').replace('.webp','-4.webp')); } } if(CCLoader.IS_MOBILE){ if(!veiculo.images.length){ template_thumbs += CCLoader.config.loop_images_html.replace('{URL}', 'https://assets.disaltecnologia.com.br/no-image-g.jpg'); } } template = template.replace(/\[LOOP_IMAGES_THUMB\]/g, template_thumbs); var template_slider_zoom = ''; for(var i = 0; i < veiculo.images.length; i++){ if(veiculo.sync_brdealer){ template_slider_zoom += '
  • '; } else { template_slider_zoom += '
  • '; } } template = template.replace(/\[GALLERY_LOOP_SLIDER_ZOOM\]/g, template_slider_zoom); var template_slider_thumbnails = ''; for(var i = 0; i < veiculo.images.length; i++){ if(veiculo.sync_brdealer){ template_slider_thumbnails += '
  • '; } else { template_slider_thumbnails += '
  • '; } } template = template.replace(/\[GALLERY_LOOP_SLIDER_RIGHT_THUMBNAILS\]/g, template_slider_thumbnails); var template_slider_top_thumbnails = ''; for(var i = 0; i < veiculo.images.length; i++){ if(veiculo.sync_brdealer){ template_slider_top_thumbnails += '
  • '; } else { template_slider_top_thumbnails += '
  • '; } } template = template.replace(/\[GALLERY_LOOP_TOP_THUMBNAILS\]/g, template_slider_top_thumbnails); var template_accessories = ''; for(var i = 0; i < veiculo.accessories.length; i++){ if(veiculo.accessories[i]){ template_accessories += CCLoader.config.loop_accessories_html.replace('{TEXT}', veiculo.accessories[i]); } } template = template.replace(/\[LOOP_ACCESSORIES\]/g, template_accessories); var template_additionals = ''; veiculo.additionals = []; if(parseInt(veiculo.one_owner)) veiculo.additionals.push('Único dono'); if(parseInt(veiculo.licensed)) veiculo.additionals.push('Licenciado'); if(parseInt(veiculo.ipva)) veiculo.additionals.push('IPVA pago'); if(parseInt(veiculo.dealership_revision)) veiculo.additionals.push('Revisões em concessionária'); if(parseInt(veiculo.revised_with_warranty)) veiculo.additionals.push('Revisado com garantia'); if(parseInt(veiculo.factory_warranty)) veiculo.additionals.push('Garantia de fábrica'); if(parseInt(veiculo.imported)) veiculo.additionals.push('Importado'); if (parseInt(veiculo.armored)) veiculo.additionals.push('Blindado'); for(var i = 0; i < veiculo.additionals.length; i++){ if(veiculo.additionals[i]){ template_additionals += '
  • ' + veiculo.additionals[i] + '
  • '; } } template = template.replace(/\[LOOP_ADDITIONALS\]/g, template_additionals); container.innerHTML = template; if(!veiculo.observation){ jQuery('.cc-view-car .observations').hide(); } if(!veiculo.details){ jQuery('.cc-view-car .details').hide(); } if(CCLoader.SHOW_DEALERS_OPTIONS){ jQuery('#dealer_options_container').show(); jQuery('#dealer_options_container select[name=_dealer_id]').attr('name','dealer_id').addClass('required').attr('data-required-message','Selecione a loja'); }else if(CCLoader.SHOW_CMS_DEALERS_OPTIONS){ jQuery('#dealer_options_container').show(); jQuery('#dealer_options_container select[name=_dealer_id]').attr('name','cms_dealer_id').addClass('required').attr('data-required-message','Selecione a loja'); } else { jQuery('#dealer_options_container').remove(); } if(CCLoader.IS_MOBILE){ jQuery("#media-gallery").owlCarousel({ navigation : false, slideSpeed : 300, paginationSpeed : 400, singleItem:true }); } if(CCLoader.getNextCar(id)){ jQuery('.cc-view-car-header .navigation-links .next').show(); CCLoader.NEXT_CAR_ID = CCLoader.getNextCar(id); } else { jQuery('.cc-view-car-header .navigation-links .next').hide(); } if(CCLoader.getPreviousCar(id)){ jQuery('.cc-view-car-header .navigation-links .prev').show(); CCLoader.PREVIOUS_CAR_ID = CCLoader.getPreviousCar(id); } else { jQuery('.cc-view-car-header .navigation-links .prev').hide(); } window.scrollTo(0,0); CC_Stats.addAction({action: 'render-car-website', id: id}); }, getNextCar: function(id){ for(var i = 0; i < DataStore.hits.length; i++){ var item = DataStore.hits[i]; if(item._id == id){ if(DataStore.hits[i + 1] != undefined && DataStore.hits[i + 1]._id){ return DataStore.hits[i + 1]._id; } } } return false; }, getPreviousCar: function(id){ for(var i = 0; i < DataStore.hits.length; i++){ var item = DataStore.hits[i]; if(item._id == id){ if(DataStore.hits[i - 1] != undefined && DataStore.hits[i - 1]._id){ return DataStore.hits[i - 1]._id; } } } return false; }, openMediaGallery: function(target){ var img = jQuery(target); jQuery('.main-accessories').hide(); jQuery('#media-gallery,#media-gallery-top-bar,.media-accessories').show(); // if(CCLoader.config.facebook){ // jQuery('.contact, .col-info').css('visibility', 'hidden'); // } CCLoader.mediaGalleryPosition(img.parent().index(), arguments[1]); CC_Stats.addAction({action: 'render-website-gallery'}); }, closeMediaGallery: function(){ jQuery('.main-accessories').show(); jQuery('#media-gallery,#media-gallery-top-bar,.media-accessories').hide(); //jQuery('.contact, .col-info').css('visibility', 'visible'); CCLoader.mediaGalleryPosition(0, false); }, mediaGalleryPosition: function(){ if(arguments[0] != undefined){ CCLoader.MEDIA_GALLERY_POSITION = parseInt(arguments[0]); // move sliders para a foto da posição var img_height = jQuery('#media-gallery #slider-right-thumbnails li img:first').height(); var slider_height = jQuery('#media-gallery #slider-right-thumbnails').height(); var slider_length = jQuery('#media-gallery #slider-right-thumbnails li img').length; console.log(arguments) var time = arguments[1] != undefined && arguments[1] === false ? 0 : 500; var next_right_thumbs_position = -(jQuery('#media-gallery #slider-right-thumbnails li img').eq(arguments[0]).position().top) - img_height; if(next_right_thumbs_position > -(slider_height - img_height)){ jQuery('#media-gallery #slider-right-thumbnails').animate({ top: next_right_thumbs_position }, time); } else { jQuery('#media-gallery #slider-right-thumbnails').animate({ top: -(slider_height - (img_height * 2)) }, time); } jQuery('#media-gallery #slider-zoom').animate({ top: -(jQuery('#media-gallery #slider-zoom li img').eq(arguments[0]).position().top) }, time); } return CCLoader.MEDIA_GALLERY_POSITION; }, search: function(){ if(typeof arguments[0] == 'string'){ CCLoader.SEARCH_ACTIVE = true; var query = arguments[0]; } else { var form = arguments[0]; var query = jQuery(form).find('input[name=q]').val(); } CCLoader.SEARCH_ACTIVE = query; var url_search = 'https://www.carclick.com.br/plugin/53a1c0a85717d733e633b3bb/search?'; if(DataStore.show_new){ CCLoader.SHOW_ALL = false; CCLoader.SHOW_ONLY_NEW = true; url_search += 'show_new=true'; } if(DataStore.show_all){ CCLoader.SHOW_ALL = true; CCLoader.SHOW_ONLY_NEW = false; url_search += '&show_all=true'; } if(CCLoader.SHOW_CMS_DEALERS_OPTIONS){ url_search += '&show_cms_dealers=1'; } if(DataStore.show_premium){ url_search += '&show_premium=1'; } jQuery.post(url_search, {q: query}, function(result){ DataStore = jQuery.parseJSON(result); var template = MainTemplate.replace(/\[total\]/g,DataStore.total); template = template.replace(/\[from\]/g, 1); template = template.replace(/\[to\]/g, DataStore.total); template = template.replace(/\[query\]/g, query); template = template.replace(/\[PAGE_TITLE\]/g, 'Resultado da pesquisa'); CCLoader.config.container.innerHTML = template; CCLoader.renderFilters(); CCLoader.renderList(); CC_Stats.addAction({action: 'search-website', q: query, results: DataStore.total}); }); }, setDelaer: function(target){ //Busca do select por apenas um delaer de um grupo.. if(typeof arguments[0] == 'string'){ CCLoader.SEARCH_ACTIVE = true; var query = arguments[0]; CCLoader.SEARCH_ACTIVE = false; } else { var form = arguments[0]; var query = jQuery(form).parents('form:first').find('input[name=q]').val(); CCLoader.SEARCH_ACTIVE = query; } // query = "*" ; // CCLoader.SEARCH_ACTIVE = query; var url_search = 'https://www.carclick.com.br/plugin/53a1c0a85717d733e633b3bb/search?'; if(DataStore.show_new){ CCLoader.SHOW_ALL = false; CCLoader.SHOW_ONLY_NEW = true; url_search += 'show_new=true'; } if(DataStore.show_all){ CCLoader.SHOW_ALL = true; CCLoader.SHOW_ONLY_NEW = false; url_search += '&show_all=true'; } if(CCLoader.SHOW_CMS_DEALERS_OPTIONS){ url_search += '&show_cms_dealers=1'; } var option_selected = jQuery("#order-by option:selected" ).val() ; //Adicionamos mais um parametro if(typeof option_selected != 'undefined') url_search += '&search_dealer_id=' + option_selected; jQuery.post(url_search, {q: query}, function(result){ DataStore = jQuery.parseJSON(result); var template = MainTemplate.replace(/\[total\]/g,DataStore.total); template = template.replace(/\[from\]/g, 1); template = template.replace(/\[to\]/g, DataStore.total); template = template.replace(/\[query\]/g, query); template = template.replace(/\[PAGE_TITLE\]/g, 'Resultado da pesquisa'); CCLoader.config.container.innerHTML = template; CCLoader.renderFilters(); CCLoader.renderList(); CC_Stats.addAction({action: 'search-website', q: query, results: DataStore.total}); jQuery('#order-by').val(DataStore.option_delaer_search_selected); }); }, applyFilter: function(filter){ var query = jQuery(CCLoader.config.container).find('form input[name=q]').val(); CCLoader.search(query.length ? query + ' ' + filter : filter); }, setOrder: function(target){ var order = jQuery(target).val(); CCLoader.ACTUAL_ORDER = order; if(DataStore.hits){ if(order == 'price_asc'){ DataStore.hits.sort(function(a,b){ return a._source.price - b._source.price; }) } else if(order == 'price_desc') { DataStore.hits.sort(function(a,b){ return -(a._source.price - b._source.price); }) } else { DataStore.hits.sort(function(a,b){ return -(a._score - b._score); }) } var html = '[LOOP_ITEMS]
    '; jQuery('.cc-container-list').html(html); CCLoader.renderList(); } }, sendContact: function(target){ var form = target; var errors = 0; jQuery(form).find('input.required, select.required, textarea.required').each(function(){ if(jQuery(this).val() == '' || !jQuery(this).val()){ alert(jQuery(this).attr('data-required-message')); jQuery(this).focus(); errors++; return false; } }); if(errors) return false; // UTM function querystring(){ return document.location.search ? document.location.search.substr(1).split('&').map( function(v){ return v.split('='); } ).reduce( function(prev, curr) { prev[curr[0]] = curr[1]; return prev; }, {}) : undefined; } var qs = querystring(); if(qs && qs.utm_source){ var textValue = $(".textarea-message").val(); var qsHTML = ''; qsHTML+= "\n\nSOURCE: " + qs.utm_source + "\n"; qsHTML+= "MEDIUM: " + qs.utm_medium + "\n"; qsHTML+= "CONTENT: " + qs.utm_content + "\n"; qsHTML+= "CAMPANHA: " + qs.utm_campaign + "\n"; var content = textValue + qsHTML; $(".textarea-message").val(content); } // var button_html = jQuery(form).find('button.btn-success').html(); jQuery(form).find('button.btn-success').attr('disabled','disabled').html('Enviando dados...'); jQuery.post("https://www.carclick.com.br/plugin/53a1c0a85717d733e633b3bb/contact", jQuery(form).serialize(), function(json){ if(json.success){ $('body').append('