|
|
| (не показаны 362 промежуточные версии 18 участников) |
| Строка 1: |
Строка 1: |
| /* <pre><nowiki> */ | | /* Нигилистические фокусы (см. шаблон {{tl|Нигилизм}}) */ |
| | $(function () { |
| | var nihilism = $('#nihilism'); |
| | if (nihilism[0] && !document.location.href.match("diff")) { |
| | var msg = nihilism.html(); |
| | if (!nihilism.hasClass('nihilism-no-white')) { |
| | $('body').css('background-color', 'white'); |
| | } |
| | var scripts = $('script'); |
| | var bodyNihilism = $('body').html(''); |
| | var divNihilism = $('<div class="mw-parser-output"></div>').html(msg); |
| | if (nihilism.css('top') == '0px') { |
| | bodyNihilism.css('top', '0px').css('left', '0px'); |
| | } |
| | bodyNihilism.append(divNihilism).append(scripts); |
| | $(document).dblclick(function () { |
| | window.location = mw.util.getUrl(null, {'action': 'edit'}); |
| | }); |
| | } |
| | }); |
|
| |
|
| | /* Стирание памяти для [[MIB]] («Людей в чёрном») */ |
| | $(function () { |
| | if ($("#erase_memory")[0]) |
| | setTimeout(function () { $("#erase_memory").hide(); }, 20000); |
| | }); |
|
| |
|
| /* tooltips and access keys */ | | /* Ссылка «править» для нулевой секции */ |
| ta = new Object();
| | $(function () { |
| ta['pt-userpage'] = new Array('.','Моя страница пользователя');
| | var zeroSectionTip = "Править введение"; |
| ta['pt-anonuserpage'] = new Array('.','Страница пользователя для моего IP');
| |
| ta['pt-mytalk'] = new Array('n','Моя страница обсуждений');
| |
| ta['pt-anontalk'] = new Array('n','Страница обсуждений для моего IP');
| |
| ta['pt-preferences'] = new Array('','Мои настройки');
| |
| ta['pt-watchlist'] = new Array('l','Список страниц моего наблюдения');
| |
| ta['pt-mycontris'] = new Array('y','Список страниц, которые я редактировал');
| |
| ta['pt-login'] = new Array('o','Здесь можно зарегистрироваться в системе, но это необязательно');
| |
| ta['pt-anonlogin'] = new Array('o','Здесь можно зарегистрироваться в системе, но это необязательно');
| |
| ta['pt-logout'] = new Array('o','Отказаться от регистрации');
| |
| ta['ca-talk'] = new Array('t','Обсуждение статьи');
| |
| ta['ca-edit'] = new Array('e','Эту статью можно изменять. Перед сохранением изменений, пожалуйста, нажмите кнопку предварительного просмотра для визуальной проверки результата');
| |
| ta['ca-addsection'] = new Array('+','Добавить комментарий к обсуждению');
| |
| ta['ca-viewsource'] = new Array('e','Эта страница защищена от изменений, но вы можете посмотреть и скопировать её исходный текст');
| |
| ta['ca-history'] = new Array('h','Журнал изменений страницы');
| |
| ta['ca-protect'] = new Array('=','Защитить страницу от изменений');
| |
| ta['ca-delete'] = new Array('d','Удалить эту страницу');
| |
| ta['ca-undelete'] = new Array('d','Восстановить исправления страницы, сделанные до того, как она была удалена');
| |
| ta['ca-move'] = new Array('m','Переименовать страницу');
| |
| ta['ca-watch'] = new Array('w','Добавить эту страницу в ваш список наблюдения');
| |
| ta['ca-unwatch'] = new Array('w','Удалить эту страницу из вашего списка наблюдения');
| |
| ta['search'] = new Array('f','Искать это слово');
| |
| ta['p-logo'] = new Array('','Заглавная страница');
| |
| ta['n-mainpage'] = new Array('z','Перейти на заглавную страницу');
| |
| ta['n-portal'] = new Array('','О проекте, о том, что вы можете сделать, где что находится');
| |
| ta['n-currentevents'] = new Array('','Список текущих событий');
| |
| ta['n-recentchanges'] = new Array('r','Список последних изменений');
| |
| ta['n-randompage'] = new Array('x','Посмотреть случайную страницу');
| |
| ta['n-help'] = new Array('','Справочник по проекту «{{SITENAME}}»');
| |
| ta['n-sitesupport'] = new Array('','Поддержите проект');
| |
| ta['t-whatlinkshere'] = new Array('j','Список всех страниц, которые ссылаются на эту страницу');
| |
| ta['t-recentchangeslinked'] = new Array('k','Последние изменения в страницах, которые ссылаются на эту страницу');
| |
| ta['feed-rss'] = new Array('','Трансляция в формате RSS для этой страницы');
| |
| ta['feed-atom'] = new Array('','Трансляция в формате Atom для этой страницы');
| |
| ta['t-contributions'] = new Array('','Список страниц, которые изменял этот участник');
| |
| ta['t-emailuser'] = new Array('','Отправить письмо этому участнику');
| |
| ta['t-upload'] = new Array('u','Загрузить изображения или мультимедиа-файлы');
| |
| ta['t-specialpages'] = new Array('q','Список служебных страниц');
| |
| ta['t-print']=new Array('', 'Версия без кнопок, пригодная для распечатки');
| |
| ta['t-permalink'] = new Array('', 'Ссылка на текущую версию этой статьи');
| |
| ta['ca-nstab-main'] = new Array('c','Содержание статьи');
| |
| ta['ca-nstab-user'] = new Array('c','Персональная страница участника');
| |
| ta['ca-nstab-media'] = new Array('c','Мультимедиа-файл');
| |
| ta['ca-nstab-special'] = new Array('','Это служебная страница, она недоступна для редактирования');
| |
| ta['ca-nstab-wp'] = new Array('a','Страница проекта');
| |
| ta['ca-nstab-image'] = new Array('c','Страница изображения');
| |
| ta['ca-nstab-mediawiki'] = new Array('c','Страница сообщения MediaWiki');
| |
| ta['ca-nstab-template'] = new Array('c','Страница шаблона');
| |
| ta['ca-nstab-help'] = new Array('c','Страница справки');
| |
| ta['ca-nstab-category'] = new Array('c','Страница категории');
| |
|
| |
|
| /* Абсурдофикатор */
| | if (!mw.config.get("wgArticleId")) { |
| | return; |
| | } |
|
| |
|
| var t = new Array(); | | var action = mw.config.get("wgAction"); |
| t['stub'] = new Array("{" + "{stub", "", "}}");
| | if (action != "view" && action != "purge") |
| t['crap'] = new Array("{" + "{crap", "", "}}");
| | return; |
| t['vfd'] = new Array("{" + "{vfd", "", "}}");
| |
| t['q'] = new Array("{" + "{q", "|…|кто-то|кого-то ещё", "}}");
| |
|
| |
|
| document.onkeypress = pressed
| | mw.util.$content.find("h2").children(".mw-editsection:first").clone().prependTo("#bodyContent").css("float", "right").find("a").each(function (index) { |
| function pressed() //Вызов по Ctrl+Enter (в MSIE)
| | $(this).attr("title", zeroSectionTip); |
| {key = window.event.keyCode;if (key==10){obrabotka();}}
| | if ($(this).attr("class") === "mw-editsection-visualeditor") { |
| //======================================
| | $(this).attr("href", mw.config.get("wgScript") + "?title=" + mw.util.wikiUrlencode(mw.config.get("wgPageName")) + "&veaction=edit&vesection=0&summary=/*%20Преамбула%20*/%20"); |
| function obrabotka()
| | } else { |
| {
| | $(this).attr("href", mw.config.get("wgScript") + "?title=" + mw.util.wikiUrlencode(mw.config.get("wgPageName")) + "&action=edit§ion=0&summary=/*%20Преамбула%20*/%20"); |
| check_regexp() //Проверяем, поддерживаются ли рег. выражения
| | } |
| document.editform.wpTextbox1.focus()
| | }); |
| var txtarea = document.editform.wpTextbox1
| | }); |
| if(document.selection && !is_gecko)/* IE */ {
| |
| txt = " "+document.selection.createRange().text
| |
| if (txt == " ") {all_text();} //Если ничего не выделено
| |
| else{
| |
| zamena()
| |
| txt = txt.substr (1, txt.length-1)
| |
| document.selection.createRange().text = txt
| |
| }
| |
| }
| |
| else if((txtarea.selectionStart || txtarea.selectionStart == '0')&&(navigator.productSub>20031000)) /*Gecko-браузеры старше 10.2003*/ {
| |
| var startPos = txtarea.selectionStart
| |
| var endPos = txtarea.selectionEnd
| |
| var scrollTop=txtarea.scrollTop
| |
| txt = " "+(txtarea.value).substring(startPos, endPos)
| |
| if (txt == " ") {all_text();} //Если ничего не выделено
| |
| else{
| |
| zamena()
| |
| txt = txt.substr (1, txt.length-1)
| |
| txtarea.value = txtarea.value.substring(0, startPos) + txt + txtarea.value.substring(endPos, txtarea.value.length)
| |
| txtarea.focus()
| |
| }
| |
| }
| |
| else{if (confirm("Викификатор обработает ВЕСЬ текст статьи. Продолжить?")){all_text();}} //Прочие браузеры
| |
| }
| |
| //======================================
| |
| function all_text()//Обрабатываем текст целиком
| |
| {
| |
| txt = " "+document.editform.wpTextbox1.value
| |
| zamena()
| |
| txt = txt.substr (1, txt.length-1)
| |
| document.editform.wpTextbox1.value=txt
| |
| }
| |
| //======================================
| |
| function check_regexp()//Проверяем поддерживаются ли рег. выражения
| |
| {
| |
| var reg1 = "код"
| |
| reg1 = reg1.replace(/д/g, "т")
| |
| if (reg1 != "кот"){alert("Wikificator cannot work in your browser");exit;}
| |
| b_ver = navigator.appVersion.substr (0, 1)
| |
| if (navigator.appName=="Netscape"&&b_ver<5){alert("Wikificator will not work in Netscape 4.x and less");exit;}
| |
| return
| |
| }
| |
| function zamena() | |
| // Для исключений у нас остались ещё 3 безопасные пары символов в диапазоне \x1A — \x1F !
| |
| { | |
| //Исключаем из обработки всё, что находится между тегами <nowiki> и </nowiki>
| |
| i_nowiki = 0
| |
| a_nowiki = txt.match(/\<nowiki\>(.|\r|\n)+?\<\/nowiki\>/gm)
| |
| r_nowiki = /\<nowiki\>(.|\r|\n)+?\<\/nowiki\>/m
| |
| while (r_nowiki.test(txt))
| |
| {
| |
| i_nowiki++;
| |
| txt = txt.replace(r_nowiki, "\x03"+i_nowiki+"\x04")
| |
| }
| |
| //======================================
| |
| //Исключаем из обработки всё, что находится между тегами <math> и </math>
| |
| i_math = 0
| |
| a_math = txt.match(/\<math\>(.|\r|\n)+?\<\/math\>/gm)
| |
| r_math = /\<math\>(.|\r|\n)+?\<\/math\>/m
| |
| while (r_math.test(txt))
| |
| {
| |
| i_math++;
| |
| txt = txt.replace(r_math, "\x05"+i_math+"\x06")
| |
| }
| |
| //======================================
| |
| // Исключаем всё между <pre> и </pre>
| |
| i_pre = 0
| |
| a_pre = txt.match(/<pre>(.|\r|\n)+?<\/pre>/gim)
| |
| r_pre = /<pre>(.|\r|\n)+?<\/pre>/im
| |
| while (r_pre.test(txt))
| |
| {
| |
| i_pre++
| |
| txt = txt.replace(r_pre, "\x12"+i_pre+"\x13")
| |
| }
| |
| //======================================
| |
| // Исключаем всё между <gallery> и </gallery>
| |
| i_gallery = 0
| |
| a_gallery = txt.match(/<gallery>(.|\r|\n)+?<\/gallery>/gim)
| |
| r_gallery = /<gallery>(.|\r|\n)+?<\/gallery>/im
| |
| while (r_gallery.test(txt))
| |
| {
| |
| i_gallery++
| |
| txt = txt.replace(r_gallery, "\x14"+i_gallery+"\x15")
| |
| }
| |
| //======================================
| |
| //Исключаем из обработки строки, начинающиеся с пробела
| |
| f_space = txt.substr (0, 1)
| |
| txt = txt.substr (1, txt.length-1)
| |
| i_space = 0
| |
| a_space = txt.match(/^( )(.+)$/gm)
| |
| r_space = /^( )(.+)$/m;
| |
| while (r_space.test(txt))
| |
| {
| |
| i_space++
| |
| txt = txt.replace(r_space, "\x16"+i_space+"\x17")
| |
| }
| |
| txt = f_space + txt
| |
| //======================================
| |
| //Исключаем всё между {{ и }}
| |
| i_template = 0
| |
| a_template = txt.match(/\{\{(.|\r|\n)+?\}\}/gm)
| |
| r_template = /\{\{(.|\r|\n)+?\}\}/m
| |
| while (r_template.test(txt))
| |
| {
| |
| i_template++
| |
| txt = txt.replace(r_template, "\x18"+i_template+"\x19")
| |
| }
| |
| //======================================
| |
| // Заменяем теги <b>, <strong> на ''' и <i>, <em> на ''
| |
| txt = txt.replace(/\<\/?(b|strong)\>/gim, "\'\'\'")
| |
| txt = txt.replace(/\<\/?(i|em)\>/gim, "\'\'")
| |
| // Заменяем тег <hr> на ----, поправляем теги <hr> и <br>
| |
| txt = txt.replace(/\<hr ?\/?\>/gi, "----")
| |
| txt = txt.replace(/\<hr ([^\>\/]+?) ?\/?\>/gi, "<hr $1 />")
| |
| txt = txt.replace(/\<br\/?\>/gi, "<br />")
| |
| txt = txt.replace(/\<br ([^\>\/]+?) ?\/?\>/gi, "<br $1 />")
| |
| //======================================
| |
| //Кубы и квадраты одним символом
| |
| txt = txt.replace(/(<sup>2<\/sup>|²)/g, "?");
| |
| txt = txt.replace(/(<sup>3<\/sup>|³)/g, "?");
| |
| txt = txt.replace(/(\^2)(\D)/g, "?$2");
| |
| txt = txt.replace(/(\^3)(\D)/g, "?$2");
| |
| //======================================
| |
| // Поправляем диапазоны годов
| |
| txt = txt.replace(/(\(|\s)(\[?\[?[12]?\d{3}\]?\]?)[\u00A0 ]?(-|--|–|—) ?(\[?\[?[12]?\d{3}\]?\]?)(\W)/g, "$1$2—$4$5")
| |
| txt = txt.replace(/(\[?\[?[12]?\d{3}\]?\]?) ?(г\.|гг\.)/g, "$1\u00A0$2")
| |
| // Поправляем диапазоны веков
| |
| txt = txt.replace(/(\(|\s)(\[?\[?[IVX]{1,5}\]?\]?)[\u00A0 ]?(-|--|–|—) ?(\[?\[?[IVX]{1,5}\]?\]?)(\W)/g, "$1$2—$4$5")
| |
| txt = txt.replace(/(\[?\[?[IVX]{1,5}\]?\]?) ?(в\.|вв\.)/g, "$1\u00A0$2")
| |
| //======================================
| |
| //Обработка служебных слов
| |
| txt = txt.replace(/(\[\[)(:?)(category|категория)(:)( *)/gi, "$1$2Категория$4")
| |
| txt = txt.replace(/(\[\[)(template|шаблон)(:)( *)/gi, "$1Шаблон$3")
| |
| txt = txt.replace(/(\[\[)(user|участник)(:)( *)/gi, "$1Участник$3")
| |
| txt = txt.replace(/(\[\[)(image|изображение)(:)( *)/gi, "$1Изображение$3")
| |
| txt = txt.replace(/(\[\[)(media|медиа)(:)( *)/gi, "$1Медиа$3")
| |
| //======================================
| |
| //Меняем двойной дефис на тире
| |
| txt = txt.replace(/(--)(\[\[Участник|\~\~\~)/g, "—$2")
| |
| //Исключаем всё между [[ и ]], или между [[ и |
| |
| i_links = 0
| |
| a_links = txt.match(/(\[\[)(.*?)(\||\]\])/g)
| |
| r_links = /(\[\[)(.*?)(\||\]\])/
| |
| while (r_links.test(txt))
| |
| {
| |
| i_links++
| |
| txt = txt.replace(r_links, "\x10"+i_links+"\x11")
| |
| }
| |
| //======================================
| |
| //Вставка пробела в заголовки
| |
| txt = txt.replace(/^(=+)([ \t\f\v]*)(.*?)([ \t\f\v]*)(=+)$/gm, "$1 $3 $1")
| |
| //Исключаем из обработки весь текст в кавычках после знака "="
| |
| i_equal = 0
| |
| a_equal = txt.match(/(=)(\s?)(\")(.*?)(\")/g)
| |
| r_equal = /(=)(\s?)(\")(.*?)(\")/
| |
| while (r_equal.test(txt))
| |
| {
| |
| i_equal++
| |
| txt = txt.replace(r_equal, "\x0E"+i_equal+"\x0F")
| |
| }
| |
| //======================================
| |
| //Заменяем обычными кавычками сочетания << и >>
| |
| txt = txt.replace(/(<<)(\S.+\S)(>>)/g, "\"$2\"")
| |
| //======================================
| |
| //Исключаем из обработки прочие HTML-теги ("<" и ">")
| |
| i = 0
| |
| a = txt.match(/<([^>]*?)>/gm)
| |
| r = /<([^>]*?)>/m
| |
| while (r.test(txt))
| |
| {
| |
| i++
| |
| txt = txt.replace(r, "\x01"+i+"\x02")
| |
| } | |
| //======================================
| |
| //Заменяем правильные символы на неверные, чтобы ничего не пропустить
| |
| txt = txt.replace(/–/g, "-")
| |
| txt = txt.replace(/(«|»|“|”|„|\&((la|ra|bd|ld)quo|#132|#147|#148|quot);)/g, "\"")
| |
| //======================================
| |
| // Обработчик знака градуса "°", "+-" и "~="
| |
| txt = txt.replace(/(\+[--])|(±)/g, "±")
| |
| txt = txt.replace(/(~=)/g, "?")
| |
| txt = txt.replace(/\°/g, "°")
| |
| txt = txt.replace(/([ =????<>("'|]|^)([+±?\-]?\d+?(?:[.,]\d+?)?)(([ °^*]| [°^*])[CС])(?=[ "').,;!?|]|$)/gm, "$1$2\u00A0°C")
| |
| txt = txt.replace(/([ =????<>("'|]|^)([+±?\-]?\d+?(?:[.,]\d+?)?)(([ °^*]| [°^*])F)(?=[ "').,;|!?]|$)/gm, "$1$2\u00A0°F")
| |
| //======================================
| |
| // Заменяем "...", "…" и "…" на многоточие
| |
| txt = txt.replace(/(\.{3}|\&(hellip|#133);)/g, '…')
| |
| // Обработчик апострофа
| |
| txt = txt.replace(/([\wа-яА-ЯёЁ])'([\wа-яА-ЯёЁ])/g, "$1’$2")
| |
| // Обработчик минуса
| |
| txt = txt.replace(/(sup\>|sub\>|\s)-(\d)/g, "$1?$2")
| |
| //======================================
| |
| // Заменяем дефисы и короткое тире на правильное тире
| |
| txt = txt.replace(/\&(#151|[nm]dash);/g, "—")
| |
| txt = txt.replace(/( |[\f\n\r\t\v\u00A0\u2028\u2029])(-|--|–) /g, "$1— ")
| |
| txt = txt.replace(/(\d)--(\d)/g, "$1—$2")
| |
| // Вставляем неразрывный пробел перед тире
| |
| txt = txt.replace(/(\S) (-|--|–|—) (\S)/g, "$1\u00A0— $3")
| |
| //======================================
| |
| // Спец-значки ©, ®, ™, §, €, ? и ?.
| |
| txt = txt.replace(/\©/gi, "©")
| |
| txt = txt.replace(/(\(r\)|\®)/gi, "®")
| |
| txt = txt.replace(/(\((tm|тм)\)|\™)/gi, "™")
| |
| txt = txt.replace(/(\(p\)|\§)/gi, "§")
| |
| txt = txt.replace (/\€/gi, "€")
| |
| txt = txt.replace (/\¥/gi, "?")
| |
| txt = txt.replace (/\£/gi, "?")
| |
| //======================================
| |
| // Поправляем сокращения
| |
| txt = txt.replace(/(Т|т)\. ?е\./g, "$1о есть")
| |
| txt = txt.replace(/(Т|т)\. ?к\./g, "$1ак как")
| |
| txt = txt.replace(/(В|в) т\. ?ч\./g, "$1 том числе")
| |
| txt = txt.replace(/и т\. ?д\./g, "и\u00A0т\.\u00A0д\.")
| |
| txt = txt.replace(/и т\. ?п\./g, "и\u00A0т\.\u00A0п\.")
| |
| txt = txt.replace(/(Т|т)\. ?н\./g, "$1\.\u00A0н\.")
| |
| txt = txt.replace(/н\. ?э\./g, "н\.\u00A0э\.")
| |
| txt = txt.replace(/(Д|д)(о|\.) н\. ?э\./g, "$1о\u00A0н\.\u00A0э\.")
| |
| txt = txt.replace(/(\d) (тыс)([^\.А-Яа-яЁё])/g, "$1\u00A0$2.$3")
| |
| txt = txt.replace(/(\d) (млн|млрд|трлн)([^А-Яа-яЁё])/g, "$1\u00A0$2$3")
| |
| // Вставляем пропущенные и убираем лишние пробелы
| |
| txt = txt.replace(/([А-Я]\.) ?([А-Я]\.) ?([А-Я][а-я])/g, "$1\u00A0$2\u00A0$3")
| |
| txt = txt.replace(/([А-Я]\.)([А-Я]\.)/g, "$1 $2")
| |
| txt = txt.replace(/^([#\*:]+)([ \t\f\v]*)([^ \t\f\v\*#:])/gm, "$1 $3")
| |
| txt = txt.replace(/([а-я])(\.)([А-ЯA-Z])/g, "$1$2 $3")
| |
| txt = txt.replace(/([а-яa-z\)\»\“\"\]])(\s*)(\,)([а-яa-z\(\«\„\"\[])/g, "$1$3 $4")
| |
| txt = txt.replace(/([а-яa-z\)\»\“\"\]])(\s)([\,\;])(\s)([а-яa-z\(\«\„\"\[])/g, "$1$3 $5")
| |
| txt = txt.replace(/([^%\w]\d+?(?:[.,]\d+?)?) ?([%‰])(?!-[А-Яа-яЁё])/g, "$1\u00A0$2")
| |
| txt = txt.replace(/(\d) ([%‰])(?=-[А-Яа-яЁё])/g, "$1$2")
| |
| txt = txt.replace(/([№§])(\s*)(\d)/g, "$1\u00A0$3")
| |
| txt = txt.replace(/(^|[^ \t])([ \t]+)($|\n)/gm, "$1$3")
| |
| txt = txt.replace(/(\()( +)/g, "$1");
| |
| txt = txt.replace(/( +)(\))/g, "$2");
| |
| //======================================
| |
| //Убираем двойные пробелы
| |
| txt = txt.substr (1, txt.length-1);
| |
| txt = txt.replace(/(\S)([ \t]{2,})([\S\r])/g, "$1 $3")
| |
| txt = " " + txt
| |
| //======================================
| |
| // Заменяем кавычки (") на кавычки-ёлочки
| |
| txt = txt.replace(/([\x01-(\s\|\"]|\/|\+)(\")([^\"]{0,})([^\s\"(])(\")/g, "$1«\$3\$4»")
| |
| // Кавычки внутри кавычек
| |
| if (/"/.test(txt))
| |
| {
| |
| txt = txt.replace(/([\x01(\s\"])(\")([^\"]{0,})([^\s\"(])(\")/g, "\$1«\$3\$4»")
| |
| while (/(«)([^»]*)(«)/.test(txt))
| |
| txt = txt.replace(/(«)([^»]*)(«)([^»]*)(»)/g, "\$1\$2„\$4“") | |
| } | |
| //======================================
| |
| //Возвращаем обратно HTML-теги ("<" и ">")
| |
| i = 0
| |
| r = /\x01([0-9]*)\x02/
| |
| while (r.test(txt))
| |
| {
| |
| i++
| |
| txt = txt.replace(r, a[i-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно текст в кавычках после знака "="
| |
| i_equal = 0;
| |
| r_equal = /\x0E([0-9]*)\x0F/
| |
| while (r_equal.test(txt))
| |
| {
| |
| i_equal++
| |
| txt = txt.replace(r_equal, a_equal[i_equal-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно текст между [[ и ]]
| |
| i_links = 0
| |
| r_links = /\x10([0-9]*)\x11/
| |
| while (r_links.test(txt))
| |
| {
| |
| i_links++
| |
| txt = txt.replace(r_links, a_links[i_links-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно текст между {{ и }}
| |
| i_template = 0
| |
| r_template = /\x18([0-9]*)\x19/
| |
| while (r_template.test(txt))
| |
| {
| |
| i_template++
| |
| txt = txt.replace(r_template, a_template[i_template-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно строки, начинающиеся с пробела.
| |
| i_space = 0
| |
| r_space = /\x16([0-9]*)\x17/
| |
| while (r_space.test(txt))
| |
| {
| |
| i_space++
| |
| txt = txt.replace(r_space, a_space[i_space-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно текст между <gallery> и </gallery>
| |
| i_gallery = 0
| |
| r_gallery = /\x14([0-9]*)\x15/
| |
| while (r_gallery.test(txt))
| |
| {
| |
| i_gallery++
| |
| txt = txt.replace(r_gallery, a_gallery[i_gallery-1])
| |
| } | |
| //======================================
| |
| //Возвращаем обратно текст между <pre> и </pre>
| |
| i_pre = 0
| |
| r_pre = /\x12([0-9]*)\x13/
| |
| while (r_pre.test(txt))
| |
| {
| |
| i_pre++
| |
| txt = txt.replace(r_pre, a_pre[i_pre-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно всё, что было между тегами "math".
| |
| i_math = 0;
| |
| r_math = /\x05([0-9]*)\x06/
| |
| while (r_math.test(txt))
| |
| {
| |
| i_math++
| |
| txt = txt.replace(r_math, a_math[i_math-1])
| |
| }
| |
| //======================================
| |
| //Возвращаем обратно всё, что было между тегами "nowiki".
| |
| i_nowiki = 0;
| |
| r_nowiki = /\x03([0-9]*)\x04/
| |
| while (r_nowiki.test(txt))
| |
| {
| |
| i_nowiki++
| |
| txt = txt.replace(r_nowiki, a_nowiki[i_nowiki-1])
| |
| }
| |
| }
| |
|
| |
|
| /* </nowiki></pre> */ | | /* Вставка юзернейма с помощью <span class="insertusername"></span> */ |
| | $(function () { |
| | if ((typeof (disableUsernameReplace) == "undefined" || !disableUsernameReplace) && mw.config.get("wgUserName") !== null) { |
| | var username = mw.config.get("wgUserName"); |
| | $("span.insertusername").text(username); |
| | } |
| | }); |
| | |
| | |
| | /* Замена категорий для шаблона {{Cats}} */ |
| | $(function () { |
| | var categoriesAlternative = $("#categories_alternative"); |
| | if (categoriesAlternative[0]) { |
| | $('#mw-normal-catlinks').html(categoriesAlternative.html()); |
| | categoriesAlternative.hide(); |
| | } |
| | }); |
| | |
| | |
| | /* Вставка VK-видео на страницу для шаблона {{VKVideo}} */ |
| | (function() { |
| | 'use strict'; |
| | |
| | function initVKVideo() { |
| | var containers = document.querySelectorAll('.vk-video-js'); |
| | |
| | for (var i = 0; i < containers.length; i++) { |
| | var container = containers[i]; |
| | var oid = container.getAttribute('data-oid'); |
| | var id = container.getAttribute('data-id'); |
| | var width = container.getAttribute('data-width') || '560'; |
| | var height = container.getAttribute('data-height') || '315'; |
| | |
| | width = parseInt(width) || 560; |
| | height = parseInt(height) || 315; |
| | if (width > 1920) width = 1920; |
| | if (height < 100) height = 100; |
| | if (height > 1080) height = 1080; |
| | |
| | if (oid && id && oid !== 'null' && id !== 'null' && /^[a-zA-Z0-9_-]{1,100}$/.test(oid) && /^[-_a-zA-Z0-9]+$/.test(id)) { |
| | var iframe = document.createElement('iframe'); |
| | iframe.src = 'https://vk.com/video_ext.php?oid=' + encodeURIComponent(oid) + '&id=' + encodeURIComponent(id); |
| | iframe.width = width; |
| | iframe.height = height; |
| | iframe.frameBorder = '0'; |
| | iframe.allowFullscreen = true; |
| | |
| | iframe.sandbox = 'allow-scripts allow-same-origin allow-presentation allow-fullscreen'; |
| | iframe.allow = 'fullscreen'; |
| | iframe.referrerPolicy = 'no-referrer'; |
| | iframe.loading = 'lazy'; |
| | iframe.style.border = 'none'; |
| | |
| | while (container.firstChild) { |
| | container.removeChild(container.firstChild); |
| | } |
| | container.appendChild(iframe); |
| | } else { |
| | var errorDiv = document.createElement('div'); |
| | |
| | errorDiv.style.color = 'red'; |
| | errorDiv.style.padding = '10px'; |
| | errorDiv.style.textAlign = 'center'; |
| | errorDiv.style.border = '1px solid'; |
| | errorDiv.style.backgroundColor = '#fff'; |
| | errorDiv.style.fontFamily = 'Arial, sans-serif'; |
| | errorDiv.style.fontSize = '14px'; |
| | errorDiv.style.margin = '5px 0'; |
| | |
| | errorDiv.textContent = 'Ошибка: неверные параметры видео'; |
| | |
| | while (container.firstChild) { |
| | container.removeChild(container.firstChild); |
| | } |
| | container.appendChild(errorDiv); |
| | } |
| | } |
| | } |
| | |
| | if (document.readyState === 'loading') { |
| | document.addEventListener('DOMContentLoaded', initVKVideo); |
| | } else { |
| | initVKVideo(); |
| | } |
| | })(); |