From 8003937c5fe723a1e43a22fe71350be3488e7ac3 Mon Sep 17 00:00:00 2001 From: ail3n Date: Tue, 16 Jul 2024 13:47:04 -0300 Subject: [PATCH] modify logic to render modal success/error --- _layouts/index.liquid | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/_layouts/index.liquid b/_layouts/index.liquid index 0b1d7d7..4cec98c 100644 --- a/_layouts/index.liquid +++ b/_layouts/index.liquid @@ -18,6 +18,17 @@ X + +
{{ page.content }}
{{ site.data[site.data.lang].globals.go-down }} @@ -60,24 +71,10 @@ const mailButton = document.getElementById('mail-button'); const closeButton = document.querySelector('.close-button'); const modalMessage = document.getElementById('modal-message'); -const userLang = navigator.language; -const isSpanish = userLang.startsWith('es'); - -const messages = { - success: { - en: `success

Thank you!

Your email has been successfully registered!

`, - es: `success

¡Gracias!

¡Tu correo ha sido registrado exitosamente!

` - }, - error: { - en: `error

Oops!

We encountered an error registering your email.

Please try again.

`, - es: `error

¡Ups!

Presentamos un error al registrar tu correo.

Inténtalo nuevamente, por favor.

` - } -}; - function openModal(type) { - const message = isSpanish ? messages[type].es : messages[type].en; - modalMessage.innerHTML = message; - modal.showModal(); + const message = modal.querySelector(`[data-msg=${type}]`); + modalMessage.replaceChildren(message.content.cloneNode(true)); + modal.showModal(); } closeButton.addEventListener('click', () => {