|
|
Строка 1: |
Строка 1: |
− | /* <pre> */
| |
| /* tooltips and access keys */ | | /* tooltips and access keys */ |
| ta = new Object(); | | ta = new Object(); |
Строка 52: |
Строка 51: |
| ta['ca-nstab-help'] = new Array('c','Страница справки'); | | ta['ca-nstab-help'] = new Array('c','Страница справки'); |
| ta['ca-nstab-category'] = new Array('c','Страница категории'); | | ta['ca-nstab-category'] = new Array('c','Страница категории'); |
− |
| |
− | function addLoadEvent(func)
| |
− | {
| |
− | if (window.addEventListener)
| |
− | window.addEventListener("load", func, false);
| |
− | else if (window.attachEvent)
| |
− | window.attachEvent("onload", func);
| |
− | }
| |
− |
| |
− | //
| |
− | // Замена неправильного заголовка правильным by SergV
| |
− | //
| |
− |
| |
− | // Все неправильные заголовки
| |
− | title_restr_alerts = ["trestrictions_replace", "trestrictions_alert"];
| |
− |
| |
− | // Только шаблон title
| |
− | //title_restr_alerts = ["trestrictions_replace"];
| |
− |
| |
− | function display_correct_title () {
| |
− | var title_restr_alert1, a1;
| |
− | if (document.getElementsByTagName && document.getElementById) {
| |
− | for(var i=0; i < title_restr_alerts.length; i++) {
| |
− | title_restr_alert1 = title_restr_alerts[i];
| |
− | a1 = document.getElementById(title_restr_alert1);
| |
− | if(a1) {
| |
− | ct = document.getElementById("trestrictions_correct");
| |
− | if(ct) {
| |
− | document.getElementsByTagName("h1")[0].innerHTML = ct.innerHTML;
| |
− | a1.style.display = "none";
| |
− | document.getElementById("trestrictions_replaced").style.display = "block";
| |
− | }
| |
− | break;
| |
− | }
| |
− | }
| |
− | }
| |
− | }
| |
− |
| |
− | addLoadEvent(display_correct_title);
| |
− |
| |
− | // ============================================================
| |
− | // BEGIN Dynamic Navigation Bars (experimantal)
| |
− |
| |
− | // set up the words in your language
| |
− | var NavigationBarHide = '[ Скрыть ]';
| |
− | var NavigationBarShow = '[ Показать ]';
| |
− |
| |
− | // set up max count of Navigation Bars on page,
| |
− | // if there are more, all will be hidden
| |
− | // NavigationBarShowDefault = 0; // all bars will be hidden
| |
− | // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
| |
− | var NavigationBarShowDefault = 1;
| |
− |
| |
− |
| |
− | // shows and hides content and picture (if available) of navigation bars
| |
− | // Parameters:
| |
− | // indexNavigationBar: the index of navigation bar to be toggled
| |
− | function toggleNavigationBar(indexNavigationBar)
| |
− | {
| |
− | var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
| |
− | var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
| |
− |
| |
− | if (!NavFrame || !NavToggle) {
| |
− | return false;
| |
− | }
| |
− |
| |
− | // if shown now
| |
− | if (NavToggle.firstChild.data == NavigationBarHide) {
| |
− | for (
| |
− | var NavChild = NavFrame.firstChild;
| |
− | NavChild != null;
| |
− | NavChild = NavChild.nextSibling
| |
− | ) {
| |
− | if (NavChild.className == 'NavPic') {
| |
− | NavChild.style.display = 'none';
| |
− | }
| |
− | if (NavChild.className == 'NavContent') {
| |
− | NavChild.style.display = 'none';
| |
− | }
| |
− | }
| |
− | NavToggle.firstChild.data = NavigationBarShow;
| |
− |
| |
− | // if hidden now
| |
− | } else if (NavToggle.firstChild.data == NavigationBarShow) {
| |
− | for (
| |
− | var NavChild = NavFrame.firstChild;
| |
− | NavChild != null;
| |
− | NavChild = NavChild.nextSibling
| |
− | ) {
| |
− | if (NavChild.className == 'NavPic') {
| |
− | NavChild.style.display = 'block';
| |
− | }
| |
− | if (NavChild.className == 'NavContent') {
| |
− | NavChild.style.display = 'block';
| |
− | }
| |
− | }
| |
− | NavToggle.firstChild.data = NavigationBarHide;
| |
− | }
| |
− | }
| |
− |
| |
− | // adds show/hide-button to navigation bars
| |
− | function createNavigationBarToggleButton()
| |
− | {
| |
− | var indexNavigationBar = 0;
| |
− | // iterate over all < div >-elements
| |
− | for(
| |
− | var i=0;
| |
− | NavFrame = document.getElementsByTagName("div")[i];
| |
− | i++
| |
− | ) {
| |
− | // if found a navigation bar
| |
− | if (NavFrame.className == "NavFrame") {
| |
− |
| |
− | indexNavigationBar++;
| |
− | var NavToggle = document.createElement("a");
| |
− | NavToggle.className = 'NavToggle';
| |
− | NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
| |
− | NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
| |
− |
| |
− | var NavToggleText = document.createTextNode(NavigationBarHide);
| |
− | NavToggle.appendChild(NavToggleText);
| |
− | // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
| |
− | for(
| |
− | var j=0;
| |
− | j < NavFrame.childNodes.length;
| |
− | j++
| |
− | ) {
| |
− | if (NavFrame.childNodes[j].className == "NavHead") {
| |
− | NavFrame.childNodes[j].appendChild(NavToggle);
| |
− | }
| |
− | }
| |
− | NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
| |
− | }
| |
− | }
| |
− | // if more Navigation Bars found than Default: hide all
| |
− | if (NavigationBarShowDefault < indexNavigationBar) {
| |
− | for(
| |
− | var i=1;
| |
− | i<=indexNavigationBar;
| |
− | i++
| |
− | ) {
| |
− | toggleNavigationBar(i);
| |
− | }
| |
− | }
| |
− |
| |
− | }
| |
− |
| |
− | addLoadEvent(createNavigationBarToggleButton);
| |
− |
| |
− | // END Dynamic Navigation Bars
| |
− | // ============================================================
| |
− |
| |
− |
| |
− | /* add menu for selecting subsets of secial characters */
| |
− | /***** must match MediaWiki:Edittools *****/
| |
− |
| |
− | function addCharSubsetMenu() {
| |
− | var specialchars = document.getElementById('specialchars');
| |
− |
| |
− | if (specialchars) {
| |
− | var menu = "<select id=\"charsetBox\" style=\"display:inline\" onkeyup=\"chooseCharSubset(selectedIndex)\" onChange=\"chooseCharSubset(selectedIndex)\">";
| |
− | menu += "<option>Ещё спецсимволы</option>";
| |
− | menu += "<option>Отметки заготовок</option>";
| |
− | menu += "<option>Греческий алфавит</option>";
| |
− | menu += "<option>МФА (IPA)</option>";
| |
− | menu += "<option>Матем./TeX</option>";
| |
− | menu += "</select>";
| |
− | specialchars.innerHTML = menu + specialchars.innerHTML;
| |
− |
| |
− | /* default subset - try to use a cookie some day */
| |
− | chooseCharSubset(0);
| |
− | }
| |
− | }
| |
− |
| |
− | /* select subsection of special characters */
| |
− | function chooseCharSubset(s) {
| |
− | var l = document.getElementById('specialchars').getElementsByTagName('p');
| |
− | for (var i = 0; i < l.length ; i++) {
| |
− | l[i].style.display = i == s ? 'inline' : 'none';
| |
− | l[i].style.visibility = i == s ? 'visible' : 'hidden';
| |
− | }
| |
− | }
| |
− |
| |
− | addLoadEvent(addCharSubsetMenu);
| |
− |
| |
− |
| |
− | var mpTitle = "Заглавная страница";
| |
− | var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" — ")) == mpTitle);
| |
− | var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
| |
− |
| |
− | if (isMainPage && !isDiff)
| |
− | {
| |
− | document.write('<style type="text/css">/*<![CDATA[*/ #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
| |
− | }
| |
− |
| |
− | document.write('<script type="text/javascript" src="'
| |
− | + 'http://armor.kiev.ua/wiki/index.php?title=MediaWiki:Wikificator.js'
| |
− | + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
| |
− |
| |
− |
| |
− | /* Делаем ссылку "править" для нулевой секции */
| |
− | var disable_zero_section = 0;
| |
− | function edit_zero_section()
| |
− | {
| |
− | if((disable_zero_section !=1 ) && (document.getElementById('bodyContent').innerHTML.match('class=\"editsection\"')) && (!isMainPage))
| |
− | document.getElementById('bodyContent').innerHTML = "<div class=\"editsection\" id=\"ca-edit-0\" style=\"float: right; margin-left: 5px;\">[<a href=\"http://armor.kiev.ua/wiki/index.php?title=" + document.title.substr(0, document.title.lastIndexOf(" — ")) + "&action=edit§ion=0\">править</a>]</div>" + document.getElementById('bodyContent').innerHTML;
| |
− | }
| |
− | addLoadEvent(edit_zero_section);
| |
− |
| |
− |
| |
− |
| |
− | // Расширенный поиск
| |
− | // Автор: ru:User:Не А
| |
− |
| |
− | function SpecialSearchEnhanced()
| |
− | {
| |
− | var mainNode = document.getElementsByTagName("form");
| |
− | if (!mainNode) return;
| |
− |
| |
− | var searchValue = document.forms[0].search.value
| |
− | var firstForm = mainNode[0];
| |
− |
| |
− | var node = document.createElement('div');
| |
− |
| |
− | var googleSearch = '<form action="http://www.google.com/custom" method="get" name="google" target="_blank" id="google">';
| |
− | googleSearch += '<input type="hidden" name="hl" value="ru" />';
| |
− | googleSearch += '<input type="hidden" name="domains" value="armor.kiev.ua" />';
| |
− | googleSearch += '<input type="hidden" name="q" maxlength="2048" value="' + searchValue + '" />'
| |
− | googleSearch += '<input type="hidden" name="sitesearch" value="armor.kiev.ua" />'
| |
− | googleSearch += '<input type="button" value="Google по Википедии" onclick="document.google.q.value = document.forms[0].search.value; this.form.submit();" style="width: 12em;" />'
| |
− | googleSearch += '</form>'
| |
− |
| |
− | var yandexSearch = '<form action="http://www.yandex.ru/yandsearch" method="get" name="yandex" target="_blank" id="yandex">';
| |
− | yandexSearch += '<input type="hidden" name="text" maxlength="300" value="' + searchValue + '" />';
| |
− | yandexSearch += '<input type="hidden" name="site" value="armor.kiev.ua" />';
| |
− | yandexSearch += '<input type="hidden" name="ras" value="1" />'
| |
− | yandexSearch += '<input type="hidden" name="site_manually" value="true" />'
| |
− | yandexSearch += '<input type="hidden" name="server_name" value="Википедия" />'
| |
− | yandexSearch += '<input type="button" value="Яндекс по Википедии" onclick="document.yandex.text.value = document.forms[0].search.value; this.form.submit();" style="width: 12em;" />'
| |
− | yandexSearch += '</form>'
| |
− |
| |
− | node.innerHTML = node.innerHTML + '<table style="margin-left: 75%; padding-left:4px;"><tr><td>' + yandexSearch + '</td></tr><tr><td>' + googleSearch + '</td></tr></table>';
| |
− |
| |
− | firstForm.parentNode.insertBefore(node, firstForm.nextSibling);
| |
− | }
| |
− |
| |
− | if (wgPageName == "Служебная:Search") { addOnloadHook(SpecialSearchEnhanced); }
| |
− |
| |
− | //============================================================
| |
− | // Table generator
| |
− | //============================================================
| |
− |
| |
− | /**
| |
− | *
| |
− | * English: Generate an array using Mediawiki syntax
| |
− | *
| |
− | * @author: fr:user:dake (language conversion and new options added by en:user:Voice of All)
| |
− | * @version: 0.1
| |
− | */
| |
− |
| |
− | function generateTableau(nbCol, nbRow, border, styleHeader, styleLine, exfield, align, padding)
| |
− | {
| |
− | var code = "\n";
| |
− |
| |
− | if (padding==false) padding=0;
| |
− | else if (padding==true) padding=1;
| |
− |
| |
− | code += '{| align="' + align + '" class="standard"\n';
| |
− | code += '|+\n';
| |
− |
| |
− | for (var i=1;i<nbCol+1;i++) code += '! |Столбец ' + i + '\n';
| |
− |
| |
− | var items = 0;
| |
− | for (var j=0;j<nbRow;j++) {
| |
− | code += '|-----\n'
| |
− |
| |
− | for (var i=0;i<nbCol;i++) code += '| ячейка\n';
| |
− | }
| |
− |
| |
− | code += '|+\n';
| |
− | code += '|}\n';
| |
− | insertTags('','', code);
| |
− | }
| |
− |
| |
− | /**
| |
− | *
| |
− | * English: Open a popup with parameters to generate an array.
| |
− | * The number of rows/columns can be modified. Some additional
| |
− | * parameters are related to templates available on :fr
| |
− | *
| |
− | * @author: fr:user:dake
| |
− | * @version: 0.1
| |
− | */
| |
− |
| |
− | function popupTable()
| |
− | {
| |
− | var popup = window.open('','name','height=180,width=300,scrollbars=yes');
| |
− |
| |
− | javaCode = '<script type="text\/javascript">function insertCode(){';
| |
− | javaCode += 'var row = parseInt(document.paramForm.inputRow.value); '
| |
− | javaCode += 'var col = parseInt(document.paramForm.inputCol.value); '
| |
− | javaCode += 'var bord = 0; '
| |
− | javaCode += 'var styleHeader = false; '
| |
− | javaCode += 'var styleLine = false; '
| |
− | javaCode += 'var exfield = false; '
| |
− | javaCode += 'var align = document.paramForm.inputAlign.value; '
| |
− | javaCode += 'var padding = false; '
| |
− | javaCode += 'window.opener.generateTableau(col,row,bord,styleHeader,styleLine,exfield,align,padding); '
| |
− | javaCode += "alert('Таблица создана!'); "
| |
− | javaCode += 'window.close(); '
| |
− | javaCode += '}<\/script>';
| |
− |
| |
− | popup.document.write('<html><head><title>Создание таблицы</title>');
| |
− | popup.document.write('<script type="text\/javascript" src="\/skins\/common\/wikibits.js"><!-- wikibits js --><\/script>');
| |
− | popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins\/monobook\/main.css?5"; /*]]>*/<\/style>');
| |
− | popup.document.write(javaCode);
| |
− | popup.document.write('</head><body>');
| |
− | popup.document.write('<p>Введите параметры таблицы: </p>');
| |
− | popup.document.write('<form name="paramForm">');
| |
− | popup.document.write('Выравнивание: <input type="text" name="inputAlign" value="center" ><p>');
| |
− | popup.document.write('Количество строк: <input type="text" name="inputRow" value="3" ><p>');
| |
− | popup.document.write('Количество столбцов: <input type="text" name="inputCol" value="3" ><p>');
| |
− | popup.document.write('</form">');
| |
− | popup.document.write('<p><a href="javascript:insertCode()"> Вставить таблицу</a> |');
| |
− | popup.document.write(' <a href="javascript:self.close()">Отмена (закрыть окно)</a></p>');
| |
− | popup.document.write('</body></html>');
| |
− | popup.document.close();
| |
− | }
| |
− |
| |
− | //Ressemble à la fonction de /skins-1.5/commons/wikibits.js pour insérer un autre lien que insertTags
| |
− | function marque_tab()
| |
− | {
| |
− | var toolbar = document.getElementById('toolbar');
| |
− | if (!toolbar) return false;
| |
− |
| |
− | var textbox = document.getElementById('wpTextbox1');
| |
− | if (!textbox) return false;
| |
− |
| |
− | if (!document.selection && textbox.selectionStart == null)
| |
− | return false;
| |
− |
| |
− | var image = document.createElement("img");
| |
− | image.width = 23;
| |
− | image.height = 22;
| |
− | image.src = 'http://armor.kiev.ua/wiki/skins/common/images/button_array.png';
| |
− | image.border = 0;
| |
− | image.alt = 'Таблица';
| |
− | image.title = 'Создать таблицу';
| |
− | image.style.cursor = "pointer";
| |
− | image.onclick = function() {
| |
− | popupTable();
| |
− | return false;
| |
− | }
| |
− | toolbar.appendChild(image);
| |
− |
| |
− | var image2 = document.createElement("img");
| |
− | image2.width = 69;
| |
− | image2.height = 22;
| |
− | image2.src = 'http://armor.kiev.ua/wiki/skins/common/images/button-wikifikator.png';
| |
− | image2.border = 0;
| |
− | image2.alt = 'Викификатор';
| |
− | image2.title = 'Викификатор';
| |
− | image2.style.cursor = "pointer";
| |
− | image2.onclick = function() {
| |
− | Wikify();
| |
− | return false;
| |
− | }
| |
− | toolbar.appendChild(image2);
| |
− | }
| |
− |
| |
− | addOnloadHook(marque_tab);
| |
− |
| |
− | /* </pre> */
| |