aboutsummaryrefslogtreecommitdiff
path: root/static/email.js
diff options
context:
space:
mode:
authorJieiku2022-08-23 13:41:41 -0700
committerJieiku2022-08-23 13:41:41 -0700
commitc7b914505b6505b013610cc71e3b50d68c4a5473 (patch)
treed2abebfa75cedd1b7351b51f9d5c909834e8d05d /static/email.js
parent6e6c0cbbb5d6136788d35ee5a354d36079c3475a (diff)
downloadabridge-c7b914505b6505b013610cc71e3b50d68c4a5473.tar.gz
abridge-c7b914505b6505b013610cc71e3b50d68c4a5473.tar.bz2
abridge-c7b914505b6505b013610cc71e3b50d68c4a5473.zip
Optimizations, Update Readme YellowLabTools
Diffstat (limited to 'static/email.js')
-rw-r--r--static/email.js34
1 files changed, 13 insertions, 21 deletions
diff --git a/static/email.js b/static/email.js
index 47aafc8..01e338a 100644
--- a/static/email.js
+++ b/static/email.js
@@ -1,24 +1,16 @@
-//btoa(unescape(encodeURIComponent(str))))
-//atob(escape(decodeURIComponent(str))))
+(function() {
+ // Find all the elements on the page that use class="m-protected"
+ var allElements = document.getElementsByClassName('m-protected');
-// 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');
-// Loop through all the elements, and update them
-for (var i = 0; i < allElements.length; i++) {
- updateAnchor(allElements[i]);
-}
+ // decode the email address
+ var decoded = atob(encoded.substring(1));
-function updateAnchor(el) {
- // fetch the hex-encoded string from the title property
- var encoded = el.getAttribute('title');
-
- // replace the title
- el.title = 'Mail';
-
- // decode the email address and remove the added string 'abridge'.
- var decoded = atob(encoded).substring(7);
-
- // Set the link to be a "mailto:" link
- el.href = 'mailto:' + decoded;
-}
+ // Set the link to be a "mailto:" link
+ allElements[i].href = 'mailto:' + decoded;
+ }
+})();