$( document ).ready(function() { let protocol = location.protocol; if (protocol=="http:") { $("form[action='https://gramotadel.express/api/v1/tilda-create/']").html("

Форма может работать только по https

").css("visibility", "visible"); $("form[action='https://dimaker.app/api/v1/tilda-create/']").html("

Форма может работать только по https

").css("visibility", "visible"); } else { setTimeout(function() { $("form").each(function() { let thForm=$(this); let action=thForm.attr("action"); if (action.indexOf("https://gramotadel.ru/api/v1/tilda-create/") !== -1 || action.indexOf("https://gramotadel.express/api/v1/tilda-create/") !== -1 || action.indexOf("https://dimaker.app/api/v1/tilda-create/") !== -1) { let secure=$("input[name='secure']",thForm).val(); let docId=$("input[name='doc_id']", thForm).val(); let maEmail=$("input[name='ma_email']").val(); if (secure) { $.getJSON("https://gramotadel.express/api/v1/tilda-form/", {"secure":secure, "doc_id":docId, "ma_email":maEmail}) .done(function (data) { if (data["result"] == "form") { thForm.css("visibility", "visible"); } if (data["result"] == "getfile") { thForm.before(''); thForm.empty().remove(); } if (data["result"] == "getall") { thForm.before(''); thForm.empty().remove(); window.addEventListener("message", (ev) => {if(ev.data.type && ev.data.type === "gramotadel-resize-iframe") { let el=document.getElementById("gramotadel_iframe"); el.style.height = ev.data.payload.height + "px"; el.className="b-show";}}, false); } }) .fail(function () { thForm.html("

Ошибка инциализации формы.
Возможно, домен сайта отличается от указанного в интеграции.

").css("visibility", "visible"); }); } } }); }, 500); gdInterval = setInterval(() => { if ($(".gd-success").is(":visible")) { clearInterval(gdInterval); let url = $(".gd-success").attr("data-url"); if (url) { $("body").append(''); $(".t-form__successbox").remove(); function receiveMessage(event) { if (event.data == "removetheiframe") { var element = document.getElementById("iframe-gd"); element.parentNode.removeChild(element); } } window.addEventListener("message", receiveMessage, false); } } if ($(".gd-success-msg").is(":visible")) { clearInterval(gdInterval); $(".gd-success-msg").parent().css("opacity", "1"); } }, 500); } });