From a186989885ae6ff1bfc6ac86e2ca4986021bc3fd Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Thu, 19 Sep 2019 12:16:29 +0200 Subject: [PATCH] changed the behaviour of telegram, now available only with username --- src/mailgo.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/mailgo.js b/src/mailgo.js index 1d58709..1355a5d 100644 --- a/src/mailgo.js +++ b/src/mailgo.js @@ -29,7 +29,8 @@ let url = "", // mailgo tel variables let tel = "", - msg = ""; + msg = "", + telegramUsername = ""; // mailgo buttons let gmailButton, @@ -230,6 +231,10 @@ const mailgoInit = () => { telegram.href = "#mailgo-telegram"; telegram.classList.add("mailgo-open"); telegram.classList.add("mailgo-telegram"); + + // by default not display + telegram.style.display = "none"; + let telegramContent = document.createTextNode("open in "); telegram.appendChild(telegramContent); let telegramSpan = document.createElement("span"); @@ -437,12 +442,21 @@ const mailgoRender = (type = MAIL_TYPE, mailgo) => { // information let titleEl = getE("mailgo-tel-title"); + // Telegram username + if (mailgo.hasAttribute("data-telegram")) { + telegramUsername = mailgo.getAttribute("data-telegram"); + } + // actions waButton = getE("mailgo-wa"); telegramButton = getE("mailgo-telegram"); callButton = getE("mailgo-call"); copyButton = getE("mailgo-tel-copy"); + if (telegramUsername) { + telegramButton.setDisplay("block"); + } + // the title of the modal (tel) titleEl.innerHTML = tel; @@ -508,7 +522,7 @@ const actions = { openTelegram: () => { // Telegram url - let tgUrl = "https://t.me/" + tel; + let tgUrl = "https://t.me/" + telegramUsername; // open the url window.open(tgUrl, "_blank"); // hide the modal