PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/README.md

https://github.com/mikebranski/jquery-nospam
Markdown | 98 lines | 67 code | 31 blank | 0 comment | 0 complexity | 05fc77e6a614c8339daf956a07f4168e MD5 | raw file
  1. # jQuery No Spam Plugin ![Project status](http://stillmaintained.com/mikebranski/jquery-nospam.png)
  2. This jQuery plugin turns an obfuscated e-mail address into a human-readable one. To use this plugin, include `jquery.nospam.js` and call the nospam() method. No Spam automatically detects if your matched element is a link. If so, it checks the rel attributes for the obfuscated e-mail addresses. For all other elements, it uses the text between the matched tags.
  3. Now supports multiple dots (.) both before and after the at (@) sign! (since 1.3)
  4. ## Options
  5. $('a.email').nospam({
  6. replaceText: true, // BOOLEAN, optional default false. If set to true, replaces matched elements' text with the e-mail address
  7. filterLevel: 'normal' // STRING, optional accepts 'low' or 'normal', default 'normal'.
  8. // low: email//domain/tld
  9. // normal: dlt/niamod//liame (email//domain/tld reversed)
  10. });
  11. ## Examples
  12. ### Link with fallback, replaceText: true
  13. <a class="email" href="contact.php" rel="moc/elpmaxe//oof">Contact us</a>
  14. <script>
  15. $('.email').nospam({
  16. replaceText: true
  17. });
  18. </script>
  19. If JavaScript is enabled, the above code will render:
  20. <mailto:foo@example.com>
  21. However, if JavaScript is not enabled, the user will simply see a link to contact.php with the text 'Contact Us', providing a nice fallback:
  22. [Contact us](contact.php)
  23. ### Link with fallback, filterLevel: 'low'
  24. <a class="email" href="contact.php" rel="foo//example/com">Contact us</a>
  25. <script>
  26. $('.email').nospam({
  27. filterLevel: 'low'
  28. });
  29. </script>
  30. If JavaScript is enabled, the above code will render:
  31. [Contact us](mailto:foo@example.com)
  32. If JavaScript is not enabled, the user will simply see a link to contact.php like in the previous example:
  33. [Contact us](contact.php)
  34. ### Link with fallback, replaceText: true
  35. <a class="email" href="contact.php" rel="moc/elpmaxe//oof">Contact us</a>
  36. <script>
  37. $('.email').nospam({
  38. replaceText: true
  39. });
  40. </script>
  41. If JavaScript is enabled, the above code will render:
  42. <mailto:foo@example.com>
  43. However, if JavaScript is not enabled, the user will simply see a link to contact.php with the text 'Contact Us', providing a nice fallback:
  44. [Contact us](contact.php)
  45. ### Span
  46. You can also use No Spam with non-link elements. `replaceText` will also be `true` in this case.
  47. <span class="email">foo//example/com</span>
  48. <script>
  49. $('.email').nospam({
  50. filterLevel: 'low'
  51. });
  52. </script>
  53. With JavaScript:
  54. <mailto:foo@example.com>
  55. Without JavaScript:
  56. foo//example/com
  57. ## Integration
  58. To make things easier, I also created a PHP function called nospam() that formats your regular e-mail addresses dynamically and outputs them in a No Spam-ready format which I've made [available for download](https://github.com/mikebranski/jquery-nospam/blob/master/nospam.php).
  59. ## Changelog
  60. * 1.4.0 - Changed license to LGPLv3
  61. * 1.3.2 - Wrap plugin in a closure for better compatibility with other libraries, clean up comments and examples, create README
  62. * 1.3.1 - Updated links in comments, removed GPL license file, tested against jQuery 1.6.2
  63. * 1.3 - Added support for e-mail addresses with multiple dots (.) both before and after the at (@) sign
  64. * 1.2.1 - Included GPL license
  65. * 1.2 - Finalized name as No Spam (was Protect Email)
  66. * 1.1 - Changed switch() to if() statement
  67. * 1.0 - Initial release