[ Index ] |
|
Code source de Seagull 0.6.1 |
1 /* 2 * (c) WackoWiki team ( http://wackowiki.com/team/ ), 2003-2004 3 * (c) Pixel-Apes team ( http://pixel-apes.com/ ), 2004 4 * (c) JetStyle ( http://jetstyle.ru/ ), 2004 5 * Maintainers -- Roman Ivanov <thingol@mail.ru>, 6 * Kuso Mendokusee <mendokusee@gmail.com> 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 function Translit() 32 { 33 this.enabled = true; 34 } 35 36 Translit.prototype.UrlTranslit = function( str, allow_slashes) 37 { 38 var slash = ""; 39 if (allow_slashes) slash = "\\/"; 40 41 var LettersFrom = "àáâãäåçéèêëìíîïðñòóôûùýéõ"; 42 var LettersTo = "aaaaaaceeeeiiiionooouuyzo"; 43 var Consonant = ""; 44 var Vowel = ""; 45 var BiLetters = { 46 "æ" : "zh", "ö" : "ts", "÷" : "ch", 47 "ø" : "sh", "ù" : "sch", "þ" : "ju", "ÿ" : "ja" 48 }; 49 50 str = str.replace( /[_\.,?!\[\](){}]+/g, "_"); 51 str = str.replace( /-{2,}/g, "--"); 52 str = str.replace( /_\-+_/g, "--"); 53 str = str.replace( /['\s]+/g, "-"); 54 55 str = str.toLowerCase(); 56 57 //transliterating 58 var _str = ""; 59 for (var x=0; x<str.length; x++) { 60 if ((index = LettersFrom.indexOf(str.charAt(x))) > -1) { 61 _str+=LettersTo.charAt(index); 62 } else { 63 _str+=str.charAt(x); 64 } 65 } 66 str = _str; 67 68 var _str = ""; 69 for (var x=0; x<str.length; x++) { 70 if (BiLetters[str.charAt(x)]) { 71 _str+=BiLetters[str.charAt(x)]; 72 } else { 73 _str+=str.charAt(x); 74 } 75 } 76 str = _str; 77 78 str = str.replace( /j{2,}/g, "j"); 79 80 str = str.replace( new RegExp( "[^"+slash+"0-9a-z_\\-]+", "g"), ""); 81 82 return str; 83 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 01:27:52 2007 | par Balluche grâce à PHPXref 0.7 |