aboutsummaryrefslogtreecommitdiff
path: root/static/js/email.js
blob: 01e338ab089254a2dd0209d3530e2785d66b91f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(function() {
    // Find all the elements on the page that use class="m-protected"
    var allElements = document.getElementsByClassName('m-protected');

    // Loop through all the elements, and update them
    for (var i = 0; i < allElements.length; i++) {
        // fetch the hex-encoded string from the href property
        var encoded = allElements[i].getAttribute('href');

        // decode the email address
        var decoded = atob(encoded.substring(1));

        // Set the link to be a "mailto:" link
        allElements[i].href = 'mailto:' + decoded;
    }
})();