| 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 |
} |
} |
|
|
|