# HG changeset patch # User Laurens Holst # Date 1610888251 -3600 # Sun Jan 17 13:57:31 2021 +0100 # Node ID 17fc9ea81b8560604ad10633bd2694f0ddc68fc2 # Parent 15bf84bc19b28f69f30e0f98f0594e250050ca35 email: Update script to HTML5. diff --git a/contributing/index.php b/contributing/index.php --- a/contributing/index.php +++ b/contributing/index.php @@ -1,12 +1,12 @@ - + Contributing to the MAP - MSX Assembly Page - + - +

Contributing to the MAP

@@ -16,8 +16,8 @@ mistakes, and we don’t always know what’s best either, so any feedback is appreciated. If you want to submit something for publication on this site, you can email it to us as well. Our contact address is -(enable JavaScript for email -link).

+(enable +JavaScript for email link).

If you want to contribute more directly to the MAP like write articles about a certain subject, or digitize some documents, or making editorial changes diff --git a/index.php b/index.php --- a/index.php +++ b/index.php @@ -1,14 +1,14 @@ - + MSX Assembly Page - + - +

Introduction

@@ -60,8 +60,8 @@ mistakes, and we don’t always know what’s best either, so any feedback is appreciated. If you want to submit something for publication on this site, you can email it to us as well. Our contact address is -(enable JavaScript for email -link).

+(enable +JavaScript for email link).

If you want to contribute more directly to the map, like write articles about a certain subject, or digitize some documents, or making editorial changes diff --git a/js/email.js b/js/email.js --- a/js/email.js +++ b/js/email.js @@ -1,38 +1,7 @@ -/** - * Email address link javascript (by Grauw) - * ============================= - * Using standard DOM methods working in an XHTML environment. - * - * Usage: - * - Fill in your email address in the variable 'eml' below - * - Put a tag with class="myemail" where you want the link - * - Add onload="putEmail(['','']);" to your <body> tag - */ - -/** - * Replaces all spans with class 'myemail' with an email address constructed from the provided array. - * @param email An array with two elements, corresponding to the part before and after the @ in an email-address. - */ -function putEmail() { - var aNodes = document_getElementsByTagNameNS('http://www.grauw.nl/g', 'insertMail', 'g'); - for (var i=0; i < aNodes.length; i++) { - var oNode = aNodes[i]; - var sEmail = oNode.getAttribute('local-part') + '@' + oNode.getAttribute('domain'); - var oAnchor = document.createElement('a'); - oAnchor.setAttribute('href', 'mailto:' + sEmail); - oAnchor.appendChild(document.createTextNode(sEmail)); - oNode.parentNode.replaceChild(oAnchor, oNode); - } +for (const node of document.getElementsByClassName("email")) { + var email = `${node.dataset.localPart}@${node.dataset.domain}`; + var anchor = document.createElement('a'); + anchor.href = `mailto:${email}`; + anchor.textContent = email; + node.parentNode.replaceChild(anchor, node); } - -/** - * Ugly cross-browser getElementsByTagNameNS wrapper - */ -function document_getElementsByTagNameNS(sNamespace, sLocalName, sPrefix) { - if (document.getElementsByTagNameNS) - return document.getElementsByTagNameNS(sNamespace, sLocalName); - else if (window.ActiveXObject) - return document.getElementsByTagName(sLocalName); - else - return document.getElementsByTagName(sPrefix + ':' + sLocalName); -} \ No newline at end of file