Skip to content

Instantly share code, notes, and snippets.

@clifton
Created May 25, 2012 22:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clifton/2790938 to your computer and use it in GitHub Desktop.
Save clifton/2790938 to your computer and use it in GitHub Desktop.
$(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);
});
});
@lookfirst
Copy link

THANK YOU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment