Created
November 7, 2013 12:47
-
-
Save dancek/7354053 to your computer and use it in GitHub Desktop.
Given an angular module _r, this is a directive for obfuscating an email address. Would be easy to parameterize and release as a module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_r.directive 'obfuscateEmail', -> | |
scope: | |
email: '=' | |
link: (scope, element) -> | |
rnd = Math.random().toString(36).substr(2,3) | |
re = /@/ | |
obfuscated = scope.email?.replace re, "<span class=\"obfuscate\">#{rnd}</span>$&" | |
element.html obfuscated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Idea from http://superuser.com/a/235965/72407