Regístrese y reciba un 15% de descuento
| Boletín
Contacto ¿Necesitas ayuda? Nuestro equipo está aquí para ti.
You are on our Spanish website!
The website is in Spanish language. Would you like to be redirected to our Englisch website for a better experience?
Stay on Site
$(document).ready(function() {
function setLocalStorage(key, value) { localStorage.setItem(key, value); }
function getLocalStorage(key) { return localStorage.getItem(key); }
function fetchData() {
var lastShownDate = getLocalStorage('geoLocationModalShownDate');
var currentDate = new Date().getTime();
var daysSinceLastShown = lastShownDate ? (currentDate - lastShownDate) / (1000 * 3600 * 24) : null;
if (getLocalStorage('geoLocationModalShown') && daysSinceLastShown < 3) return;
fetch("https://morgenland-cpanel.eu/api/morgenland-info").then(function(r) {
if (!r.ok) throw new Error('HTTP error! status: ' + r.status);
return r.json();
}).then(function(d) {
var c = normalizeCountryCode(d.data.countryCode), l = [{"lang":"de","locale":"de","url":"https:\/\/www.morgenland-teppiche.de\/contact","name":"German","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/German.png"},{"lang":"en","locale":"en","url":"https:\/\/www.morgenland-rugs.com\/contact","name":"English","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/USA.png"},{"lang":"uk","locale":"en-gb","url":"https:\/\/www.morgenland-rugs.co.uk\/contact","name":"English","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/UK.png"},{"lang":"fr","locale":"fr","url":"https:\/\/www.morgenland-tapis.fr\/contact","name":"French","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/France.png"},{"lang":"nl","locale":"nl","url":"https:\/\/www.morgenland-tapijt.nl\/contact","name":"Dutch","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Netherland.png"},{"lang":"se","locale":"sv-SE","url":"https:\/\/www.morgenland-mattor.se\/contact","name":"Swedish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Sweden.png"},{"lang":"at","locale":"de-AT","url":"https:\/\/www.morgenland-teppiche.at\/contact","name":"Austria","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Austria.png"},{"lang":"ch","locale":"de-CH","url":"https:\/\/www.morgenland-teppiche.ch\/contact","name":"Swiss German","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Switzerland.png"},{"lang":"nn","locale":"no-NO","url":"https:\/\/www.morgenland-tepper.com\/contact","name":"Norwegian","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Norway.png"},{"lang":"da","locale":"da","url":"https:\/\/www.morgenland-taepper.com\/contact","name":"Danish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Denmark.png"},{"lang":"it","locale":"it","url":"https:\/\/www.morgenland-tappeto.it\/contact","name":"Italian","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Italy.png"},{"lang":"pl","locale":"pl","url":"https:\/\/www.morgenland-dywany.pl\/contact","name":"Polish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Poland.png"},{"lang":"pt","locale":"pt","url":"https:\/\/www.morgenland-tapetes.pt\/contact","name":"Portuguese","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Portguese.png"},{"lang":"cz","locale":"cs-CZ","url":"https:\/\/www.morgenland-koberce.cz\/contact","name":"Czech","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Czech-Republic.png"}], a = {"lang":"es","name":"Spanish","image":"https:\/\/cdn02.plentymarkets.com\/6wg68w8zahno\/frontend\/assets\/imgs\/flags\/Spain.png"}, f = findActiveUrl(l, c);
if (shouldShowModal(f, a, c)) {
updateModal(f);
$('#geoLocationModal').modal('show');
$('#geoLocationModal').attr('aria-hidden', 'false');
setLocalStorage('geoLocationModalShown', 'true');
setLocalStorage('geoLocationModalShownDate', currentDate);
}
}).catch(function(e) { console.error('Fetch error:', e.message); });
}
function normalizeCountryCode(c) {
return c.toLowerCase() === "gb" ? "uk" : c.toLowerCase();
}
function findActiveUrl(l, c) {
var d = l.filter(function(u) { return u.lang === 'en'; })[0];
return l.find(function(u) { return u.lang === c; }) || d;
}
function shouldShowModal(foundUrl, activeUrl, countryCode) {
if (!foundUrl || countryCode === activeUrl.lang) return false;
var exceptions = { 'de': ['at', 'ch'], 'uk': ['en'], 'en': ['uk'], 'at': ['de', 'ch'], 'ch': ['de', 'at'] };
var activeExceptions = exceptions[activeUrl.lang] || [];
return !activeExceptions.includes(foundUrl.lang);
}
function updateModal(f) {
var b = document.querySelector('#redirectButton'), t = document.querySelector('#geoLocationText'), bt = document.querySelector('#redirectButtonText'), bi = document.querySelector('#redirectButtonImage');
b.href = f.url;
t.textContent = "The website is in Spanish language. Would you like to be redirected to our {name} website for a better experience?".replace("{name}", f.name);
bi.src = bi['data-src'] = f.image;
bi.alt = f.name;
bt.textContent = "Redirect to {name} Site".replace("{name}", f.name);
}
fetchData();
});