PageSourceSearch

https://eco63.ru/sites/all/modules/extlink/extlink.js?0

js eco63.ru collected 2026-10-05 00:03:36 UTC 4,422 bytes, 104 lines download raw bytes

1// $Id: extlink.js,v 1.4.2.12 2010/05/26 01:25:56 quicksketch Exp $
2(function ($) {
3
4function extlinkAttach(context) {
5  // Strip the host name down, removing ports, subdomains, or www.
6  var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
7  var host = window.location.host.replace(pattern, '$3$4');
8  var subdomain = window.location.host.replace(pattern, '$1');
9
10  // Determine what subdomains are considered internal.
11  if (Drupal.settings.extlink.extSubdomains) {
12    var subdomains = "([^/]*\\.)?";
13  }
14  else if (subdomain == 'www.' || subdomain == '') {
15    var subdomains = "(www\\.)?";
16  }
17  else {
18    var subdomains = subdomain.replace(".", "\\.");
19  }
20
21  // Build regular expressions that define an internal link.
22  var internal_link = new RegExp("^https?://" + subdomains + host, "i");
23
24  // Extra internal link matching.
25  var extInclude = false;
26  if (Drupal.settings.extlink.extInclude) {
27    extInclude = new RegExp(Drupal.settings.extlink.extInclude.replace(/\\/, '\\'));
28  }
29
30  // Extra external link matching.
31  var extExclude = false;
32  if (Drupal.settings.extlink.extExclude) {
33    extExclude = new RegExp(Drupal.settings.extlink.extExclude.replace(/\\/, '\\'));
34  }
35
36  // Find all links which are NOT internal and begin with http (as opposed
37  // to ftp://, javascript:, etc. other kinds of links.
38  // When operating on the 'this' variable, the host has been appended to
39  // all links by the browser, even local ones.
40  // In jQuery 1.1 and higher, we'd use a filter method here, but it is not
41  // available in jQuery 1.0 (Drupal 5 default).
42  var external_links = new Array();
43  var mailto_links = new Array();
44  $("a:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + ")", context).each(function(el) {
45    try {
46      var url = this.href.toLowerCase();
47      if (url.indexOf('http') == 0 && (!url.match(internal_link) || (extInclude && url.match(extInclude))) && !(extExclude && url.match(extExclude))) {
48        external_links.push(this);
49      }
50      else if (url.indexOf('mailto:') == 0) {
51        mailto_links.push(this);
52      }
53    }
54    // IE7 throws errors often when dealing with irregular links, such as:
55    // <a href="node/10"></a> Empty tags.
56    // <a href="http://user:[email protected]">example</a> User:pass syntax.
57    catch(error) {
58      return false;
59    }
60  });
61
62  if (Drupal.settings.extlink.extClass) {
63    // Apply the "ext" class to all links not containing images.
64    if (parseFloat($().jquery) < 1.2) {
65      $(external_links).not('[img]').addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
66    }
67    else {
68      $(external_links).not($(external_links).find('img').parents('a')).addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
69    }
70  }
71
72  if (Drupal.settings.extlink.mailtoClass) {
73    // Apply the "mailto" class to all mailto links not containing images.
74    if (parseFloat($().jquery) < 1.2) {
75      $(mailto_links).not('[img]').addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
76    }
77    else {
78      $(mailto_links).not($(mailto_links).find('img').parents('a')).addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
79    }
80  }
81
82  if (Drupal.settings.extlink.extTarget) {
83    // Apply the target attribute to all links.
84    $(external_links).attr('target', Drupal.settings.extlink.extTarget);
85  }
86
87  if (Drupal.settings.extlink.extAlert) {
88    // Add pop-up click-through dialog.
89    $(external_links).click(function(e) {
90     return confirm(Drupal.settings.extlink.extAlertText);
91    });
92  }
93
94  // Work around for Internet Explorer box model problems.
95  if (($.support && !($.support.boxModel === undefined) && !$.supp
95ort.boxModel) || ($.browser.msie && parseInt($.browser.version) <= 7)) {
96    $('span.ext, span.mailto').css('display', 'inline-block');
97  }
98}
99
100Drupal.behaviors.extlink = function(context) {
101  extlinkAttach(context);
102}
103
104})(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.