Created
May 25, 2012 22:33
-
-
Save clifton/2790938 to your computer and use it in GitHub Desktop.
This file contains 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
$(document).ready(function() { | |
// automatically fix obfuscated email addresses pasted into | |
// to/cc/bcc fields | |
$("textarea[name=to], textarea[name=cc], textarea[name=bcc]") | |
.live('blur', function(e){ | |
var text = $(this).val(); | |
var separators = ['_', ' ', '\\[', '\\]', '\\(', '\\)']; | |
var separatorExp = '(' + separators.join('|') + ')+'; | |
var keywords = {'@': ['at'], | |
'.': ['dot', 'daught']}; | |
for (var keyword in keywords) { | |
var aliases = keywords[keyword]; | |
aliases.forEach(function (alias) { | |
var regexp = new RegExp(separatorExp + alias + separatorExp); | |
console.log(separatorExp + alias + separatorExp); | |
text = text.replace(regexp, keyword); | |
}); | |
} | |
$(this).val(text); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANK YOU.