Удаление системы транслитерации из движка.

Отсутствует возможность поддерживать сложную систему транслитерации, тем более на нескольких языках. Пользователям следует посоветовать использование сайтов наподобие http://translit.net/ для этой цели.
This commit is contained in:
Exile 2014-10-21 17:50:26 +04:00
parent d3b8049006
commit cd8c7aa4b0
12 changed files with 14 additions and 281 deletions

View file

@ -453,119 +453,4 @@ function initMedia(context)
$(document).ready(function(){
$('div.post_wrap, div.signature').each(function(){ initPostBBCode( $(this) ) });
});
// One character letters
var t_table1 = "ABVGDEZIJKLMNOPRSTUFXHCYWabvgdezijklmnoprstufxhcyw'#";
var w_table1 = "АБВГДЕЗИЙКЛМНОПРСТУФХХЦЫЩабвгдезийклмнопрстуфххцыщьъ";
// Two character letters
var t_table2 = "EHSZYOJOZHCHSHYUJUYAJAehszyojozhchshyujuyajaEhSzYoJoZhChShYuJuYaJa";
var w_table2 = "ЭЩЁЁЖЧШЮЮЯЯэщёёжчшююяяЭЩЁЁЖЧШЮЮЯЯ";
var tagArray = [
'code', '',
'img', '',
'quote', "(=[\"']?[^"+String.fromCharCode(92,93)+"]+)?",
'email', "(=[\"']?[a-zA-Z0-9_.-]+@?[a-zA-Z0-9_.-]+[\"']?)?",
'url', "(=[\"']?[^ \"'"+String.fromCharCode(92,93)+"]*[\"']?)?"
];
function translit2win (str)
{
var len = str.length;
var new_str = "";
for (i = 0; i < len; i++)
{
/* non-translatable text must be in ^ */
if(str.substr(i).indexOf("^")==0){
end_len=str.substr(i+1).indexOf("^")+2;
if (end_len>1){
new_str+=str.substr(i,end_len);
i += end_len - 1;
continue;
}
}
/* Skipping emoticons */
if(str.substr(i).indexOf(":")==0){
iEnd = str.substr(i+1).indexOf(":")+2;
if (iEnd > 1 && str.substr(i,iEnd).match("^:[a-zA-Z0-9]+:$")){
new_str += str.substr(i,iEnd);
i += iEnd - 1;
continue;
}
}
/* Skipping http|news|ftp:/.../ links */
rExp = new RegExp("^((http|https|news|ftp|ed2k):\\/\\/[\\/a-zA-Z0-9%_?.:;&#|\(\)+=@-]+)","i");
if (newArr = str.substr(i).match(rExp)){
new_str += newArr[1];
i += newArr[1].length - 1;
continue;
}
/* Skipping FONT, COLOR, SIZE tags */
rExp = new RegExp("^(\\[\\/?(b|i|u|s|font(=[a-z0-9]+)?|size(=[0-9]+)?|color(=#?[a-z0-9]+)?)\\])","i");
if (newArr = str.substr(i).match(rExp)){
new_str += newArr[1];
i += newArr[1].length - 1;
continue;
}
/* Skipping [QUOTE]..[/QUOTE], [IMG]..[/IMG], [CODE]..[/CODE], [SQL]..[/SQL], [EMAIL]..[/EMAIL] tags */
bSkip = false;
for(j = 0; j < tagArray.length; j += 2){
rExp = new RegExp("^(\\["+tagArray[j]+tagArray[j+1]+"\\])","i");
if (newArr = str.substr(i).match(rExp)){
rExp = new RegExp("\\[\\/" + tagArray[j] + "\\]", "i");
if (iEnd = str.substr(i + newArr[1].length + 2).search(rExp)){
end_len = iEnd + newArr[1].length + tagArray[j].length + 4;
new_str += str.substr(i,end_len);
i += end_len - 1;
bSkip = true;
}
}
if(bSkip)break;
}
if(bSkip)continue;
// Check for 2-character letters
is2char=false;
if (i < len-1) {
for(j = 0; j < w_table2.length; j++)
{
if(str.substr(i, 2) == t_table2.substr(j*2,2)) {
new_str+= w_table2.substr(j, 1);
i++;
is2char=true;
break;
}
}
}
if(!is2char) {
// Convert one-character letter
var c = str.substr(i, 1);
var pos = t_table1.indexOf(c);
if (pos < 0)
new_str+= c;
else
new_str+= w_table1.substr(pos, 1);
}
}
return new_str;
}
function transliterate (msg, e)
{
if (e) e.disabled = true;
setTimeout(function() {
if (!bbcode.surround('', '', translit2win)) {
msg.value = translit2win(msg.value);
}
if (e) e.disabled = false;
}, 1);
}
});