|
|
| (۱۶ نسخهٔ میانی ویرایش شده توسط ۲ کاربر نشان داده نشد) |
| خط ۱: |
خط ۱: |
| // <nowiki> // DO NOT REMOVE THIS LINE EVER
| |
| /*jslint browser: true, white: true*/
| |
| /*global mediaWiki, jQuery*/
| |
| /*!
| |
| * @author User:Ebraminio, User:Yamaha5
| |
| */
| |
| (function ($, mw) { | | (function ($, mw) { |
| 'use strict'; | | var isVector2022 = mw.config.get('skin') === 'vector-2022'; |
| | | var portlet = isVector2022 ? 'p-collaboration' : 'p-tb'; |
| function createPage(title, text, summary, callback) {
| | $(mw.util.addPortletLink( |
| return new mw.Api().post({
| | portlet, |
| action: 'edit',
| | '//fa.wikipedia.org/wiki/%D9%88%DB%8C%DA%98%D9%87:%D8%B5%D9%81%D8%AD%D9%87%D9%94_%D8%AE%D8%A7%D9%84%DB%8C/tofawiki-conosle?withJS=MediaWiki:TofawikiConsole.js#redirectmaker|' + encodeURI(mw.config.get('wgPageName').replace(/_/g, ' ')), |
| title: title,
| | 'تغییرمسیر\u200cساز', |
| text: text,
| | 't-redirectmaker', |
| summary: summary,
| | 'ایجاد تغییرمسیر به صورت خودکار' |
| createonly: '',
| | )).attr('target', '_blank'); |
| bot: '',
| |
| token: mw.user.tokens.get('editToken')
| |
| });
| |
| }
| |
| | |
| // Make button by namespace
| |
| function makeButton() {
| |
| var namespaces = {
| |
| 0: "",
| |
| 2: "کاربر:",
| |
| 4: ["وپ:", "ویکی\u200cپدیا:"],
| |
| 6: "پرونده:",
| |
| 8: "مدیاویکی:",
| |
| 10: "الگو:",
| |
| 12: "راهنما:",
| |
| 14: "رده:",
| |
| 100: "درگاه:",
| |
| 102: "کتاب:",
| |
| 446: "برنامه آموزشی:",
| |
| 828: "پودمان:"
| |
| };
| |
| | |
| var append = "@";
| |
| var buttonText = "@";
| |
| var ns = mw.config.get("wgNamespaceNumber");
| |
| if (typeof namespaces[ns] === "object") {
| |
| append = namespaces[ns][0] + "@" + namespaces[ns][1] + mw.config.get("wgTitle");
| |
| buttonText = namespaces[ns][0] + "@اینجا";
| |
| } else if (typeof namespaces[ns] === "string") {
| |
| append = namespaces[ns] + "@" + namespaces[ns] + mw.config.get("wgTitle");
| |
| buttonText = namespaces[ns] + "@اینجا";
| |
| }
| |
| | |
| return $("<button>", {
| |
| text: buttonText,
| |
| style: "position: absolute; left: 1em;",
| |
| class: "mw-ui-button mw-ui-constructive"
| |
| }).click(function () {
| |
| var value = $("#redirectmakerinput").val().trim();
| |
| if (value !== '')
| |
| value = value + '\n';
| |
| value = value + append;
| |
| $("#redirectmakerinput").val(value).focus();
| |
| });
| |
| } | |
| | |
| function init(e) {
| |
| e.preventDefault();
| |
|
| |
| var form = $('<div>').append(
| |
| $('<div style="width: 40em">تغییرمسیرها را در خط\u200cهای جداگانه در جعبهٔ زیر وارد کنید:</div>'),
| |
| // makeButton(),
| |
| $('<textarea>', {
| |
| style: 'width: 100%; background-color: white; resize:vertical; padding-left: 50px;',
| |
| placeholder: 'مبدأ@مقصد',
| |
| id: 'redirectmakerinput',
| |
| rows: 7
| |
| })
| |
| );
| |
|
| |
| mw.loader.using('oojs-ui').then(function () {
| |
| mw.util.addCSS('.oo-ui-window-frame { width: 700px!important; }');
| |
| OO.ui.confirm(form).then(function (confirmed) {
| |
| if (!confirmed) return;
| |
|
| |
| var requests = $('#redirectmakerinput').val();
| |
| if (requests === '') {
| |
| mw.notify('لطفاً فرم درخواست را به درستی پر کنید');
| |
| return;
| |
| }
| |
| | |
| requests.split('\n').map(function (x) {
| |
| return function () {
| |
| var req = x.split('@');
| |
| if (req.length !== 2) {
| |
| return;
| |
| }
| |
| var from = req[0].trim();
| |
| var to = req[1].trim();
| |
| return createPage(
| |
| from,
| |
| '#تغییرمسیر [[' + to + ']]',
| |
| 'ایجاد تغییرمسیر برای [[' + to + ']] (ابزار تغییرمسیرساز)'
| |
| ).then(function () {
| |
| mw.notify('ایجاد ' + to + ' با موفقیت انجام شد.');
| |
| }, function () {
| |
| // revive the chain
| |
| return $.Deferred().resolve();
| |
| });
| |
| };
| |
| }).reduce(function (defer, job) {
| |
| return defer.then(job);
| |
| }, $.Deferred().resolve()).then(function () {
| |
| mw.notify('ایجاد تغییرمسیرها\u200cها به پایان رسید، لطفاً بررسی کنید.');
| |
| window.location = mw.util.getUrl('ویژه:مشارکتها/' + mw.config.get('wgUserName'));
| |
| });
| |
| });
| |
| });
| |
| }
| |
| | |
| $(function () {
| |
| //mw.util.addCSS('#t-redirectmaker { font-weight: bold; }');
| |
| $(mw.util.addPortletLink('p-tb', '#', 'تغییرمسیر\u200cساز', 't-redirectmaker', 'ایجاد تغییرمسیر به صورت خودکار')).click(init); | |
| });
| |
| }(jQuery, mediaWiki)); | | }(jQuery, mediaWiki)); |
(function ($, mw) {
var isVector2022 = mw.config.get('skin') === 'vector-2022';
var portlet = isVector2022 ? 'p-collaboration' : 'p-tb';
$(mw.util.addPortletLink(
portlet,
'//fa.wikipedia.org/wiki/%D9%88%DB%8C%DA%98%D9%87:%D8%B5%D9%81%D8%AD%D9%87%D9%94_%D8%AE%D8%A7%D9%84%DB%8C/tofawiki-conosle?withJS=MediaWiki:TofawikiConsole.js#redirectmaker|' + encodeURI(mw.config.get('wgPageName').replace(/_/g, ' ')),
'تغییرمسیر\u200cساز',
't-redirectmaker',
'ایجاد تغییرمسیر به صورت خودکار'
)).attr('target', '_blank');
}(jQuery, mediaWiki));