پرش به محتوا

مدیاویکی:Gadget-close.js: تفاوت میان نسخه‌ها

از دانشنامه علوم انسانی
imported>Yamaha5
اصلاح خلاصه ویرایش لید
imported>Yamaha5
خنثی‌سازی ویرایش 22935866 توسط Yamaha5 (بحث)
خط ۸: خط ۸:
         install: function() {
         install: function() {
             if ($.inArray(mw.config.get("wgNamespaceNumber"), [1, 3, 4, 5, 7, 9, 11, 13, 15]) > -1) {
             if ($.inArray(mw.config.get("wgNamespaceNumber"), [1, 3, 4, 5, 7, 9, 11, 13, 15]) > -1) {
                  
                 // افزودن دکمه به لید
                 var our_content = $("#content, #mw_content").first();
                 var our_content = $("#content, #mw_content").first();
                 var span1 = our_content.find("span.mw-editsection:not(.plainlinks)").first();
                 var span1 = our_content.find("span.mw-editsection:not(.plainlinks)").first();
                 if (!span1.length) {
                 if (!span1.length) {
                  return;
                    return;
                 }
                 }
                 var span0 = span1.clone();
                 var span0 = span1.clone();
                 $("#mw_header h1, #content h1").first().append(span0);
                 $("#mw_header h1, #content h1").first().append(span0);
                 span0.find("a").each(function (idx) {
                 span0.find("a").each(function(idx) {
                     var a = $(this);
                     var a = $(this);
                     a.attr("title", 'ویرایش بخش آغازین');
                     a.attr("title", 'ویرایش بخش آغازین');
                     if ( !/&(ve|)section=T/.test( a.attr( "href" ) ) ) { // not transcluded
                     if (!/&(ve|)section=T/.test(a.attr("href"))) { // not transcluded
                      a.attr( "href", a.attr( "href" ).replace( /&(ve|)section=\d+/, "&$1section=0&summary=/*%20لید%20*/%20" ) );
                        a.attr("href", a.attr("href").replace(/&(ve|)section=\d+/, "&$1section=0&summary=/*%20لید%20*/%20"));
                     } else if ( /&vesection=/.test( a.attr( "href" ) ) ) { // transcluded, VE
                     } else if (/&vesection=/.test(a.attr("href"))) { // transcluded, VE
                         a.attr( "href", mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + "?veaction=edit&vesection=0&summary=/*%20لید%20*/%20" );
                         a.attr("href", mw.util.getUrl(mw.config.get('wgPageName')) + "?veaction=edit&vesection=0&summary=/*%20لید%20*/%20");
                     } else { // transcluded, not VE
                     } else { // transcluded, not VE
                         a.attr( "href", mw.util.getUrl( mw.config.get( 'wgPageName' ) ) + "?action=edit&section=0&summary=/*%20لید%20*/%20" );
                         a.attr("href", mw.util.getUrl(mw.config.get('wgPageName')) + "?action=edit&section=0&summary=/*%20لید%20*/%20");
                     }
                     }
                 });
                 });
                // افزودن دکمه به زیربخش‌ها
                 $('.mw-editsection').each(function() {
                 $('.mw-editsection').each(function() {
                     var section = '';
                     var section = '';
                     $(this).find('a').each(function(){
                     $(this).find('a').each(function() {
                         var m = $(this).attr('href').match(/section=(\d+)/);
                         var m = $(this).attr('href').match(/section=(\d+)/);
                         if (m && m.length == 2 && section == '') {
                         if (m && m.length == 2 && section == '') {
                             section = $(this).attr('href');
                             section = $(this).attr('href');
                         }
                         }
                     });  
                     });
                     var span = $('<span>', {
                     var span = $('<span>', {
                         class: 'mw-archivesection'
                         class: 'mw-archivesection'
خط ۱۱۸: خط ۱۱۸:
                 archiveSectionOptions.textSummary = new OO.ui.MultilineTextInputWidget({
                 archiveSectionOptions.textSummary = new OO.ui.MultilineTextInputWidget({
                     placeholder: 'متن جمع‌بندی را وارد کنید',
                     placeholder: 'متن جمع‌بندی را وارد کنید',
                     rows:6,
                     rows: 6,
                 });
                 });
                 //archiveSectionOptions.textSummary.setRTL(true);
                 //archiveSectionOptions.textSummary.setRTL(true);
خط ۱۹۸: خط ۱۹۸:
                     this.content = new OO.ui.FieldsetLayout();
                     this.content = new OO.ui.FieldsetLayout();
                     var PingUsers = current.match(/\[\[(?:بحث[_ ]کاربر|[Uu]ser[_ ][tT]alk)\:([^\]]+)\]\]/gi)
                     var PingUsers = current.match(/\[\[(?:بحث[_ ]کاربر|[Uu]ser[_ ][tT]alk)\:([^\]]+)\]\]/gi)
                     if (!PingUsers){
                     if (!PingUsers) {
                         var PingUsers = current.match(/\[\[(?:کاربر|[Uu]ser)\:([^\]]+)\]\]/gi)
                         var PingUsers = current.match(/\[\[(?:کاربر|[Uu]ser)\:([^\]]+)\]\]/gi)
                     }
                     }
                     var uniqueNames = [];
                     var uniqueNames = [];
                     $.each(PingUsers, function(i, el){
                     $.each(PingUsers, function(i, el) {
                         var username = el.split('|')[0].split('/')[0].split('#')[0].split(':')[1];
                         var username = el.split('|')[0].split('/')[0].split('#')[0].split(':')[1];
                         if($.inArray(username, uniqueNames) === -1 && username != mw.config.get('wgUserName')) {
                         if ($.inArray(username, uniqueNames) === -1 && username != mw.config.get('wgUserName')) {
                             uniqueNames.push(username);
                             uniqueNames.push(username);
                         }
                         }
                     });
                     });
                     var finallList=[]
                     var finallList = []
                     var i;
                     var i;
                     for (i = 0; i < uniqueNames.length; i++) {  
                     for (i = 0; i < uniqueNames.length; i++) {
                                finallList.push({data:uniqueNames[i],lable:'کاربر:'+uniqueNames[i]})
                        finallList.push({
                            data: uniqueNames[i],
                            lable: 'کاربر:' + uniqueNames[i]
                        })
                     }
                     }
                     archiveSectionOptions.MultiselectPingUser = new OO.ui.MenuTagMultiselectWidget( {
                     archiveSectionOptions.MultiselectPingUser = new OO.ui.MenuTagMultiselectWidget({
                         inputPosition: 'outline',
                         inputPosition: 'outline',
                         options: finallList,
                         options: finallList,
                         placeholder: 'از اینجا نام کاربری که قصد پاسخ دارید، انتخاب کنید یا ابتدای نامش را بنویسید',
                         placeholder: 'از اینجا نام کاربری که قصد پاسخ دارید، انتخاب کنید یا ابتدای نامش را بنویسید',
                         selected: []
                         selected: []
                     } );
                     });
                     archiveSectionOptions.sameIndent = new OO.ui.ToggleSwitchWidget({
                     archiveSectionOptions.sameIndent = new OO.ui.ToggleSwitchWidget({
                         label: 'پاسخ هم‌دندانه',
                         label: 'پاسخ هم‌دندانه',
خط ۲۴۸: خط ۲۵۱:
                         align: 'inline',
                         align: 'inline',
                     }));
                     }));
                   
 
                       
 
                     archiveSectionOptions.radioCommentType = new OO.ui.RadioSelectWidget({
                     archiveSectionOptions.radioCommentType = new OO.ui.RadioSelectWidget({
                         items: [
                         items: [
خط ۲۶۱: خط ۲۶۴:
                         ]
                         ]
                     });
                     });
                     archiveSectionOptions.editButton = new OO.ui.ButtonWidget( {
                     archiveSectionOptions.editButton = new OO.ui.ButtonWidget({
                         label: 'ابرابزار',
                         label: 'ابرابزار',
                         flags: [
                         flags: [
خط ۲۶۷: خط ۲۷۰:
                             'progressive'
                             'progressive'
                         ]
                         ]
                     } );
                     });
                     if (persianWikiTools) {
                     if (persianWikiTools) {
                         archiveSectionOptions.editButton.on( 'click', function() {
                         archiveSectionOptions.editButton.on('click', function() {
                              
 
                                archiveSectionOptions.textComment.setValue(persianWikiTools.superTool(archiveSectionOptions.textComment.getValue( ) ).trim())
                             archiveSectionOptions.textComment.setValue(persianWikiTools.superTool(archiveSectionOptions.textComment.getValue()).trim())
                           
 
                         } );
                         });
                     } else {
                     } else {
                         archiveSectionOptions.editButton.setDisabled( true )
                         archiveSectionOptions.editButton.setDisabled(true)
                     }
                     }


           
 
                     archiveSectionOptions.radioCommentType.selectItem(archiveSectionOptions.radioComment);
                     archiveSectionOptions.radioCommentType.selectItem(archiveSectionOptions.radioComment);
                     archiveSectionOptions.textComment = new OO.ui.MultilineTextInputWidget({
                     archiveSectionOptions.textComment = new OO.ui.MultilineTextInputWidget({
                         placeholder: 'متن نظر را وارد کنید',
                         placeholder: 'متن نظر را وارد کنید',
                         rows:6,
                         rows: 6,
                     });
                     });
                     //archiveSectionOptions.textComment.setRTL(true);
                     //archiveSectionOptions.textComment.setRTL(true);
خط ۳۳۰: خط ۳۳۳:
             var lines = text.split('\n');
             var lines = text.split('\n');
             var lastline = lines[lines.length - 1];
             var lastline = lines[lines.length - 1];
             var colons=lastline.match('^([\#\*]?)(\:*)')
             var colons = lastline.match('^([\#\*]?)(\:*)')
             var colonNum = colons [2].length;
             var colonNum = colons[2].length;
             var colonType = colons [1];
             var colonType = colons[1];
             if (!archiveSectionOptions.sameIndent.getValue()){
             if (!archiveSectionOptions.sameIndent.getValue()) {
                 colonNum=colonNum-1
                 colonNum = colonNum - 1
             }
             }
             var indentation = '';
             var indentation = '';
             for (var i = 0; i < colonNum+1; i++) {
             for (var i = 0; i < colonNum + 1; i++) {
                 indentation += ':';
                 indentation += ':';
             }
             }
             text = text + '\n' + colonType + indentation + newText.trim().replace(/\n/ig,'\n'+ colonType +indentation).trim();
             text = text + '\n' + colonType + indentation + newText.trim().replace(/\n/ig, '\n' + colonType + indentation).trim();
             return text
             return text
         },
         },
خط ۳۶۰: خط ۳۶۳:
                 var section_title = (current.match(/^(=+)[^=]*?(\1)$/m) || [''])[0];
                 var section_title = (current.match(/^(=+)[^=]*?(\1)$/m) || [''])[0];
                 section_title = section_title.replace(/\=/g, '');
                 section_title = section_title.replace(/\=/g, '');
                if (!section_title){
                    section_title='لید'
                }
                 var editSummary = '/' + '*' + section_title + '*' + '/ ';
                 var editSummary = '/' + '*' + section_title + '*' + '/ ';
                 if (action == 'archive') {
                 if (action == 'archive') {
خط ۴۲۷: خط ۴۲۷:
                     }
                     }
                     if (archiveSectionOptions.MultiselectPingUser.getValue()) {
                     if (archiveSectionOptions.MultiselectPingUser.getValue()) {
                         var userlist=archiveSectionOptions.MultiselectPingUser.getValue()
                         var userlist = archiveSectionOptions.MultiselectPingUser.getValue()
                         var Pingtxt = '{{پینگ|'+archiveSectionOptions.MultiselectPingUser.getValue()+'}}'
                         var Pingtxt = '{{پینگ|' + archiveSectionOptions.MultiselectPingUser.getValue() + '}}'
                         Pingtxt=Pingtxt.replace(/\,/g,'|')
                         Pingtxt = Pingtxt.replace(/\,/g, '|')
                         var userTalkPage=mw.config.get("wgTitle")
                         var userTalkPage = mw.config.get("wgTitle")
                         Pingtxt=Pingtxt.replace('|'+userTalkPage+'}}','|}}').replace('|'+userTalkPage+'|','|')
                         Pingtxt = Pingtxt.replace('|' + userTalkPage + '}}', '|}}').replace('|' + userTalkPage + '|', '|')
                         var PingtxteditSummary=' + پاسخ به کاربر:'+Pingtxt.replace('{{پینگ|','').replace('}}','').trim().replace(/\|/g ,'، ')
                         var PingtxteditSummary = ' + پاسخ به کاربر:' + Pingtxt.replace('{{پینگ|', '').replace('}}', '').trim().replace(/\|/g, '، ')
                     } else {
                     } else {
                         var Pingtxt = ''
                         var Pingtxt = ''
                     }
                     }
                     if (Pingtxt=='{{پینگ|}}'){
                     if (Pingtxt == '{{پینگ|}}') {
                         Pingtxt=''
                         Pingtxt = ''
                         PingtxteditSummary=''
                         PingtxteditSummary = ''
                     }
                     }
                     if (archiveSectionOptions.radioDone.isSelected()) {
                     if (archiveSectionOptions.radioDone.isSelected()) {
                         newText = Pingtxt + '{{شد}} ';
                         newText = Pingtxt + '{{شد}} ';
                         editSummary += 'انجام شد'+PingtxteditSummary;
                         editSummary += 'انجام شد' + PingtxteditSummary;
                     } else if (archiveSectionOptions.radioComment.isSelected()) {
                     } else if (archiveSectionOptions.radioComment.isSelected()) {
                         newText = Pingtxt + '';
                         newText = Pingtxt + '';
                         editSummary += 'پیام'+PingtxteditSummary;
                         editSummary += 'پیام' + PingtxteditSummary;
                     } else if (archiveSectionOptions.radioReject.isSelected()) {
                     } else if (archiveSectionOptions.radioReject.isSelected()) {
                         newText = Pingtxt + '{{نشد}} ';
                         newText = Pingtxt + '{{نشد}} ';
                         editSummary += 'انجام نشد'+PingtxteditSummary;
                         editSummary += 'انجام نشد' + PingtxteditSummary;
                     } else if (archiveSectionOptions.radioKeep.isSelected()) {
                     } else if (archiveSectionOptions.radioKeep.isSelected()) {
                         newText = prefix + Pingtxt + ' {{بماند}} ';
                         newText = prefix + Pingtxt + ' {{بماند}} ';
                         editSummary += 'ثبت نظر بماند'+PingtxteditSummary;
                         editSummary += 'ثبت نظر بماند' + PingtxteditSummary;
                     } else if (archiveSectionOptions.radioDelete.isSelected()) {
                     } else if (archiveSectionOptions.radioDelete.isSelected()) {
                         newText = prefix + Pingtxt + ' {{حذف}} ';
                         newText = prefix + Pingtxt + ' {{حذف}} ';
                         editSummary += 'ثبت نظر حذف شود'+PingtxteditSummary;
                         editSummary += 'ثبت نظر حذف شود' + PingtxteditSummary;
                     } else if (archiveSectionOptions.radioSupport.isSelected()) {
                     } else if (archiveSectionOptions.radioSupport.isSelected()) {
                         newText = prefix + Pingtxt + ' {{موافق}} ';
                         newText = prefix + Pingtxt + ' {{موافق}} ';
                         editSummary += 'ثبت نظر موافق'+PingtxteditSummary;
                         editSummary += 'ثبت نظر موافق' + PingtxteditSummary;
                     } else {
                     } else {
                         newText = prefix + Pingtxt + ' {{مخالف}} ';
                         newText = prefix + Pingtxt + ' {{مخالف}} ';
                         editSummary += 'ثبت نظر مخالف'+PingtxteditSummary;
                         editSummary += 'ثبت نظر مخالف' + PingtxteditSummary;
                     }
                     }
                     newText += archiveSectionOptions.textComment.getValue();
                     newText += archiveSectionOptions.textComment.getValue();
خط ۴۸۹: خط ۴۸۹:
                     mw.notify('در حال ثبت نظر شما ...');
                     mw.notify('در حال ثبت نظر شما ...');
                 }
                 }
                 if (sectionId==0){
                 if (sectionId == 0) {
                     sectionId=1
                     sectionId = 1
                 }
                 }
                 location.hash = $('.mw-headline')[sectionId - 1].id;
                 location.hash = $('.mw-headline')[sectionId - 1].id;

نسخهٔ ۱۱ آوریل ۲۰۱۸، ساعت ۱۷:۵۷

/*global jQuery, mediaWiki */
(function($, mw) {
    'use strict';
    var windowManager;
    var archiveSection;
    var commentInSection;
    var archiveSectionOptions = {
        install: function() {
            if ($.inArray(mw.config.get("wgNamespaceNumber"), [1, 3, 4, 5, 7, 9, 11, 13, 15]) > -1) {
                // افزودن دکمه به لید
                var our_content = $("#content, #mw_content").first();
                var span1 = our_content.find("span.mw-editsection:not(.plainlinks)").first();
                if (!span1.length) {
                    return;
                }
                var span0 = span1.clone();
                $("#mw_header h1, #content h1").first().append(span0);
                span0.find("a").each(function(idx) {
                    var a = $(this);
                    a.attr("title", 'ویرایش بخش آغازین');
                    if (!/&(ve|)section=T/.test(a.attr("href"))) { // not transcluded
                        a.attr("href", a.attr("href").replace(/&(ve|)section=\d+/, "&$1section=0&summary=/*%20لید%20*/%20"));
                    } else if (/&vesection=/.test(a.attr("href"))) { // transcluded, VE
                        a.attr("href", mw.util.getUrl(mw.config.get('wgPageName')) + "?veaction=edit&vesection=0&summary=/*%20لید%20*/%20");
                    } else { // transcluded, not VE
                        a.attr("href", mw.util.getUrl(mw.config.get('wgPageName')) + "?action=edit&section=0&summary=/*%20لید%20*/%20");
                    }
                });
                // افزودن دکمه به زیربخش‌ها
                $('.mw-editsection').each(function() {
                    var section = '';
                    $(this).find('a').each(function() {
                        var m = $(this).attr('href').match(/section=(\d+)/);
                        if (m && m.length == 2 && section == '') {
                            section = $(this).attr('href');
                        }
                    });
                    var span = $('<span>', {
                        class: 'mw-archivesection'
                    }).insertAfter(this);
                    span.append($('<span>', {
                        class: 'mw-editsection-bracket',
                        text: '['
                    }));
                    span.append($('<a>', {
                        href: '#',
                        title: 'ثبت نظر (موافق/مخالف/شد/...)',
                        style: 'font-size: smaller;',
                        text: 'ثبت نظر',
                    }).click(function(e) {
                        e.preventDefault();
                        mw.loader.using(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows']).done(function() {
                            archiveSectionOptions.createCommentWindow(section);
                        });
                    }));
                    span.append($('<span>', {
                        class: 'mw-editsection-bracket',
                        text: ' / '
                    }));
                    span.append($('<a>', {
                        href: '#',
                        title: 'جمع‌بندی این بخش',
                        style: 'font-size: smaller;',
                        text: 'جمع‌بندی',
                    }).click(function(e) {
                        e.preventDefault();
                        mw.loader.using(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows']).done(function() {
                            archiveSectionOptions.createArchiveWindow(section);
                        });
                    }));
                    span.append($('<span>', {
                        class: 'mw-editsection-bracket',
                        text: ']'
                    }));
                    // Late pre-loading
                    mw.loader.load(['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows']);
                });
            }
        },
        createArchiveWindow: function(section) {
            var query = archiveSectionOptions.getQuery(section);
            archiveSectionOptions.currentSectionId = query.section;

            function ArchiveSection(config) {
                ArchiveSection.super.call(this, config);
            }
            OO.inheritClass(ArchiveSection, OO.ui.ProcessDialog);
            ArchiveSection.static.name = 'archive';
            ArchiveSection.static.title = 'جمع‌بندی بخش';
            ArchiveSection.static.actions = [{
                action: 'archive',
                label: 'جمع‌بندی',
                flags: 'primary'
            }, {
                label: 'لغو',
                flags: 'safe'
            }];
            ArchiveSection.prototype.initialize = function() {
                var fieldset = [];
                ArchiveSection.super.prototype.initialize.apply(this, arguments);
                this.panel = new OO.ui.PanelLayout({
                    padded: true,
                    expanded: false
                });
                this.content = new OO.ui.FieldsetLayout();
                archiveSectionOptions.switchTop = new OO.ui.ToggleSwitchWidget({
                    label: 'جمع‌بندی بالای متن باشد',
                    value: true,
                });
                archiveSectionOptions.switchSuccess = new OO.ui.ToggleSwitchWidget({
                    label: 'بحث در رسیدن به اجماع موفق بود',
                    value: true,
                });
                archiveSectionOptions.switchBold = new OO.ui.ToggleSwitchWidget({
                    label: 'متن جمع‌بندی ضخیم نمایش داده شود',
                    value: false,
                });
                archiveSectionOptions.textSummary = new OO.ui.MultilineTextInputWidget({
                    placeholder: 'متن جمع‌بندی را وارد کنید',
                    rows: 6,
                });
                //archiveSectionOptions.textSummary.setRTL(true);
                fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.switchTop, {
                    label: 'جمع‌بندی بالای متن باشد',
                    align: 'inline',
                }));
                fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.switchSuccess, {
                    label: 'بحث در رسیدن به اجماع موفق بود',
                    align: 'inline',
                }));
                fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.switchBold, {
                    label: 'متن جمع‌بندی ضخیم نمایش داده شود',
                    align: 'inline',
                }));
                fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.textSummary, {
                    label: 'جمع‌بندی:',
                    align: 'top'
                }));
                this.content.addItems(fieldset);
                this.panel.$element.append(this.content.$element);
                this.$body.append(this.panel.$element);
            };
            ArchiveSection.prototype.getActionProcess = function(action) {
                var dialog = this;
                if (action === 'archive') {
                    archiveSectionOptions.doEdit(archiveSectionOptions.currentSectionId, action);
                }
                return ArchiveSection.super.prototype.getActionProcess.call(this, action);
            };
            if (!windowManager) {
                windowManager = new OO.ui.WindowManager();
                $('body').append(windowManager.$element);
            }
            if (!archiveSection) {
                archiveSection = new ArchiveSection({
                    size: 'medium'
                });
                windowManager.addWindows([archiveSection]);
            }
            windowManager.openWindow(archiveSection);
        },
        createCommentWindow: function(section) {
            var query = archiveSectionOptions.getQuery(section);
            archiveSectionOptions.currentSectionId = query.section;
            (new mw.Api()).get({
                format: 'json',
                action: 'query',
                titles: mw.config.get("wgPageName"),
                rvsection: query.section,
                prop: 'revisions',
                rvprop: 'content',
            }).then(function(data) {
                var page = data.query.pages[Object.keys(data.query.pages)[0]];
                var current = page.revisions[0]['*'];


                function CommentInSection(config) {
                    CommentInSection.super.call(this, config);
                }
                OO.inheritClass(CommentInSection, OO.ui.ProcessDialog);
                CommentInSection.static.name = 'comment';
                CommentInSection.static.title = 'ثبت نظر';
                CommentInSection.static.actions = [{
                    action: 'comment',
                    label: 'ثبت نظر',
                    flags: 'primary'
                }, {
                    label: 'لغو',
                    flags: 'safe'
                }];
                CommentInSection.prototype.initialize = function() {
                    var fieldset = [];
                    CommentInSection.super.prototype.initialize.apply(this, arguments);
                    this.panel = new OO.ui.PanelLayout({
                        padded: true,
                        expanded: false
                    });
                    this.content = new OO.ui.FieldsetLayout();
                    var PingUsers = current.match(/\[\[(?:بحث[_ ]کاربر|[Uu]ser[_ ][tT]alk)\:([^\]]+)\]\]/gi)
                    if (!PingUsers) {
                        var PingUsers = current.match(/\[\[(?:کاربر|[Uu]ser)\:([^\]]+)\]\]/gi)
                    }
                    var uniqueNames = [];
                    $.each(PingUsers, function(i, el) {
                        var username = el.split('|')[0].split('/')[0].split('#')[0].split(':')[1];
                        if ($.inArray(username, uniqueNames) === -1 && username != mw.config.get('wgUserName')) {
                            uniqueNames.push(username);
                        }
                    });
                    var finallList = []
                    var i;
                    for (i = 0; i < uniqueNames.length; i++) {
                        finallList.push({
                            data: uniqueNames[i],
                            lable: 'کاربر:' + uniqueNames[i]
                        })
                    }
                    archiveSectionOptions.MultiselectPingUser = new OO.ui.MenuTagMultiselectWidget({
                        inputPosition: 'outline',
                        options: finallList,
                        placeholder: 'از اینجا نام کاربری که قصد پاسخ دارید، انتخاب کنید یا ابتدای نامش را بنویسید',
                        selected: []
                    });
                    archiveSectionOptions.sameIndent = new OO.ui.ToggleSwitchWidget({
                        label: 'پاسخ هم‌دندانه',
                        value: true,
                    });
                    archiveSectionOptions.radioComment = new OO.ui.RadioOptionWidget({
                        label: 'پیام',
                    });
                    archiveSectionOptions.radioDone = new OO.ui.RadioOptionWidget({
                        label: 'شد',
                    });
                    archiveSectionOptions.radioReject = new OO.ui.RadioOptionWidget({
                        label: 'نشد',
                    });
                    archiveSectionOptions.radioSupport = new OO.ui.RadioOptionWidget({
                        label: 'موافق',
                    });
                    archiveSectionOptions.radioOppose = new OO.ui.RadioOptionWidget({
                        label: 'مخالف',
                    });
                    archiveSectionOptions.radioDelete = new OO.ui.RadioOptionWidget({
                        label: 'حذف شود',
                    });
                    archiveSectionOptions.radioKeep = new OO.ui.RadioOptionWidget({
                        label: 'بماند',
                    });
                    fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.MultiselectPingUser, {
                        label: 'انتخاب کاربران شرکت‌کننده در بحث برای پاسخ (پینگ)',
                        align: 'inline',
                    }));


                    archiveSectionOptions.radioCommentType = new OO.ui.RadioSelectWidget({
                        items: [
                            archiveSectionOptions.radioComment,
                            archiveSectionOptions.radioDone,
                            archiveSectionOptions.radioReject,
                            archiveSectionOptions.radioSupport,
                            archiveSectionOptions.radioOppose,
                            archiveSectionOptions.radioDelete,
                            archiveSectionOptions.radioKeep
                        ]
                    });
                    archiveSectionOptions.editButton = new OO.ui.ButtonWidget({
                        label: 'ابرابزار',
                        flags: [
                            'primary',
                            'progressive'
                        ]
                    });
                    if (persianWikiTools) {
                        archiveSectionOptions.editButton.on('click', function() {

                            archiveSectionOptions.textComment.setValue(persianWikiTools.superTool(archiveSectionOptions.textComment.getValue()).trim())

                        });
                    } else {
                        archiveSectionOptions.editButton.setDisabled(true)
                    }


                    archiveSectionOptions.radioCommentType.selectItem(archiveSectionOptions.radioComment);
                    archiveSectionOptions.textComment = new OO.ui.MultilineTextInputWidget({
                        placeholder: 'متن نظر را وارد کنید',
                        rows: 6,
                    });
                    //archiveSectionOptions.textComment.setRTL(true);
                    fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.sameIndent, {
                        label: 'پاسخ به نفر قبلی (یک دندانه متن جلوتر برود)',
                        align: 'inline',
                    }));
                    fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.radioCommentType, {
                        label: 'برچسب قبل از نظر',
                        align: 'top'
                    }));
                    fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.editButton));
                    fieldset.push(new OO.ui.FieldLayout(archiveSectionOptions.textComment, {
                        label: 'متن نظر:',
                        align: 'top'
                    }));
                    this.content.addItems(fieldset);
                    this.panel.$element.append(this.content.$element);
                    this.$body.append(this.panel.$element);
                };
                CommentInSection.prototype.getActionProcess = function(action) {
                    var dialog = this;
                    if (action === 'comment') {
                        archiveSectionOptions.doEdit(archiveSectionOptions.currentSectionId, action);
                    }
                    return CommentInSection.super.prototype.getActionProcess.call(this, action);
                };
                if (!windowManager) {
                    windowManager = new OO.ui.WindowManager();
                    $('body').append(windowManager.$element);
                }
                if (!commentInSection) {
                    commentInSection = new CommentInSection({
                        size: 'medium'
                    });
                    windowManager.addWindows([commentInSection]);
                }
                windowManager.openWindow(commentInSection);
            });
        },
        getQuery: function(section) {
            var query = new mw.Uri(section).query;
            return query;
        },
        setIndentation: function(text, newText) {
            text = text.replace(/\r/g, '')
            var lines = text.split('\n');
            var lastline = lines[lines.length - 1];
            var colons = lastline.match('^([\#\*]?)(\:*)')
            var colonNum = colons[2].length;
            var colonType = colons[1];
            if (!archiveSectionOptions.sameIndent.getValue()) {
                colonNum = colonNum - 1
            }
            var indentation = '';
            for (var i = 0; i < colonNum + 1; i++) {
                indentation += ':';
            }
            text = text + '\n' + colonType + indentation + newText.trim().replace(/\n/ig, '\n' + colonType + indentation).trim();
            return text
        },
        doEdit: function(sectionId, action) {
            (new mw.Api()).get({
                format: 'json',
                action: 'query',
                titles: mw.config.get("wgPageName"),
                rvsection: sectionId,
                prop: 'revisions',
                rvprop: 'content',
            }).then(function(data) {
                var page = data.query.pages[Object.keys(data.query.pages)[0]];
                var current = page.revisions[0]['*'];
                var header = current.substr(0, current.indexOf('\n'));
                var content = current.substr(current.indexOf('\n') + 1);
                var newText = '';
                var pingtxt = '';
                var section_title = (current.match(/^(=+)[^=]*?(\1)$/m) || [''])[0];
                section_title = section_title.replace(/\=/g, '');
                var editSummary = '/' + '*' + section_title + '*' + '/ ';
                if (action == 'archive') {
                    editSummary += 'جمع‌بندی: ';
                    editSummary += archiveSectionOptions.textSummary.getValue();
                    newText = header + '\n';
                    // Per Special:Diff/18468612
                    if (mw.config.get("wgPageName") == "ویکی‌پدیا:درخواست_انتقال") {
                        if (archiveSectionOptions.switchSuccess.getValue()) {
                            content = content.replace(/\{\{وضعیت\|?\}\}/, '{{وضعیت|شد}}');
                        } else {
                            content = content.replace(/\{\{وضعیت\|?\}\}/, '{{وضعیت|نشد}}');
                        }
                    }
                    newText += '{{بسته';
                    if (archiveSectionOptions.switchSuccess.getValue()) {
                        newText += '}}\n';
                    } else {
                        newText += '|ناموفق=بله}}\n';
                    }
                    var summaryText = '';
                    if (archiveSectionOptions.textSummary.getValue()) {
                        if (archiveSectionOptions.switchBold.getValue()) {
                            summaryText += "'''";
                        }
                        summaryText += archiveSectionOptions.textSummary.getValue();
                        if (archiveSectionOptions.switchBold.getValue()) {
                            summaryText += "'''";
                        }
                        summaryText += ' ~~' + '~~\n';
                    }
                    if (archiveSectionOptions.switchTop.getValue()) {
                        if (archiveSectionOptions.textSummary.getValue()) {
                            newText += ':' + summaryText;
                        }
                        newText += content;
                        if (newText.indexOf('{{بسته') > -1) newText += '\n{{پایان بسته}}';
                    } else {
                        if (archiveSectionOptions.textSummary.getValue()) {
                            newText = archiveSectionOptions.setIndentation(newText + content, summaryText);
                        } else {
                            newText = newText + content;
                        }
                        if (newText.indexOf('{{بسته') > -1) newText += '\n{{پایان بسته}}';
                    }
                    return (new mw.Api()).post({
                        format: 'json',
                        action: 'edit',
                        title: mw.config.get("wgPageName"),
                        section: sectionId,
                        summary: editSummary,
                        text: newText,
                        token: mw.user.tokens.get('editToken')
                    });
                } else {
                    var currentTxt = current.replace('\r', '')
                    var prefix = '';
                    if (currentTxt.search('\n*') > 0) {
                        prefix = '* ';
                    } else if (currentTxt.search('\n#') > 0) {
                        prefix = '# ';
                    } else {
                        prefix = '* ';
                    }
                    if (archiveSectionOptions.MultiselectPingUser.getValue()) {
                        var userlist = archiveSectionOptions.MultiselectPingUser.getValue()
                        var Pingtxt = '{{پینگ|' + archiveSectionOptions.MultiselectPingUser.getValue() + '}}'
                        Pingtxt = Pingtxt.replace(/\,/g, '|')
                        var userTalkPage = mw.config.get("wgTitle")
                        Pingtxt = Pingtxt.replace('|' + userTalkPage + '}}', '|}}').replace('|' + userTalkPage + '|', '|')
                        var PingtxteditSummary = ' + پاسخ به کاربر:' + Pingtxt.replace('{{پینگ|', '').replace('}}', '').trim().replace(/\|/g, '، ')
                    } else {
                        var Pingtxt = ''
                    }
                    if (Pingtxt == '{{پینگ|}}') {
                        Pingtxt = ''
                        PingtxteditSummary = ''
                    }
                    if (archiveSectionOptions.radioDone.isSelected()) {
                        newText = Pingtxt + '{{شد}} ';
                        editSummary += 'انجام شد' + PingtxteditSummary;
                    } else if (archiveSectionOptions.radioComment.isSelected()) {
                        newText = Pingtxt + '';
                        editSummary += 'پیام' + PingtxteditSummary;
                    } else if (archiveSectionOptions.radioReject.isSelected()) {
                        newText = Pingtxt + '{{نشد}} ';
                        editSummary += 'انجام نشد' + PingtxteditSummary;
                    } else if (archiveSectionOptions.radioKeep.isSelected()) {
                        newText = prefix + Pingtxt + ' {{بماند}} ';
                        editSummary += 'ثبت نظر بماند' + PingtxteditSummary;
                    } else if (archiveSectionOptions.radioDelete.isSelected()) {
                        newText = prefix + Pingtxt + ' {{حذف}} ';
                        editSummary += 'ثبت نظر حذف شود' + PingtxteditSummary;
                    } else if (archiveSectionOptions.radioSupport.isSelected()) {
                        newText = prefix + Pingtxt + ' {{موافق}} ';
                        editSummary += 'ثبت نظر موافق' + PingtxteditSummary;
                    } else {
                        newText = prefix + Pingtxt + ' {{مخالف}} ';
                        editSummary += 'ثبت نظر مخالف' + PingtxteditSummary;
                    }
                    newText += archiveSectionOptions.textComment.getValue();
                    newText += ' ~~' + '~~';
                    if (archiveSectionOptions.radioSupport.isSelected() ||
                        archiveSectionOptions.radioOppose.isSelected() ||
                        archiveSectionOptions.radioDelete.isSelected() ||
                        archiveSectionOptions.radioKeep.isSelected()) {
                        newText = current + '\n' + newText;
                    } else {
                        newText = archiveSectionOptions.setIndentation(current, newText);
                    }

                    return (new mw.Api()).post({
                        format: 'json',
                        action: 'edit',
                        title: mw.config.get("wgPageName"),
                        section: sectionId,
                        summary: editSummary,
                        text: newText,
                        token: mw.user.tokens.get('editToken')
                    });
                }
            }).then(function() {
                if (action == 'archive') {
                    mw.notify('در حال ثبت جمع‌بندی شما ...');
                } else {
                    mw.notify('در حال ثبت نظر شما ...');
                }
                if (sectionId == 0) {
                    sectionId = 1
                }
                location.hash = $('.mw-headline')[sectionId - 1].id;
                location.reload(true);
            }, function(error) {
                mw.notify('ثبت نظر یا جمع‌بندی ناموفق بود: ' + error, {
                    type: 'error'
                });
            })
        },
        currentSectionId: -1,
    };
    if (mw.config.get('wgNamespaceNumber') >= 0) {
        $(archiveSectionOptions.install);
    }
})(jQuery, mediaWiki);