2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
function td__drawPreload(e){td__drawBody(e),td__drawMenu()}function td__drawGlobal(e){document.querySelector(".td-maincontainer")&&(document.body.innerHTML=""),window.csrf&&document.getElementById("csrf").setAttribute("content",window.csrf),window.lang&&document.body.setAttribute("data-lang",window.lang),td__drawBody(e),td__drawMenu(),"object"==typeof e&&!0===e.nofooter||td__drawFooter(),"function"==typeof td__help__showBubble&&td__help__showBubble()}function td__drawBody(e){var t='<div id="loadicon" class="spinner" style="display:none;"></div><div class="td-menucontainer"></div><div class="td-maincontainer" style="'+("object"==typeof e&&"string"==typeof e.mcbgcolor?"background-color:"+e.mcbgcolor+";":"background-color:#fff;")+'min-height:calc(100vh - 60px);"></div><div class="td-footercontainer"></div>';document.body.insertAdjacentHTML("beforeend",t)}function td__drawBreadcrumbs(e){if("object"==typeof e){var t="https://tilda."+window.location.hostname.split(".").pop(),o="";o+='<div class="td-breadcrumbs">',o+='<div class="td-breadcrumbs__list">';for(var r=0;r<e.length;r++){var n=e[r],i,a="";void 0!==n.def?"myprojects"==n.def?(i=t+"/projects/",a="{{dashboard}}"):"project"==n.def?(i=t+"/projects/?projectid="+n.prid,(a=n.prt)||(a="{{my_project}}")):"ss"==n.def?(i=t+"/projects/settings/?projectid="+n.prid+(void 0!==n.tab?"#tab="+n.tab:""),a="{{site_settings}}"):"identity"==n.def?(i=t+"/identity/",a="{{profile}}"):"plans"==n.def?(i=t+"/identity/plan/",a="{{plans_and_billing}}"):"domains"==n.def&&(i=t+"/domains/",a="{{domains}}"):(i=n.l,a=n.t),o+='<div class="td-breadcrumbs__item'+(r===e.length-1?" td-breadcrumbs__item_last":"")+(a.length>=20?" td-breadcrumbs__item_long":"")+'">',o+=""===i?'<span class="td-breadcrumbs__link" style="opacity:0.7;">'+a+"</span>":'<a class="td-breadcrumbs__link" href="'+i+'">'+a+"</a>",o+="</div>",r!==e.length-1&&(o+='<div class="td-breadcrumbs__item td-breadcrumbs__item_arrow">→</div>')}o+="</div>",o=td__other__translate(o+="</div>"),document.querySelector(".td-maincontainer").insertAdjacentHTML("afterbegin",o)}}function td__load(e,t,o,r){"object"!=typeof o&&(o={}),"noloader"!==o.loadicon&&("corner"===o.loadicon?showLoadIcon():showCentralLoadIcon());var n=Date.now();void 0!==window.xhr_get&&window.xhr_get.abort();var i="/page/publish/"===e?35:20;function onSuccess(o){if("function"==typeof check_logout&&check_logout(o),""==o)"function"==typeof tc__showDialog?tc__showDialog({msg:"Error. Empty response from server"},"alert"):alert("Error. Empty response from server");else{if("bsf"==o.substring(0,3))try{o=bsfdunicode(o.substring(3))}catch(e){console.log("error bsf")}if("{"===o.substring(0,1)||"["===o.substring(0,1)){var n=td__parseJson(o);"object"==typeof n?(null===n&&(n={}),r(n)):(console.log("Error response. Can not parse response from server: "+o),document.body.innerHTML=o)}else console.log("Error response from server: "+o),"Sorry, you do not have rights to this action"!=o&&"Извините, у вас нет прав на это действие"!=o||(o='<div style="font-size:20px; padding:40px; line-height:1.5;">'+o+"</div>",o+='<div style="font-size:12px; padding:40px; padding-top:0;">',"/projects/get/getsitesettings/"==e&&void 0!==t.projectid&&(o+=td__other__translate("{{owner_restricted_access|projectid}}",{projectid:t.projectid})),o+='<br><br><a href="javascript:window.history.back();">{{go_back}}</a>',o+="</div>"),"Project does not exist!"==o&&(o='<div style="font-size:20px; padding:40px; line-height:1.5;">'+o+"</div>"),o=td__other__translate(o),document.body.innerHTML=o;-1===o.indexOf("Sorry, you don't have permission to perform this action")&&-1===o.indexOf("Извините, у вас нет прав на это действие")||!document.body.classList.contains("td-body_popup-opened")||document.body.classList.remove("td-body_popup-opened")}}function onError(r,i){var a=Date.now()-n;if(console.log(r.status),console.log(i),"abort"===i){var s=document.getElementById("noactionlayer");s&&(s.style.display="none")}else r.status>=400?(td__drawpageerror(r.status,"(Action: Get "+o.ctext.replace(/^get/i,"").trim()+")"),logAjaxError(e,t,"comm: "+t.comm+", (td__load)",r.status,{ts_delta:parseInt(a/1e3),exception:i,ui:o})):0==r.status&&a<100?"function"==typeof tc__showDialog?tc__showDialog({msg:"Request error (get "+o.ctext+"). Please check your Internet connection and try again."},"alert"):alert("Request error (get "+o.ctext+"). Please check your Internet connection and try again."):(logNetworkError("ajax",e,t,a/1e3,{}),"function"==typeof tc__showDialog?tc__showDialog({msg:"Request timeout (get "+o.ctext+"). Please reload the page and try again."},"alert"):alert("Request timeout (get "+o.ctext+"). Please reload the page and try again."));if("/page/publish/"==e){var d=document.getElementById("loadicon-progress");d&&(d.parentElement.innerHTML="Error!")}}function onComplete(){delete window.xhr_get,hideCentralLoadIcon(),hideLoadIcon()}window.xhr_get=new XMLHttpRequest,window.xhr_get.open("POST",e,!0),window.xhr_get.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),window.xhr_get.responseType="text",window.xhr_get.timeout=1e3*i,window.xhr_get.addEventListener("loadend",(function(){tc__checkServerError&&tc__checkServerError(this)?tc__drawServerError(this.responseText):this.status>=200&&this.status<400?(onSuccess(this.responseText),onComplete()):(onError(this),onComplete())})),window.xhr_get.addEventListener("timeout",(function(){onError(this,"timeout"),onComplete()})),window.xhr_get.addEventListener("abort",(function(){onError(this,"abort"),onComplete()})),window.xhr_get.addEventListener("error",(function(){onError(this,"error"),onComplete()})),t?window.xhr_get.send(td__encodeData(t)):window.xhr_get.send()}function td__submit(e,t,o,r){var n=document.querySelector(o.preview),i=document.querySelector(o.btn);n&&(n.style.display="none",n.innerHTML=""),i&&(i.style.pointerEvents="none",i.style.opacity="0.3"),i&&"string"==typeof o.btntext&&(i.setAttribute("data-btn-progress-text",i.value),i.value=o.btntext),t.csrf=getCSRF(),event&&event.preventDefault();var a=Date.now();function onSuccess(e){"function"==typeof check_logout&&check_logout(e),r(e)}function onError(r,i){var s=Date.now()-a;if(console.log(r.status),console.log(i),"abort"===i);else if(r.status>=400){n&&(n.style.display="block",n.innerHTML="System error ("+o.ctext+"). Please reload the page and try again.");var d="unknown";void 0!==t.comm?d=t.comm:void 0!==t[0].name&&"comm"==t[0].name&&void 0!==t[0].value&&(d=t[0].value),logAjaxError(e,t,"comm:"+d+", (td__submit)",r.status,{ts_delta:parseInt(s/1e3),exception:i,ui:o})}else 0==r.status&&s<100?n&&(n.style.display="block",n.innerHTML="Request error ("+o.ctext+"). Please check your Internet connection and try again."):(n&&(n.style.display="block",n.innerHTML="Request timeout ("+o.ctext+"). Please reload the page and try again."),logNetworkError("ajax",e,t,s/1e3,{}))}function onComplete(){i&&(i.style.pointerEvents="auto",i.style.opacity="1");var e=i&&i.getAttribute("data-btn-progress-text");e&&(i.value=e,i.removeAttribute("data-btn-progress-text")),delete window.xhr_submit,hideLoadIcon()}showLoadIcon(),window.xhr_submit&&window.xhr_submit.abort(),window.xhr_submit=new XMLHttpRequest,window.xhr_submit.open("POST",e,!0),window.xhr_submit.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),window.xhr_submit.responseType="text",window.xhr_submit.timeout=2e4,window.xhr_submit.addEventListener("loadend",(function(){tc__checkServerError&&tc__checkServerError(this)?tc__drawServerError(this.responseText):this.status>=200&&this.status<400&&(onSuccess(this.responseText),onComplete())})),window.xhr_submit.addEventListener("timeout",(function(){onError(this,"timeout"),onComplete()})),window.xhr_submit.addEventListener("abort",(function(){onError(this,"abort"),onComplete()})),window.xhr_submit.addEventListener("error",(function(){onError(this,"error"),onComplete()})),t?window.xhr_submit.send(td__encodeData(t)):window.xhr_submit.send()}function showCentralLoadIcon(){"number"==typeof window.centralloadicon_timerid&&clearTimeout(window.centralloadicon_timerid),window.centralloadicon_timerid=setTimeout((function(){if(!document.getElementById("centralloadicon")){var e='<div id="centralloadicon" class="threedotsspinner"><div class="threedotsspinner-bounce1"></div><div class="threedotsspinner-bounce2"></div><div class="threedotsspinner-bounce3"></div></div>';document.body.insertAdjacentHTML("beforeend",e)}document.getElementById("centralloadicon").style.display="block"}),1e3)}function hideCentralLoadIcon(){clearTimeout(window.centralloadicon_timerid);var e=document.getElementById("centralloadicon");e&&e.remove()}function getUrlParameter(e){for(var t,o=window.location.search.substring(1).split("&"),r=0;r<o.length;r++){var n=o[r].split("=");if(n[0]==e)return n[1]}}function td__parseJson(e){try{var t=JSON.parse(e);return"object"==typeof t?t:(console.log("error parse json"),console.log(e),"error")}catch(t){return console.log("Error parse server response! error:"+t),console.log(e),"error"}}function td__getFormObj(e){if(Object.getPrototypeOf(e).jquery&&!(e=e[0]))return{};var t={},o=e.querySelectorAll("input[name], select[name]");return Array.prototype.forEach.call(o,(function(e){var o=e.name;"checkbox"===e.type?t[o]=e.checked?"on":"":t[o]=e.value})),t}function td__common__objtowindow(e){if(window.lang=cleanUndefined(e.lang),window.csrf=cleanUndefined(e.csrf),window.lang&&document.body.setAttribute("data-lang",window.lang),window.csrf&&document.getElementById("csrf").setAttribute("content",window.csrf),window.we_are_now_in=cleanUndefined(e.we_are_now_in),void 0===e.username){if(void 0!==window.localStorage){var t=localStorage.getItem("uname");t?window.username=t:sessionStorage&&sessionStorage.getItem("uname")&&(window.username=sessionStorage.getItem("uname"))}}else window.username=cleanUndefined(e.username);window.userplan=cleanUndefined(e.userplan)}function escapeHtml(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};return String(e).replace(/[&<>"'`=\/]/g,(function(e){return t[e]}))}function replaceUnicode(e){var t={"&":"&","<":"<",">":">",""":'"',"'":"'","'":"'","/":"/","`":"`","=":"="};return String(e).replace(/&|<|>|"|'|'|/|`|=/g,(function(e){return t[e]}))}function reEscapeHTML(e){const t=undefined;return escapeHtml(replaceUnicode(e))}function turesizeurl(e,t){if(void 0===e||""==e||null==e)return e;if(e.indexOf(".svg")>0||e.indexOf(".gif")>0||e.indexOf(".ico")>0||-1===e.indexOf("static.tildacdn.com")||e.indexOf("-/empty/")>0||e.indexOf("-/resize/")>0||e.indexOf("-/resizeb/")>0||e.indexOf("/lib/emoji/")>0||e.indexOf("/-/")>-1)return e;if(!(t>0))return e;var o=e.split("/"),r;return o.splice(e.split("/").length-1,0,"-/resize/"+t+"x"),o.join("/")}function stripTags(e){return"object"!=typeof e&&e&&(e=e.replace(/(<([^>]+)>)/gi,"")),e}function t_throttle(e,t,o){var r,n;return t||(t=250),function(){var i=o||this,a=+new Date,s=arguments;r&&a<r+t?(clearTimeout(n),n=setTimeout((function(){r=a,e.apply(i,s)}),t)):(r=a,e.apply(i,s))}}function punicodeDomain(e){if("string"!=typeof e||""==e||null==e)return e;if("object"!=typeof punycode)return e;var t=e,o="";if("http://"===e.substring(0,7)&&(e=e.replace("http://",""),o="http://"),"https://"===e.substring(0,8)&&(e=e.replace("https://",""),o="https://"),"xn--"===e.substring(0,4)){var r=t;try{r=o+""+punycode.ToUnicode(e)}catch(e){console.log("error punicode: "+r)}return r}return t}function td__drawpageerror(e,t){var o='<div class="td__error500notice" style="max-width: 450px; color:#000; z-index:100000;"><div style="padding:40px;"><div><b>Server error: '+e+"</b>"+("404"==e?" Page not found":"")+"<br><br>Sorry, it looks like we have an internal server error."+(t?"<br>"+t:"")+'<br><br>Please wait for a minute, reload the page, and try again.<br><br>If you continue to see this message multiple times, please contact us at: <a href="mailto:team@tilda.cc" style="text-decoration:underline;">team@tilda.cc</a></div><div><br><br><img src="/tpl/img/broken-robot.png" width="90px"></div><br></div></div>';document.body.innerHTML=o}function td__drawpagenotfound(){var e='<div class="td__error404notice" style="max-width: 450px; color:#000; z-index:100000;"><div style="padding:40px;"><div><b>Error: 404. Page not found</b><br><br>Sorry, it looks like the page was not found.</div><div><br><br><img src="/tpl/img/broken-robot.png" width="90px"></div><br></div></div>';document.body.innerHTML=e}function td__checkCollabAccess(e){if(!window.project||"y"!==window.project.shared)return!0;var t=Array.isArray(window.project.roles)?window.project.roles:[];return!!t.includes("all")||("publish"!==e||t.includes("pg_p"))}function getCookie(e){var t,o=("; "+document.cookie).split("; "+e+"=");if(2==o.length)return o.pop().split(";").shift()}function setCookie(e,t,o){var r=(o=o||{}).expires;if("number"==typeof r&&r){var n=new Date;n.setTime(n.getTime()+1e3*r),r=o.expires=n}r&&r.toUTCString&&(o.expires=r.toUTCString());var i=e+"="+(t=encodeURIComponent(t));for(var a in o){i+="; "+a;var s=o[a];!0!==s&&(i+="="+s)}document.cookie=i}function dateformat(e,t){if(!(e>1048561077))return"";""==t&&(t="RU"==lang?"d.m.y":"d mon, y");var o=new Date(1e3*e),r=o.getFullYear(),n=o.getMonth()+1,i=o.getDate(),a=o.getHours(),s=o.getMinutes();n=n<10?"0"+n:n,i=i<10?"0"+i:i,a=a<10?"0"+a:a,s=s<10?"0"+s:s;var d="";if("d.m.y"==t)d=i+"."+n+"."+r;else if("d mon, y"==t){var c,l,u;d=i+"."+["Jan.","Feb.","March","April","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec."][parseInt(n,10)-1]+"."+r}else"h:m"==t&&(d=a+":"+s);return d}function cleanUndefined(e){return empty(e)&&(e=""),e}function empty(e){var t=typeof e;if("undefined"===t)return!0;if("boolean"===t)return!e;if(null===e)return!0;if(void 0===e)return!0;if(e instanceof Array){if(e.length<1)return!0}else if("string"===t){if(e.length<1)return!0;if("0"===e)return!0}else if("object"===t){if(Object.keys(e).length<1)return!0}else if("number"===t&&0===e)return!0;return!1}function number_format(e,t,o,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var n=isFinite(+e)?+e:0,i=isFinite(+t)?Math.abs(t):0,a=void 0===r?",":r,s=void 0===o?".":o,d="",toFixedFix=function(e,t){var o=Math.pow(10,t);return""+Math.round(e*o)/o};return(d=(i?toFixedFix(n,i):""+Math.round(n)).split("."))[0].length>3&&(d[0]=d[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,a)),(d[1]||"").length<i&&(d[1]=d[1]||"",d[1]+=new Array(i-d[1].length+1).join("0")),d.join(s)}function td__makenotundefined_arr_items(e,t){var o=(t=t.replace(/\s/g,"")).split(",");for(var r in o)"object"!=typeof e[o[r]]&&empty(e[o[r]])&&(e[o[r]]="");return e}function bsfdunicode(e){return decodeURIComponent(atob(e).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))}function in_array(e,t){if("object"==typeof t&&("number"==typeof e||"string"==typeof e))for(var o=0,r=t.length;o<r;o++)if(t[o]==e)return!0;return!1}function td__other__translate(e,t,o){void 0===o&&(o=window.lang||(window.navigator.userLanguage||window.navigator.language).toUpperCase().slice(0,2));var r={dashboard:{RU:"Мои сайты",EN:"Dashboard",DE:"Dashboard",ES:"Mis sitios",PT:"Painel"},my_project:{RU:"Мой проект",EN:"My Project",DE:"Mein Projekt",ES:"Mi proyecto",PT:"Meu Projeto"},site_settings:{RU:"Настройки сайта",EN:"Site Settings",DE:"Website-Einstellungen",ES:"Ajustes del sitio",PT:"Configurações do Site"},profile:{RU:"Профиль",EN:"Profile",DE:"Profil",ES:"Perfil",PT:"Perfil"},plans_and_billing:{RU:"Тарифы и оплата",EN:"Plans and Billing",DE:"Pläne und Abrechnung",ES:"Planes y facturación",PT:"Planos e cobrança"},domains:{RU:"Мои домены",EN:"Domains",DE:"Domains",ES:"Dominios",PT:"Domínios"},owner_restricted_access:{RU:'Владелец проекта ограничил вам доступ к настройкам сайта.<br>Вы можете <a href="/projects/collaborators/unfollow/?projectid=${projectid}" style="color:#fb866c;">покинуть проект</a>, если не хотите видеть этот проект в списке сайтов и иметь к нему доступ. Сайт останется в исходном аккаунте, но у вас не будет к нему доступа.',EN:'Project owner has restricted your access to the Site Settings.<br>You can <a href="/projects/collaborators/unfollow/?projectid=${projectid}" style="color:#fb866c;">leave the project</a> if you don\'t want to see this project in your website\'s list and to have the access anymore. The website remains in an original account but you won\'t have access to it.',DE:'Der:die Projekteigentümer:in hat Ihren Zugriff auf die Website-Einstellungen eingeschränkt.<br>Sie können <a href="/projects/collaborators/unfollow/?projectid=${projectid}" style="color:#fb866c;">das Projekt verlassen</a>, wenn Sie dieses Projekt nicht mehr in der Liste Ihrer Website sehen und keinen Zugriff mehr darauf haben möchten. Die Website bleibt in einem ursprünglichen Konto, aber Sie werden keinen Zugriff mehr darauf haben.',ES:'El administrador del proyecto ha restringido su acceso a los Ajustes del sitio.<br>Puede <a href="/projects/collaborators/unfollow/?projectid=${projectid}" style="color:#fb866c;">abandonar el proyecto</a> si ya no desea ver este proyecto en su lista de sitios web ni tener acceso al mismo. El sitio web permanecerá en la cuenta original, pero usted ya no tendrá acceso al mismo.',PT:'O proprietário do projeto restringiu seu acesso às configurações do site.<br>Você pode <a href="/projects/collaborators/unfollow/?projectid=${projectid}" style="color:#fb866c;">sair do projeto</a> se não quiser vê-lo na lista do seu site e não quiser mais ter acesso. O site continuará na conta original, mas você não terá mais acesso a ele.'},go_back:{RU:"Вернуться назад",EN:"Go back",DE:"Zurück",ES:"Regresar",PT:"Voltar"}},n=e.match(/\{\{(.[^}]*)\}\}/g),i,a;n&&n.forEach((function(n){i=n.slice(2,n.length-2).split("|")[0];var s=(a="object"==typeof r[i]&&"string"==typeof r[i][o]&&""!=r[i][o]?r[i][o]:"object"==typeof r[i]&&"string"==typeof r[i].EN&&""!=r[i].EN?r[i].EN:i).match(/\$\{(.[^}]*)\}/g);s&&s.forEach((function(e){var o=e.slice(2,e.length-1);t&&void 0!==t[o]&&(a=a.replace(e,t[o]))})),e=e.replace(n,a)}));return e}String.prototype.replaceAll=function(e,t){var o;return this.replace(new RegExp(e,"g"),t)},String.prototype.truncate=function(e,t){var o=this,r=o.length>e?"string"==typeof t?t:"...":"";return o.substring(0,e)+r};
|