/[drupal]/contributions/modules/urlify/urlify.js
ViewVC logotype

Diff of /contributions/modules/urlify/urlify.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1, Sat Sep 29 06:23:39 2007 UTC revision 1.1.2.2, Sat Sep 29 06:57:45 2007 UTC
# Line 1  Line 1 
1  function URLify(s, num_chars) {  if (Drupal.jsEnabled) {
2    // changes, e.g., "Petty theft" to "petty_theft"    $(document).ready(function () {
3    // remove all these words from the string before urlifying      function URLify(s, num_chars) {
4    var removelist = [Drupal.settings.urlify.remove_list];        // changes, e.g., "Petty theft" to "petty_theft"
5    r = new RegExp('\\\b(' + removelist.join('|') + ')\\\b', 'gi');        // remove all these words from the string before urlifying
6    s = s.replace(r, '');        var removelist = [Drupal.settings.urlify.remove_list];
7    s = s.replace(/[^-A-Z0-9\s]/gi, '');  // remove unneeded chars        r = new RegExp('\\\b(' + removelist.join('|') + ')\\\b', 'gi');
8    s = s.replace(/^\s+|\s+$/g, '');      // trim leading/trailing spaces        s = s.replace(r, '');
9    s = s.replace(/[-\s]+/g, '-');        // convert spaces to hyphens        s = s.replace(/[^-A-Z0-9\s]/gi, '');  // remove unneeded chars
10    s = s.toLowerCase();                  // convert to lowercase        s = s.replace(/^\s+|\s+$/g, '');      // trim leading/trailing spaces
11    return s.substring(0, num_chars);     // trim to first num_chars chars        s = s.replace(/[-\s]+/g, '-');        // convert spaces to hyphens
12          s = s.toLowerCase();                  // convert to lowercase
13          return s.substring(0, num_chars);     // trim to first num_chars chars
14        }
15      });
16  }  }
   

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2