1/* 2-------------------------------------------------------------------------- 3(c) 2007 Lawrence Akka 4 - jquery version of the spamspan code (c) 2006 SpamSpan (www.spamspan.com) 5 6This program is distributed under the terms of the GNU General Public 7Licence version 2, available at http://www.gnu.org/licenses/gpl.txt 8-------------------------------------------------------------------------- 9*/ 10 11(function ($) { //Standard drupal jQuery wrapper. See http://drupal.org/update/modules/6/7#javascript_compatibility 12// load SpamSpan 13Drupal.behaviors.spamspan = { 14 attach: function(context, settings) { 15 // get each span with class spamspan 16 $("span.spamspan", context).each(function (index) { 17 // Replace each <spam class="t"></spam> with . 18 if ($('span.t', this).length) { 19 $('span.t', this).replaceWith('.'); 20 } 21 22 // For each selected span, set mail to the relevant value, removing spaces 23 var _mail = ($("span.u", this).text() + 24 "@" + 25 $("span.d", this).text()) 26 .replace(/\s+/g, ''); 27 28 // Build the mailto URI 29 var _mailto = "mailto:" + _mail; 30 if ($('span.h', this).length) { 31 // Find the header text, and remove the round brackets from the start and end 32 var _headerText = $("span.h", this).text().replace(/^ ?\((.*)\) ?$/, "$1"); 33 // split into individual headers, and return as an array of header=value pairs 34 var _headers = $.map(_headerText.split(/, /), function (n, i) { 35 return (n.replace(/: /, "=")); 36 }); 37 38 var _headerstring = _headers.join('&'); 39 _mailto += _headerstring ? ("?" + _headerstring) : ''; 40 } 41 42 // Find the anchor content, and remove the round brackets from the start and end 43 var _anchorContent = $("span.a", this).html(); 44 if (_anchorContent) { 45 _anchorContent = _anchorContent.replace(/^ ?\((.*)\) ?$/, "$1"); 46 } 47 48 // create the <a> element, and replace the original span contents 49 50 //check for extra <a> attributes 51 var _attributes = $("span.e", this).html(); 52 var _tag = "<a></a>"; 53 if (_attributes) { 54 _tag = "<a " + _attributes.replace("<!--", "").replace("-->", "") + "></a>"; 55 } 56 57 $(this).after( 58 $(_tag) 59 .attr("href", _mailto) 60 .html(_anchorContent ? _anchorContent : _mail) 61 .addClass("spamspan") 62 ).remove(); 63 }); 64 } 65}; 66}) (jQuery);;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.