| 1 |
// $Id:$ |
// $Id: urlify.js,v 1.1.2.3 2007/09/29 08:24:18 canen Exp $ |
| 2 |
if (Drupal.jsEnabled) { |
if (Drupal.jsEnabled) { |
| 3 |
$(document).ready(function () { |
$(document).ready(function () { |
| 4 |
var LATIN_MAP = { |
var LATIN_MAP = { |
| 56 |
'č':'c', 'ď':'d', 'ě':'e', 'ň': 'n', 'ř':'r', 'š':'s', 'ť':'t', 'ů':'u', |
'č':'c', 'ď':'d', 'ě':'e', 'ň': 'n', 'ř':'r', 'š':'s', 'ť':'t', 'ů':'u', |
| 57 |
'ž':'z' |
'ž':'z' |
| 58 |
}; |
}; |
| 59 |
|
|
| 60 |
|
var POLISH_MAP = { |
| 61 |
|
'ą':'a', 'ć':'c', 'ę':'e', 'ł':'l', 'ń':'n', 'ó':'o', 'ś':'s', 'ź':'z', |
| 62 |
|
'ż':'z', 'Ą':'A', 'Ć':'C', 'Ę':'e', 'Ł':'L', 'Ń':'N', 'Ó':'o', 'Ś':'S', |
| 63 |
|
'Ź':'Z', 'Ż':'Z' |
| 64 |
|
}; |
| 65 |
|
|
| 66 |
var ALL_DOWNCODE_MAPS = new Array(); |
var ALL_DOWNCODE_MAPS = new Array(); |
| 67 |
ALL_DOWNCODE_MAPS[0] = LATIN_MAP; |
ALL_DOWNCODE_MAPS[0] = LATIN_MAP; |
| 113 |
} |
} |
| 114 |
return downcoded; |
return downcoded; |
| 115 |
}; |
}; |
| 116 |
//FIXME: Why doesn't function URLify() works anymore? |
//FIXME: Why doesn't function URLify() work anymore? |
| 117 |
// The form below has to be used for some reason. |
// The form below has to be used for some reason. |
| 118 |
URLify = function (s, num_chars) { |
URLify = function (s, num_chars) { |
| 119 |
// changes, e.g., "Petty theft" to "petty_theft" |
// changes, e.g., "Petty theft" to "petty_theft" |
| 120 |
// remove all these words from the string before urlifying |
// remove all these words from the string before urlifying |
| 121 |
s = downcode(s); |
s = downcode(s); |
| 122 |
var removelist = [Drupal.settings.urlify.remove_list]; |
removelist = Drupal.settings.urlify.remove_list; |
| 123 |
r = new RegExp('\\\b(' + removelist.join('|') + ')\\\b', 'gi'); |
|
| 124 |
|
// Temporary work around for the removelist is returned. |
| 125 |
|
// removelist was an array now it is a string |
| 126 |
|
removelist = removelist.replace(/'/gi, ''); |
| 127 |
|
r = new RegExp('\\b(' + removelist.replace(/,/, '|') + ')\\b', 'gi'); |
| 128 |
|
|
| 129 |
s = s.replace(r, ''); |
s = s.replace(r, ''); |
| 130 |
// if downcode doesn't hit, the char will be stripped here |
// if downcode doesn't hit, the char will be stripped here |
| 131 |
s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars |
s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars |