CarHub

Carros, motos e caminhões de revendas e de donos — fale direto com quem vende.

+ Anunciar imóvel Cadastrar minha imobiliária

Quer anunciar o seu imóvel?

Imobiliárias no CarHub

"); w.document.close(); w.focus(); setTimeout(function(){ w.print(); }, 300); }; wrap.style.display = "block"; return true; } function watchOk(okId, fn){ var ok = document.getElementById(okId); if (!ok) return; var built = false; setInterval(function(){ var vis = ok.style.display === "block"; if (vis && !built) { built = true; fn(); } if (!vis) built = false; }, 600); } /* ---------- QR DO PERFIL ---------- */ if (CFG.profile) { (function(){ var P = CFG.profile; watchOk(P.okId, function(){ if (P.type === "agencyLink") { var tries = 0; var iv = setInterval(function(){ tries++; var link = document.getElementById("agencyPageLink"); var href = link ? link.getAttribute("href") : null; if (!href || href.charAt(0) !== "/" || href.length < 2) { if (tries > 25) clearInterval(iv); return; } clearInterval(iv); var nameEl = document.getElementById("mineName"); renderQr(P.prefix, location.origin + href, nameEl ? nameEl.textContent : "", TXT.profile); }, 600); } else { setTimeout(function(){ var inp = document.getElementById(P.inputId); var url = P.url ? (location.origin + P.url) : (location.origin + location.pathname.replace(/\.html$/, "")); renderQr(P.prefix, url, inp ? inp.value.trim() : "", TXT.profile); }, 350); } }); })(); } if (CFG.profile2) { (function(){ var P = CFG.profile2; watchOk(P.okId, function(){ setTimeout(function(){ var inp = document.getElementById(P.inputId); var url = location.origin + location.pathname.replace(/\.html$/, ""); renderQr(P.prefix, url, inp ? inp.value.trim() : "", TXT.profile2); }, 350); }); })(); } /* ---------- QR DO ANÚNCIO ---------- */ var lastTitle = ""; var createdListing = null; if (CFG.listing && CFG.listing.apiTable) { try { var origFetch = window.fetch; window.fetch = function(input, init){ var url = (typeof input === "string") ? input : ((input && input.url) || ""); var method = ((init && init.method) || (input && input.method) || "GET") + ""; var p = origFetch.apply(this, arguments); if (method.toUpperCase() === "POST" && url.indexOf("/rest/v1/" + CFG.listing.apiTable) > -1) { p.then(function(r){ try { r.clone().json().then(function(j){ if (Array.isArray(j) && j[0] && j[0].code) createdListing = j[0]; }).catch(function(){}); } catch (e) {} }).catch(function(){}); } return p; }; } catch (e) {} } if (CFG.listing) { (function(){ var Li = CFG.listing; var form = document.getElementById(Li.formId); if (form) form.addEventListener("submit", function(){ var t = document.getElementById(Li.titleId); lastTitle = t ? t.value.trim() : ""; }, true); watchOk(Li.okId, function(){ if (Li.apiTable && createdListing && createdListing.code) { var urlC = location.origin + CFG.path + "#codigo-" + createdListing.code; var nameC = (createdListing.title || lastTitle || "") + " · Cod: " + createdListing.code; if (renderQr(Li.prefix, urlC, nameC, TXT.listing)) { setTimeout(function(){ var w = document.getElementById(Li.prefix + "Wrap"); if (w) w.scrollIntoView({ block: "center", behavior: "smooth" }); }, 500); } return; } var tries = 0; var iv = setInterval(function(){ tries++; var cards = document.querySelectorAll("#propGrid .prop-card"); var found = null, firstWithCode = null; for (var i = 0; i < cards.length; i++) { var tx = cards[i].textContent || ""; var m = /Cod:\s*(H[A-Z0-9]{4})/.exec(tx) || /\b(H[A-Z0-9]{4})\b/.exec(tx); if (!m) continue; var cand = { code: m[1], title: (cards[i].querySelector("h3") || {}).textContent || "" }; if (!firstWithCode) firstWithCode = cand; if (lastTitle && cand.title.trim() === lastTitle) { found = cand; break; } } var pick = found || firstWithCode; if (!pick) { if (tries > 25) clearInterval(iv); return; } clearInterval(iv); var url = location.origin + CFG.path + "#codigo-" + pick.code; var name = (pick.title || lastTitle || "") + " · Cod: " + pick.code; if (renderQr(Li.prefix, url, name, TXT.listing)) { setTimeout(function(){ var w = document.getElementById(Li.prefix + "Wrap"); if (w) w.scrollIntoView({ block: "center", behavior: "smooth" }); }, 500); } }, 600); }); })(); } /* ---------- Deep link do anúncio: #codigo-HXXXX abre o anúncio ---------- */ if (CFG.deepLink) { var done = false; function codigoLink(){ if (done) return; var m = /^#codigo-(H[A-Z0-9]{4})/.exec(location.hash || ""); if (!m) return; var code = m[1], tries = 0; var iv = setInterval(function(){ tries++; var cards = document.querySelectorAll("#propGrid .prop-card"); for (var i = 0; i < cards.length; i++) { if ((cards[i].textContent || "").indexOf(code) > -1) { clearInterval(iv); done = true; var card = cards[i]; card.scrollIntoView({ block: "center" }); card.style.outline = "3px solid #FF6600"; setTimeout(function(){ card.style.outline = ""; }, 3500); setTimeout(function(){ try { card.click(); } catch (e) {} }, 500); return; } } if (tries > 40) clearInterval(iv); }, 500); } window.addEventListener("load", function(){ setTimeout(codigoLink, 700); }); window.addEventListener("hashchange", function(){ done = false; codigoLink(); }); ["countrySel", "stateSel", "citySel"].forEach(function(id){ var el = document.getElementById(id); if (el) el.addEventListener("change", function(){ setTimeout(function(){ done = false; codigoLink(); }, 900); }); }); } })();