/** Latin to Cyrillic Convertor version 3 Copyright (C) 2002 Petko Yotov http://5ko.free.fr/ Тази програма е "Свободен софтуер", автор Петко Йотов © 1999-2003. Това е свободна програма; можете да я разпространявате и/или променяте при условията на GNU GPL лиценза, публикуван от Фондацията за свободни програми: или версия 2, или (по Ваш избор) някоя следваща версия. Тази програма е създадена с надеждата, че ще бъде полезна, но БЕЗ НИКАКВА ГАРАНЦИЯ ЗА ТОВА, без дори косвена гаранция за ПРИГОДНОСТ ЗА ОПРЕДЕЛЕНА ЦЕЛ. Вижте GNU GPL лиценза за повече подробности. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ //пътят до скрипта и файла nastroiki3.html спрямо вашата страница path2js = "http://xdev-bg.com/forum/html/buditel/"; // може да е относителен, "javascripts/cyr/", "../scripts/cyr/", или // абсолютен, "/scripts/"; завършва с "/"; или празно, ако е в същата. // Ако викате скрипта от различни страници, дайте абсолютен път. dni = 60; //колко се запазва cookie-то // ограничители за латиница - ако имате форум, изберете подходящите ogra_original = "[]"; ogra_izbor = true; // възможност за промяна в "nastroiki3.html" // ако имате форум, може да сложите false. razdelitel_original = "'";//разделител s'hoden = сходен, а не шоден // link_na_kirilica = 'На кирилица'; link_na_latinica = 'На латиница'; link_nastroyki = 'Настройки'; link_pomosht = 'Помощ'; link_separator = ""; link_class = "lang"; button_na_kirilica = 'На кирилица'; button_na_latinica = 'На латиница'; button_nastroyki = 'Настройки'; button_pomosht = 'Помощ'; button_separator = "
\n"; button_class = "lang"; // Същинският скрипт // *** НЕ ПРОМЕНЯЙТЕ ПО-НАДОЛУ, ОСВЕН АКО ЗНАЕТЕ КАКВО ПРАВИТЕ! *** // *** NE PROMENIAYTE PO-NADOLU, OSVEN AKO ZNAETE KAKVO PRAVITE! *** azb_orig = "a.b.w.g.d.e.v.z.i.j.k.l.m.n.o.p.r.s.t.u.f.h.c.ch.sh.sht.y.x.ju.ja.." azbuka_original = azb_orig.split("."); bez_promiana = "..............................."; azbuka = new Array(); azb_frm = new Array(); function initiate() { // проверка дали има промени в Кукито tmp_c = getCookie("promeni"); tmp = (tmp_c.length>0)? tmp_c : bez_promiana; var promenen = tmp.split("."); tips = " "; azb = "абвгдежзийклмнопрстуфхцчшщъьюяыэАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯЫЭ"; for(i=0; i0)? promenen[i] : azbuka_original[i]; tips += "" + azb.charAt(i) + "=" + azbuka[i]; tips += (i % 5 != 4) ? " " : " ";//<br> ""; azb_frm[i] = azbuka[i]; //eval("document.def.bukva_" + i + ".value = \"" + azbuka[i] + "\";"); } razd = getCookie("rz"); razdelitel = (razd.length>0)? razd : razdelitel_original; //document.def.razdelitel.value = razdelitel; razdRegExpSave = ("^|*()[]{}.-+?$/\\".indexOf(razdelitel)<0)? razdelitel : "\\" + razdelitel; ogra = getCookie("og"); ogranichiteli = (ogra.length>0 && ogra_izbor)? ogra : ogra_original; og1 = ogranichiteli.charAt(0); og2 = ogranichiteli.charAt(1); tableau = new Array(); cyr = new Array(); azblen = azbuka.length; for(i=0; i=0 ; i--) //отзад напред - първо sht, после sh. { if(azbuka[i].length > 0 && azbuka[i] != " ") { var search_for = (to_lat)? cyr[i] : azbuka[i]; var replace_with = (to_lat)? azbuka[i] : cyr[i]; p = new RegExp(search_for, "g"); text = text.replace( p, replace_with ); p = new RegExp(search_for, "gi");// :)) text = text.replace( p, replace_with.toUpperCase() ); } } if(razdelitel.length > 0 && razdelitel != " ") { p = new RegExp(razdRegExpSave, "g"); text = text.replace(p, ""); } return text; } // 2 funkcii ot K&R :)) function permute(a, b) { var c = tableau[a]; var d = azbuka[a]; var e = cyr[a]; tableau[a] = tableau[b]; azbuka[a] = azbuka[b]; cyr[a] = cyr[b]; tableau[b] = c; azbuka[b] = d; cyr[b] = e; } function quicksort(gauche, droite) {// из "K&R quicksort" - сортира всички букви според // дължината на латинските еквиваленти. // Преводът трябва да почне от по-дългите. if (gauche >= droite) return; permute(gauche, Math.floor((gauche + droite) / 2)); dernier = gauche; for (i=gauche+1; i <=droite; i++) if (tableau[i] < tableau[gauche]) permute(++dernier, i); permute(gauche, dernier); quicksort(gauche, dernier-1); quicksort(dernier+1, droite); } function zapisvane()//за още (60) дни, само ако посетителят направи превод { if(tmp_c) setCookie("promeni", tmp_c, dni); if(razd) setCookie("rz", razd, dni); if(ogra) setCookie("og", ogra, dni); } function setCookie(ime, stoinost, dni) { if(dni == null)trainost = ""; else { EXPIR = new Date(); EXPIR.setTime(EXPIR.getTime() + (1000*60*60*24*dni)); trainost = "; expires=" + EXPIR.toGMTString(); } document.cookie = "" + ime + "=" + escape(stoinost) + trainost; } function getCookie(ime) { var nachalo = document.cookie.indexOf(ime + "="); if (nachalo == -1) return ""; // else var ind1 = nachalo + 1 + ime.length; ind2 = document.cookie.indexOf(";", ind1); if(ind2 == -1)ind2 = document.cookie.length; return unescape(document.cookie.substring(ind1, ind2)); } function nastroiki() { var nastr = window.open(path2js + "buditel-settings.html","nastr", "width=600,height=395,scrollbars"); nastr.focus(); } function pomosht() { var nastr = window.open(path2js + "buditel-help.html","nastr", "width=600,height=395,scrollbars"); nastr.focus(); } function textlinx() { document.write(' '); var html = ''+ link_na_kirilica +'' + link_separator; html += ''+ link_na_latinica +'' + link_separator; html += ''+ link_nastroyki +''; html += ''+ link_pomosht +''; document.writeln(html); } function buttons() { var html = ''+ button_separator; html += ''+ button_separator; html += ''; html += ''; document.writeln(html); } function whattime() {// тест за скорост var sega = new Date(); return sega.getTime(); } initiate();