_leadclient_phone = '0722132778'; _leadclient_id = 'lc__HiFRkGEZIfrR_ch'; (function ($) { if (typeof ($) === "undefined") { console.err("please install jquery"); return; } var s = {}; try { s = localStorage; } catch (e) {} _lc_refs = JSON.parse(s['_lc_refs'] || '{}'); var changed = false; var url = ""; try { url = new URL(location.href); _lc_fct = url.searchParams.get("fct"); } catch (e) {} if (typeof _lc_fct !== 'undefined' && _lc_fct) { var r = "fct:" + _lc_fct; _lc_refs[r] = ++_lc_refs[r] || 1; changed = true; } try { _lc_cmpn = url.searchParams.get("lc_kw") || url.searchParams.get("keywords") || url.searchParams.get("utm_campaign"); } catch (e) {} if (typeof _lc_cmpn !== 'undefined' && _lc_cmpn) { _lc_refs["keywords"] = _lc_cmpn; changed = true; } try { _lc_gclid = url.searchParams.get("gclid"); } catch (e) {} if (typeof _lc_gclid !== 'undefined' && _lc_gclid) { _lc_refs["gclid"] = _lc_gclid; changed = true; } var referrer = '.direct.'; var full_refferer = _lc_refs["full_refferer"] || document.referrer; if (!_lc_refs["full_refferer"]) { _lc_refs["full_refferer"] = full_refferer; } try { referrer = (new URL(document.referrer)).host; } catch (e) {} if (referrer && location.href.indexOf(referrer) === -1) { _lc_refs[referrer] = ++_lc_refs[referrer] || 1; _lc_refs['referrer'] = referrer; changed = true; } var ref = undefined; try { ref = url.searchParams.get("ref"); } catch (e) {} if (typeof ref !== 'undefined' && ref) { var r = "ref:" + ref; _lc_refs[r] = ++_lc_refs[r] || 1; _lc_refs['ref'] = ref; changed = true; } if (changed) { s['_lc_refs'] = JSON.stringify(_lc_refs); } if (s["_leadclient_id"]) { _leadclient_id = s["_leadclient_id"]; } else { s["_leadclient_id"] = _leadclient_id; } if (s["_leadclient_phone"]) { _leadclient_phone = s["_leadclient_phone"]; } else if (typeof _leadclient_phone !== 'undefined' && _leadclient_phone) { s["_leadclient_phone"] = _leadclient_phone; } if (typeof $.leadClientSubmit != "function") { $.leadClientSubmit = function (v) { var settings = $.extend({ redirect: "", id: _leadclient_id, data: { name: "", phone: "" }, done: function () {}, error: function () {} }, v); if (!settings.id) { if (typeof settings.error == "function") settings.error("no_channel_id"); console.log("LeadClient error: no_channel_id"); return false; } if (!(settings.data.phone || settings.data.email)) { if (typeof settings.error == "function") settings.error("must_contain_phone_or_email"); console.log("LeadClient error: must_contain_phone_or_email " + settings.data.phone + " " + settings.data.email); return false; } return $.ajax({ type: "post", url: "https://app.leadclient.net/get-information/form", data: { 'act': "get-information", 'code': "form", 'service_id': settings.id, 'data': settings.data }, dataType: "json" }).done(function (data) { if (data.success) { if (settings.redirect.length) window.location = settings.redirect; else if (typeof settings.done === "function") settings.done(); console.log("LeadClient success"); return true; } else { console.log("LeadClient error: " + data.error); if (typeof settings.error === "function") settings.error(data.error); return false; } }); } } if (typeof $.leadclientSubmitForm != "function") { $.leadclientSubmitForm = function (form, cb) { if (_lc_sent) { _lc_sent = false; return false; } if(typeof cb === 'undefined') { cb = form[0].submit; } inputs = form.find("input,textarea,select").not("[type=hidden]"); disabledInput = []; data = { ref: _lc_refs['ref'] || _lc_refs['referrer'] || undefined, keywords: _lc_refs['keywords'] || 'unknown', gclid: _lc_refs['gclid'] || undefined, title: document.title, full_refferer: full_refferer || undefined }; phoneInput = inputs.filter("[name*=phone],[type=tel],input[name*=פון],input[placeholder*=פון],input[placeholder*=phone],input[data-original-text*=phone],input[data-original-text*=נייד],input[data-original-text*=פון]"); if (phoneInput.length === 0) { phoneInput = form.find("input").filter(function () { return this.value.match(/^[0-9]{5,}$/); }).first(); } data["phone"] = ""; for (var i = 0; i < phoneInput.length; i++) { disabledInput.push(phoneInput[i].name); data["phone"] += phoneInput[i].value; } mailInput = inputs.filter("input[name*=mail],[type=email],[data-aid*=email],input[name*=מייל],input[placeholder*=מייל],input[placeholder*=mail]:first"); if (mailInput.length === 0) { mailInput = form.find("input").filter(function () { return this.value.match(/\S+@\S+\.\S+/); }).first(); } if (mailInput.length > 0) { disabledInput.push(mailInput[0].name); data["email"] = mailInput[0].value; } nameInput = inputs.filter(function () { return this.name.match(/(name|first|שם)/) || (this.placeholder && this.placeholder.match(/(name|שם)/)/* )|| (this.data-original-text && this.data-original-text.match(/(name|שם)/)*/); }).first(); if (nameInput.length > 0) { disabledInput.push(nameInput[0].name); data["name"] = nameInput[0].value; } inputs.each(function (i, e) { if (disabledInput.indexOf(e.name) === -1) data[e.name] = e.value; }) return $.leadClientSubmit({ data: data, id: form.find("input[name=lc_id],input[value*=lc__]:first").val() || _leadclient_id, done: function () { _lc_sent = true; cb(); }, error: function (error_code) { switch (error_code) { case 'no_channel_id': console.log("Error: There is no channel code."); break; case 'channel_not_found': console.log("Error: The channel was not found"); break; case 'must_contain_phone_or_email': console.log("Error: You must fill in a phone number or an email address"); break; case 'duplicated_lead': console.log("Error: This lead has already been sent"); break; default: console.log("Error: A general error has occurred"); break; } _lc_sent = true; cb(); } }); } } if (typeof $.leadclientAutoSubmit != "function") { $.leadclientAutoSubmit = function (event) { var theForm = $(this); if (theForm.find("input[type=password]").length !== 0) { return true; } if (ret = $.leadclientSubmitForm(theForm)) { event.preventDefault(); return false; } return true; } } if (typeof _leadclient_phone !== 'undefined' && _leadclient_phone) { $('[lc_phone]').text(_leadclient_phone).attr("href", "tel:" + _leadclient_phone); $('[leadclient_phone]').text(_leadclient_phone).attr("href", "tel:" + _leadclient_phone); $('a[ref_phone]').attr("href", "tel:" + _leadclient_phone); $("[href*=tel]").attr("href", "tel:" + _leadclient_phone); $("[href*=tel]").each(function () { this.innerHTML = this.innerHTML.replace(/[0-9\-]{8,}/g, _leadclient_phone) }); } if ((typeof _leadclient_form_inject_service_id !== 'undefined' && _leadclient_form_inject_service_id)) { var elem = "<" + "input type='hidden' name='lc_id' label='leadclient_id' value=\"" + _leadclient_id + "\">" $('form').filter(function () { if ($(this).find("[name=lc_id],[value*=lc__]").length == 0) return false; return true; }).prepend(elem); } if ((typeof _leadclient_auto_form_inject !== 'undefined' && _leadclient_auto_form_inject)) { _lc_sent = false; lc_clicked = false; var inject = function (event, element) { $('form').on('submit', $.leadclientAutoSubmit); $(".avia_ajax_form .button").on('click', function (e) { if (lc_clicked) return false; lc_clicked = true; var f = $(this).closest("form"); return $.leadclientSubmitForm(f); }); } if (typeof _leadclient_auto_form_inject_click !== 'undefined' && _leadclient_auto_form_inject_click) { $('button[type=submit],button[role=button],input[type=submit]').on('click', function (e) { console.log($('button[type=submit],button[role=button],input[type=submit]')); if (lc_clicked) return false; lc_clicked = true; var f = $(this).closest("form"); return $.leadclientSubmitForm(f, function(e){}); }); } else { $(inject); } //$("iframe").on("load", inject); } })(jQuery);