var alertInjected = false; var isRunnedAuro = false; var reservation_widget_is_exitintent = false; var reservation_widget_is_unload = false; var reservation_widget_is_tabname = false; var reservation_widget_is_timeout = true; var origTitle, animatedTitle, timer; var language = window.navigator.userLanguage || window.navigator.language; var buttonsMode = 1; if(document.createStyleSheet) { document.createStyleSheet('https://api.myrest.io/asset/css/widget.css'); } else { var styles = "@import url(' https://api.myrest.io/asset/css/widget.css ');"; var css=document.createElement('link'); css.rel='stylesheet'; css.href='data:text/css,'+escape(styles); document.getElementsByTagName("head")[0].appendChild(css); } function mrOpen(addOnbeforeunload = true) { document.getElementById("mr-widget-handler").style.display = "block"; document.getElementById("mr-widget-trigger").style.display = "none"; isRunnedAuro = true; if (!alertInjected && addOnbeforeunload && reservation_widget_is_unload) { window.onbeforeunload = function() { mrOpen(); return "Do you really want to leave reservation form?"; }; } } function mrCLose() { document.getElementById("mr-widget-handler").style.display = "none"; document.getElementById("mr-widget-trigger").style.display = "block"; } if (reservation_widget_is_exitintent) { document.addEventListener("DOMContentLoaded", function(){ document.addEventListener("mouseleave", function(e){ if( e.clientY < 0 && !isRunnedAuro ) { isRunnedAuro = true; mrOpen(false) } }, false); }); } if (reservation_widget_is_timeout) { window.addEventListener("load", function () { setTimeout(function() { if(!isRunnedAuro) {mrOpen(false)}; },10000); }, false); } function animateTitle(newTitle) { var currentState = false; origTitle = document.title; animatedTitle = buttonsMode > 1 ? getTranslation().tab_text_ordering : getTranslation().tab_text_reservation + " | " + origTitle; timer = setInterval(startAnimation, 1500); function startAnimation() { document.title = currentState ? origTitle : animatedTitle; currentState = !currentState; } } function restoreTitle() { clearInterval(timer); document.title = origTitle; } if (reservation_widget_is_tabname) { window.onblur = function() { animateTitle(); } window.onfocus = function() { mrOpen(false);restoreTitle(); } } function getTranslation () { let translations = {}; language = language.split("-"); language = language[0].toLowerCase(); switch(language) { case "pl": translations = { btn_reservation: "Zarezerwuj stolik", btn_order: "Zamów online", tab_text_reservation: "REZERWACJA", tab_text_ordering: "Zamów online" } break; case "ru": translations = { btn_reservation: "ЗАБРОНИРОВАТЬ", btn_order: "Заказать", tab_text_reservation: "РЕЗЕРВАЦИЯ", tab_text_ordering: "Заказать" } break; default: translations = { btn_reservation: "BOOK A TABLE", btn_order: "Order online", tab_text_reservation: "RESERVATION", tab_text_ordering: "Order online", } break; } return translations; } let bodyTag = document.getElementsByTagName("body")[0]; let widgetBody = ''; switch(buttonsMode) { case 1: widgetBody = '
'; break; case 2: widgetBody = ''; break; case 3: widgetBody = ''; break; } bodyTag.insertAdjacentHTML( 'beforeend',widgetBody);