MediaWiki:Editpage.js — различия между версиями
Crush (обсуждение | вклад) |
Crush (обсуждение | вклад) |
||
Строка 135: | Строка 135: | ||
addOnloadHook(SummaryButtons) | addOnloadHook(SummaryButtons) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/* </nowiki></pre> */ | /* </nowiki></pre> */ |
Версия 12:22, 4 октября 2011
/* <pre><nowiki> */ //Script 'Wikificator' from Wikipedia importScriptURI('http://wikilogia.ru/w/index.php?title=MediaWiki:Wikificator.js&action=raw&ctype=text/javascript') //Toolbar buttons function StandardButtons(){ if (mwEditButtons.length < 6) return mwEditButtons[5].tagClose = '|thumb]]' } function addFuncButton(img, tip, func){ var toolbar = document.getElementById('toolbar') if (!toolbar) return var i = document.createElement('img') i.src = img i.alt = tip; i.title = tip i.onclick = func i.style.cursor = 'pointer' toolbar.appendChild(i) } //Toolbar buttons function StandardButtons(){ if (mwEditButtons.length < 6) return mwEditButtons[5].tagClose = '|thumb]]' } function CustomButtons(){ addCustomButton('http://upload.wikimedia.org/wikipedia/ru/1/1d/Button_redirect_rus.png', 'Перенаправление','#REDIRECT [[',']]','название страницы') addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/3c/Button_cat_ru.png','Категория','[[Категория:',']]',''); addCustomButton('http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png', 'Комментарий', '<!-- ', ' -->', 'Комментарий') addCustomButton('http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png', 'Развёрнутая цитата', '<blockquote>', '</blockquote>', '') addCustomButton('http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png', 'Вставить таблицу', '{| class="wikitable"\n|-\n', '\n|}', '! заголовок 1\n! заголовок 2\n! заголовок 3\n|-\n| строка 1, ячейка 1\n| строка 1, ячейка 2\n| строка 1, ячейка 3\n|-\n| строка 2, ячейка 1\n| строка 2, ячейка 2\n| строка 2, ячейка 3') //Сноски mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png", "speedTip": "Сноски", "tagOpen": "<ref>", "tagClose": "</ref>", "sampleText": ""} mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/8/88/Btn_toolbar_enum.png", "speedTip": "Шаблон «Примечания»", "tagOpen": "== Примечания ==\n", "tagClose": "{{примечания}}", "sampleText": ""} mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/13/Button_enter.png", "speedTip": "Разрыв", "tagOpen": "<br />", "tagClose": "", "sampleText": ""} mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/af/Button_Fractur_OCR.png", "speedTip": "Горизонталь", "tagOpen": "{{ГоризонтальНачало}}\n", "tagClose": "\n{{ГоризонтальКонец}}", "sampleText": ""} } function addCustomButton(img, tip, open, close, sample){ mwCustomEditButtons[mwCustomEditButtons.length] = {'imageFile':img, 'speedTip':tip, 'tagOpen':open, 'tagClose':close, 'sampleText':sample} } function WikifButton(){ var t = document.getElementById('wpTextbox1') if (!t || (!document.selection && t.selectionStart == null)) return addFuncButton('http://upload.wikimedia.org/wikisource/ru/d/d1/Button-wikifikator.png', 'Викификатор', Wikify) } function addFuncButton(img, tip, func){ var toolbar = document.getElementById('toolbar') if (!toolbar) return var i = document.createElement('img') i.src = img i.alt = tip; i.title = tip i.onclick = func i.style.cursor = 'pointer' toolbar.appendChild(i) } //Edit Summary buttons function SummaryButtons(){ var wpSummary = document.getElementById('wpSummary') if (!wpSummary || (wpSummary.form.wpSection && wpSummary.form.wpSection.value == 'new')) return wpSummaryBtn = document.createElement('span') //global var wpSummaryBtn.id = 'userSummaryButtonsA' wpSummary.parentNode.insertBefore(wpSummaryBtn, wpSummary.nextSibling) wpSummary.parentNode.insertBefore(document.createElement('br'), wpSummary.nextSibling) addSumButton('типогр.', 'типографика', 'Проведена викификация') addSumButton('оформл.', 'оформлення', 'Изменено оформление') addSumButton('стил.', 'стилистика', 'Поправлен стиль изложения') addSumButton('орфогр.', 'виправлення', 'Поправлена орфография') addSumButton('пункт.', 'пунктуация', 'Изменена пунктуация') addSumButton('кат.', 'категория', 'Поправлена категоризация') addSumButton('шаб.', 'шаблон', 'Добавлен / изменён шаблон') addSumButton('доп.', 'доповнення', 'Добавлены новые сведения') addSumButton('илл.', 'картинка', 'Размещена иллюстрация') addSumButton('обнов.', 'обновлення', 'Обновлены данные') } function addSumButton(name, text, title) { var btn = document.createElement('a') btn.appendChild(document.createTextNode(name)) btn.title = title btn.onclick = function(){insertSummary(text)} wpSummaryBtn.appendChild(btn) } function insertSummary(text) { var wpSummary = document.getElementById('wpSummary') if (wpSummary.value.indexOf(text) != -1) return if (wpSummary.value.match(/[^,; \/]$/)) wpSummary.value += ',' if (wpSummary.value.match(/[^ ]$/)) wpSummary.value += ' ' wpSummary.value += text } //call functions addOnloadHook(StandardButtons) addOnloadHook(CustomButtons) addOnloadHook(WikifButton) addOnloadHook(SummaryButtons) /* </nowiki></pre> */