Flame | Дата: 16 Февраля 2008, 00:13 | Сообщение # 2 | ● ● ● ● ● Первый Помощник UcoZ-Helper`a 593 сообщения Статус: Offline | Вот сам скрипт транслита. Code <SCRIPT LANGUAGE="JavaScript"> var lat=new Array("jo","zh","i'","ch","sh","xh","je","ju","ja","a","b","v","g","d","e","z","i","k","l","m","n","o","p","r","s","t","u","f","x","c","'"," y","`","j","h"); var cyr=new Array("ё","ж","й","ч","ш","щ","э","ю","я","а","б","в","г","д","е","з","и","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ь","ы","ъ","ж ","х");
var latcap=new Array("JO","Jo","ZH","Zh","I'","Ch","CH","Sh","SH","Xh","XH","Je","JE","Ju","JU","Ja","JA","A","B","V","G","D","E","Z","I","K","L","M","N"," O","P","R","S","T","U","F","X","C","Y","J","H"); var cyrcap=new Array("Ё","Ё","Ж","Ж","Й","Ч","Ч","Ш","Ш","Щ","Щ","Э","Э","Ю","Ю","Я","Я","А","Б","В","Г","Д","Е","З","И","К","Л","М","Н","О","П","Р","С","Т ","У","Ф","Х","Ц","Ы","Ж","Х");
function translate(tex) { var buf=tex; var i; for (i=0;i<latcap.length;i++) { buf=replace(buf,latcap[i],cyrcap[i],1,0); }
for (i=0;i<lat.length;i++) { buf=replace(buf,lat[i],cyr[i],1,0); }
tex=buf; return tex; }
function replace(target,oldTerm,newTerm,caseSens,wordOnly) {
var work = target; var ind = 0; var next = 0;
if (!caseSens) { oldTerm = oldTerm.toLowerCase(); work = target.toLowerCase(); }
while ((ind = work.indexOf(oldTerm,next)) >= 0) { if (wordOnly) { var before = ind - 1; var after = ind + oldTerm.length; if (!(space(work.charAt(before)) && space(work.charAt(after)))) { next = ind + oldTerm.length; continue; } } target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length); work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length); next = ind + newTerm.length; if (next >= work.length) { break; } }
return target;
}
</SCRIPT>
<FORM METHOD="POST"> <textarea name=text2 cols=55 rows=17 wrap=virtual>Najmite "Perevod", monsen'er i chitai'te normal'nyi' tekst <img src="http://src.ucoz.ru/sm/2/smile.gif" border="0" align="absmiddle" alt="smile"> Pravila pol'zovanija perevodchikom s translita: 1-nabiraete tekst v okne po zadannym pravilam. 2-najimaete na "Perevod". 3-korrektiruete, esli trebuetsja, poluchennyi' tekst aglickimi bukovkami, soglasno pravilam. 4-najimaete na perevod (3 i 4 mojno povtorjat' poka ne tresnet brouzer ili ne poluchite trebuemoe) 5-vstavljaete, esli zadumano, aglickie slova (ne sleduet zhat' na knopku) 6-ispol'zuete poluchennyi' tekst po naznacheniju </textarea><BR> <input type=button value="Перевод" onclick="document.forms[0].text2.value=translate(document.forms[0].text2.value);"> <input type=button value="Очистить" onclick="document.forms[0].text2.value='';"> </FORM> | | |
|