انتقل إلى المحتوى

مستخدم:Nehaoua/common.js

من ويكي مصدر، المكتبة الحرة

ملاحظة: بعد النشر، أنت قد تحتاج إلى إفراغ الكاش الخاص بمتصفحك لرؤية التغييرات.

  • فايرفوكس / سافاري: أمسك Shift أثناء ضغط Reload، أو اضغط على إما Ctrl-F5 أو Ctrl-R (⌘-R على ماك)
  • جوجل كروم: اضغط Ctrl-Shift-R (⌘-Shift-R على ماك)
  • إنترنت إكسبلورر/إيدج: أمسك Ctrl أثناء ضغط Refresh، أو اضغط Ctrl-F5
  • أوبرا: اضغط Ctrl-F5.
mw.loader.load('//www.wikidata.org/w/index.php?title=User:Tpt/interproject.js&action=raw&ctype=text/javascript');
 
mw.loader.load('//en.wikisource.org/w/index.php?title=User:Inductiveload/Running header.js&action=raw&ctype=text/javascript');

//mw.loader.load('//en.wikisource.org/w/index.php?title=User:Inductiveload/ColourBackground.js&action=raw&ctype=text/javascript');

mw.loader.load('//en.wikisource.org/w/index.php?title=User:Inductiveload/Visibility.js&action=raw&ctype=text/javascript');

//mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');

//mw.loader.load('//wikisource.org/w/index.php?title=User:Alex brollo/common.js&action=raw&ctype=text/javascript');

// [[File:Krinkle_WhatLeavesHere.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Tools/WhatLeavesHere.js&action=raw&ctype=text/javascript');

// [[File:Krinkle_OneClickCommoniser.js]]
importScript("MediaWiki:OneClickCommoniser.js");

//mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-GlobalUsageUI.js&action=raw&ctype=text/javascript');

//mw.loader.load('//it.wikisource.org/w/index.php?title=User:Alex brollo/livePreview.js&action=raw&ctype=text/javascript');

//mw.loader.load('//bn.wikisource.org/w/index.php?title=User:Bodhisattwa/common.js/typoscan.js&action=raw&ctype=text/javascript');

//mw.loader.load('//en.wikisource.org/w/index.php?title=User:Ineuw/common.js/Gadget-NopInserter.js&action=raw&ctype=text/javascript');

//without text (script enables clear and save of Page: ns pages)
mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:Gadget-Without text.js&action=raw&ctype=text/javascript');

// this loads the WIP eis.js (Edit In Sequence), only running in edit mode
//mw.loader.load('//it.wikisource.org/w/index.php?title=User:Alex brollo/eis.js&action=raw&ctype=text/javascript');

importScript("MediaWiki:Wikisource.citeBox.js");

mw.loader.load('//en.wikisource.org/w/index.php?title=User:User:Alex brollo/t.js&action=raw&ctype=text/javascript');

mw.loader.load('//en.wikisource.org/w/index.php?title=User:User:Alex brollo/IDB.js&action=raw&ctype=text/javascript');

// mw.loader.load('//commons.wikimedia.org/wiki/MediaWiki:Gadget-AjaxQuickDelete.js&action=raw&ctype=text/javascript');

// mw.loader.load('//commons.wikimedia.org/wiki/User:Perhelion/massrename.js&action=raw&ctype=text/javascript');

//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Splarka/ajaxfilemove.js&action=raw&ctype=text/javascript');

//mw.loader.load('https://wikisource.org/w/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');

// mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Indic-TechCom/Script/MoveAndReplace.js&action=raw&ctype=text/javascript');

// Remove "Auteur:" prefix in category, see https://fr.wikisource.org/wiki/Cat%C3%A9gorie:Philosophes
$(function () {
   if (mw.config.get('wgNamespaceNumber') == 14) {
       $("li a[href^='/wiki/Author:']").each(function () {
           $(this).text($(this).text().substr("Author:".length));
       });
   }
});

//mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Urvaxhi/speechToText.js&action=raw&ctype=text/javascript');

//mw.loader.load('//bn.wikisource.org/w/index.php?title=MediaWiki:Gadget-dictionaryLookupHover.js&action=raw&ctype=text/javascript');

mw.util.addPortletLink("p-tb", "//listeria.toolforge.org/index.php?action=update&project=wikisource&lang=bn&page="+mw.config.get('wgPageName'), "লিস্টেরিয়া হালনাগাদ", "p-listeriaupdate", "লিস্টেরিয়া তালিকা হালনাগাদ করুন, যদি এই পাতায় তালিকা থাকে");

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Daduxing/familytree.js&action=raw&ctype=text/javascript');

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');

mw.loader.load('//ar.wikisource.org/w/index.php?title=User:Nehaoua/annotator.js&action=raw&ctype=text/javascript');

mw.loader.load('//bn.wikipedia.org/w/index.php?title=ব্যবহারকারী:আফতাবুজ্জামান/পুনঃনামকরণ২.js&action=raw&ctype=text/javascript');






//
importScript('User:Ciphers/Gadget-TemplatePreloader.js');
//
importScript("user:Nehaoua/cat-a-lot.js");
//<nowiki>
//catALot///////////////////////////////////////
mw.loader.using(['jquery.ui.resizable', 'mediawiki.util'], function(){
	mw.loader.load('//commons.wikimedia.org/w/load.php?modules=ext.gadget.Cat-a-lot');
});
////////// Cat-A-Lot user preferences //////////
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":true,"docleanup":false,"subcatcount":10};
////////////////////////////////////catALotEnd//
//</nowiki>
importScript('مستخدم:Mr. Ibrahem/wikEd.js');
// تنسيق النصوص
/*
 * Transformation varié du wikicode d'une page, incluant : 
 *
 * Recherche deux pages avant la page courante pour en extraire un modèle nr
 * et l'insère dans la page courante après avoir incrémenté le numéro de page.
 * De même pour un modèle tiret depuis la page précédente.
 *
 * Typographie (pas implémenté)
 *
 *
 * Le gadget fonctionne en trois niveau : 1) automatiquement lors de la création
 * d'une page 2) automatiquement lors de l'édition d'une page 3) sur l'appui
 * d'un bouton par l'utilisateur.
 *
 * Questions :
 *
 * Le bouton rh doit-il apparaître dans les autres espaces de noms que Page ?
 *
 * Voir la variable no_mise_en_page, c'est assez maladroit comme façon de faire,
 * plusieurs problèmes à résoudre :
 * Un gadget peut avoir besoin d'inhiber complètement ce gadget et s'en
 * servir comme librairie.
 * Un gadget peut avoir besoin de faire une requête api et la requête dans ce
 * gadget est redondante et doit pouvoir être éviter.
 * Un gadget ou script utilisateur peut vouloir étendre ce gadget, en particulier
 * pour la typographie.
 *
 *
 * À faire :
 *
 * Typographie.
 *
 * application d'un dico définit par l'utilisateur mais seulement en level = "on_button"
 *
 *
 * Bugs  :
 *
 * See also the FIXME comment(s) for caveats.
 *
 */

// Some code here come from left and right, mainly [[User:InductiveLoad]]

// From http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter
var roman_converter = {

    to_roman : function (num) {
	if (!+num)
		return false;
	var	digits = String(+num).split(""),
		key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
		       "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
		       "","I","II","III","IV","V","VI","VII","VIII","IX"],
		roman = "",
		i = 3;
	while (i--)
		roman = (key[+digits.pop() + (i * 10)] || "") + roman;
	return Array(+digits.join("") + 1).join("M") + roman;
    },

    to_int : function (s) {
	var	str = s.toUpperCase(),
		validator = /^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/,
		token = /[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,
		key = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},
		num = 0, m;
	if (!(str && validator.test(str)))
		return false;
	while ((m = token.exec(str)))
		num += key[m[0]];
	return num;
    }
};


function levenshtein(s1, s2, case_sensitive) {
    if (s1.length < s2.length)
        return levenshtein(s2, s1);
    if (!s1)
        return s2.length;

    if (!case_sensitive) {
        s1 = s1.toLowerCase();
        s2 = s2.toLowerCase();
    }
 
    previous_row = [];
    for (var i = 0; i < s2.length+1; ++i)
        previous_row.push(i);
    for (var i = 0; i < s1.length; ++i) {
        current_row = [];
        current_row.push(i + 1);
        for (var j = 0; j < s2.length; ++j) {
            var insert = previous_row[j + 1] + 1;
            var del = current_row[j] + 1;
            var subst = previous_row[j] + (s1[i] != s2[j]);
            current_row.push(Math.min(insert, del, subst));
        }
        previous_row = current_row;
    }

    return previous_row.slice(-1)[0];
}

mise_en_page = {
    level : '',
    increment_arabic : function (rh){
        try {
            // Avoid to incr 100%, likely to be css style.
            var r = new RegExp("(\\d+)(?![%\\d])");
            var page = Number(r.exec(rh)[1]) + 2;

            return rh.replace(/\d+(?![%\d])/, page.toString());
        } catch(err) {
            return '';
        }
    },

    increment_roman : function (rh) {
        try {
            var r = new RegExp("^(.*?)([ivxlcm]+|[IVXLCM]+)(?![a-zA-ZéèàÉÈÀ])(.*?)$");

            var regex_res = r.exec(rh);

            var numeral = regex_res[2];

            var lower_case = numeral.toUpperCase() != numeral;

            var number = roman_converter.to_int(numeral) + 2;

            numeral = roman_converter.to_roman(number);
            if (lower_case)
                numeral = numeral.toLowerCase();

            return regex_res[1] + numeral + regex_res[3];
        }
        catch(err) { 
            return '';
        }
    },

    has_rh : function () {
        var header = document.getElementsByName('wpHeaderTextbox')[0];
        return !header || header.value.search(/{{([Nn]r|[Nn]umérotation) *\|[^\n]*}}/) != -1;
    },

    has_tiret : function () {
        var textbox = document.getElementById("wpTextbox1");
        return !textbox || textbox.value.search(/{{([Tt])iret2 *(\|[^}]*)}}/) != -1;
    },

    has_nowiki : function () {
        var textbox = document.getElementById("wpTextbox1");
        return !textbox || textbox.value.search(/<nowiki *\/>/) != -1;
    },

    has_manchette : function () {
        var textbox = document.getElementsByName('wpHeaderTextbox')[0];
        return !textbox || textbox.value.search(/{{[Mm]anchette *(\|[^}]*)*}}/) != -1;
    },

    set_manchette : function (content) {
        var header = document.getElementsByName('wpHeaderTextbox')[0];
        if (!header || mise_en_page.has_manchette())
            return;
        var r = new RegExp(/{{([Mm]anchette) *(\|[^}]*)*}}/);
        var match = r.exec(content);
        if (match)
            header.value += match[0]; 
    },

    set_rh : function (content) {
        var header = document.getElementsByName('wpHeaderTextbox')[0];
        if (!header || mise_en_page.has_rh())
            return;
        var result = mise_en_page.split_content(content);
        if (!result || !result.header) {
            return;
        }
        var r = new RegExp(/({{([Nn]r|[Nn]umérotation) *\|)([^\n]*)}}/);
        var match = r.exec(result.header);
        if (match) {
            // match[3] == xxx(\|yyy)*, choose the field to incr, it's likely the one that can be incr
            // and which is the shortest.
            var params = match[3].split('|');
            var i;
            var last_found = -1;
            for (i = 0; i < params.length; ++i) {
                if (!params[i].length)
                    continue;
                var found = mise_en_page.increment_arabic(params[i]);
                    
                if (found === '') {
                    found = mise_en_page.increment_roman(params[i]);
                }

                if (found !== '') {
                    if (last_found == -1 || params[i].length < params[last_found].length) {
                        last_found = i;
                    }
                }
            }

            if (last_found != -1) {
                found = mise_en_page.increment_arabic(params[last_found]);
                    
                if (found === '')
                    found = mise_en_page.increment_roman(params[last_found]);

                if (found !== '')
                    params[last_found] = found;
            }
            header.value += match[1] + params.join("|") + '}}';
        }

        var textbox = document.getElementById("wpTextbox1");
        match = header.value.match(/{{([Nn]r|[Nn]umérotation) *\|([^\n]*)}}/);
        if (match && textbox) {
            var search = match[2].replace(/\|/g, " ").replace(/^ *| *$/, "");
            var lines = textbox.value.split("\n");
            if (lines.length) {
                var dist = levenshtein(search, lines[0], false);
                var nr_line = 1;
                var tot_length = lines[0].length;
                for (var i = 1; i < lines.length; ++i) {
                    if (lines[i].length) {
                        var dist1 = levenshtein(search, lines[0] + " " + lines[i], false);
                        if (dist1 <= dist) {
                            dist = dist1;
                            nr_line = i + 1;
                            tot_length += lines[i].length;
                        }
                        break;
                    }
                }

                if (dist < 15 && dist < tot_length * 0.70) {
                    lines = lines.slice(nr_line);
                    while (lines.length && !lines[0].length) {
                        lines.shift();
                    }
                    textbox.value = lines.join("\n");
                }
            }
        }
    },

    set_tiret : function (previous_page_content) {
        var wpTextbox1 = document.getElementById("wpTextbox1");
        if (wpTextbox1 && !mise_en_page.has_tiret()) {
            var tiret = new RegExp(/{{([Tt])iret *\|(.*?)\|(.*?)}}/);
            var match = tiret.exec(previous_page_content);
            if (match) {
                 /* {{tiret|dit|-il}} --> {{tiret2|dit-|il}}  et {{tiret|''aban|don''}} --> {{tiret2|aban|don}} */
                 var part1 = match[2].replace(/''(.*)''/, "$1");
                 part1 = part1.replace(/''(.*)/, "$1");
                 part1 = part1.replace(/(.*)''/, "$1");
                 var part2 = match[3];
                 part2 = part2.replace(/''(.*)/, "$1");
                 part2 = part2.replace(/(.*)''/, "$1");
                 var has_italic = false;
                 if (part1 != match[2] || part2 != match[3])
                     has_italic = true;
                 if (part2[0] == '-') {
                     part2 = part2.slice(1);
                     part1 += '-';
                 }

                 var text = wpTextbox1.value;

                 var section = text.match(/^##[^#]*##\n(<nowiki[ ]*\/>\n\n)?/);
                 if (!section) {
                     section = [ "" ];
                     text = text.replace(/^<nowiki[ ]*\/>\n\n*(.*)/, "$1");
                 }

                 text = text.slice(section[0].length);

                 var offset = text.indexOf(part2);
                 if (offset != -1 && offset < 16)
                     text = text.slice(offset + part2.length);

                 var tiret2 = match[0].replace(tiret, "{" + "{$1iret2|" + part1 + "|" + part2 + "}}");
                 if (text.search(/[a-zA-Zçéèà]/) == 0)
                     text = " " + text;

                 if (has_italic)
                     tiret2 = "''" + tiret2;

                 wpTextbox1.value = section[0] + tiret2 + text;
            }
        }
    },

    split_content : function (content) {
        var result = {}
        var re = /^<noinclude>([\s\S]*?)\n*<\/noinclude>([\s\S]*)<noinclude>([\s\S]*?)<\/noinclude>\n*$/;
        m = content.match(re);
        if (m) {
            result['header'] = m[1];
            result['body']   = m[2];
            result['footer'] = m[3];
        } else {
            var re2 = /^<noinclude>([\s\S]*?)\n*<\/noinclude>([\s\S]*?)\n$/;
            var m2 = content.match(re2);
            if (m2) {
                result['header'] = m2[1];
                // IE & Opera mis-implement non greedy match
                var re3 = /^([\s\S]*)<noinclude>([\s\S]*)<\/noinclude>\s*$/;
                var m3 = m2[2].match( re3 );
                if (m3) {
                    result['body']   = m3[1];
                    result['footer'] = m3[2];
                } else {
                    result['body']   = m2[2];
                    result['footer'] = '';
                }
            }
        }
        return result;
    },

    set_nowiki : function (previous_page_content) {
        /* FIXME: ne devrait pas être fait si le nowiki est caché par une autre gadget */
        if (mise_en_page.has_tiret())
            return;

        var wpTextbox1 = document.getElementById("wpTextbox1");
        if (!wpTextbox1 || mise_en_page.has_nowiki())
            return;

        /* First check if the text start with a <br />, if yes replace it by a nowiki and return */
        var content =  wpTextbox1.value;
        var section = content.match(/^##[^#]*##\n/);
        if (!section)
            section = [ "" ];
        content = content.slice(section[0].length);
        if (content.search(/^<br *\/>/) == 0) {
            content = section[0] + content.replace(/^<br *\/>/, "<nowiki/>");
            wpTextbox1.value = content;
            return;
        }

        // FIXME: do we need all of this or only rely on the previous page content finishing by a [.?!»] ?
        previous_page_content = mise_en_page.split_content(previous_page_content)['body'];
        previous_page_content = previous_page_content.replace(/<ref>(.|\n)*?<\/ref>/gm, '');
        var lines = previous_page_content.split('\n');
        /* bug du '\n' https://bugzilla.wikimedia.org/show_bug.cgi?id=26028 */
        while (lines.length && lines[lines.length - 1].length == 0) {
            lines.pop();
        }
        var count_empty = 0;
        for (var idx in lines) {
            if (!lines[idx].length)
                count_empty += 1;
        }

        content = wpTextbox1.value.replace(/\s*(.)/, "$1");
        var match = previous_page_content.match(/([.!?»]<section end="[^"]*"\/>|[.!?»])$/);
        var avg_length = previous_page_content.length / (lines.length - count_empty);
        var last_length = lines[lines.length - 1].length;
        if (avg_length > 30 && avg_length < 100 && last_length < avg_length * 0.60) {
            if (content.length)
                wpTextbox1.value = '<nowiki />\n\n' + content;
        } else if (match) {
            if (content.length)
                wpTextbox1.value = '<nowiki />\n\n' + content;
        }
    },

    split_paragraph : function (text) {
        var lines = text.split("\n");
        var avg_length = text.length / lines.length;
        if (avg_length > 40) {
            var result = [];
            for (idx in lines) {
                if (lines[idx].indexOf('— ') == 0)
                    result[result.length] = "";
                result[result.length] = lines[idx];
                if (lines[idx] && lines[idx].length < avg_length * 0.75)
                    result[result.length] = "";
            }
            text = result.join("\n");
            // in case paragraph mark already exists.
            text = text.replace(/\n\n\n\n/g, "\n\n");
            text = text.replace(/\n\n\n/g, "\n\n");
        }
        // Perhaps a better place to strip blank line at start/end ?
        text = text.replace(/^\n*/, "");
        text = text.replace(/\s*$/, "");

        return text;
    },

    handle_paragraph : function() {
        var textbox = document.getElementById("wpTextbox1");
        if (textbox)
            textbox.value = mise_en_page.split_paragraph(textbox.value);
    },

    pagename : null,
    previous_page : null,

    get_data : function (data, pagename) {
        for (var ids in data.query.pages) {
            if (ids > 0 && data.query.pages[ids].title == pagename) {
                return data.query.pages[ids];
            }
        }
        return null;
    },

    // FIXME: we need to allow end user to specify if he wants section propagation
    // for a given book but that need to refactorize the whole code and to ensure
    // its /common.js is loaded before this script. Alternative is to add bookname
    // prefix in need_section_prefix array.
    need_section : function (pagename) {
	var need_section_prefix = [
		'Rozier - Cours d’agriculture,', 
		'Chénier - Poésies choisies, ed. Derocquigny, 1907.djvu',
		'Chénier - Œuvres poétiques, édition Moland, 1889',
		];
	for (var i = 0; i < need_section_prefix.length; ++i) {
		if (pagename.indexOf(need_section_prefix[i]) === 0)
			return true;
	}
	return false;
    },

    // try to propage section, handling in a special way an existing section called ## début ##
    last_match : function (regex, text) {
        var last_match = null;
        var match;
        while (match = regex.exec(text))
           last_match = match;
        return last_match;
    },

    propagate_section : function (previous_page_content) {
         if (!mise_en_page.need_section(mw.config.get("wgTitle")))
             return;
         var r = new RegExp("<section end=\"(.*?)\"", "g");
         var match = mise_en_page.last_match(r, previous_page_content);
         if (match) {
             var textbox = document.getElementById("wpTextbox1");
             // FIXME: Michaud must be handled differently, see Utilisateur:Phe/Michaud.js
             textbox.value = '## ' + match[1] + ' ##\n' + textbox.value;
         }
    },

    fill_rh : function (data) {
        var api_page = mise_en_page.get_data(data, mise_en_page.pagename);
        if (api_page) {
            var content = api_page.revisions[0]['*'];
            mise_en_page.set_rh(content);
            mise_en_page.set_manchette(content);
        }
        api_page = mise_en_page.get_data(data, mise_en_page.previous_page);
        if (api_page) {
            var content = api_page.revisions[0]['*'];
            mise_en_page.set_tiret(content);
            mise_en_page.set_nowiki(content);
            if (mise_en_page.level == 'auto_create') {
                mise_en_page.propagate_section(content);
		// FIXME: should we propagate <poem> here, but
		// where to place the </poem>?
	    }
        }
    },

    rh_and_tiret : function () {
        if (!mise_en_page.has_rh() || !mise_en_page.has_tiret() || !mise_en_page.has_nowiki()) {
            var r = new RegExp("(\\d+)$");
            var page = Number(r.exec(mw.config.get('wgPageName'))[1]);

            mise_en_page.pagename = 'Page:' + mw.config.get('wgTitle').replace(/\d+$/g, page - 2);
            mise_en_page.previous_page = 'Page:' + mw.config.get('wgTitle').replace(/\d+$/g, page - 1);

	    $.ajax({
		url: mw.config.get('wgServer') + mw.util.wikiScript( 'api' ),
		dataType: 'json',
		data: {
			'format': 'json',
			'action': 'query',
			'titles': mise_en_page.pagename + '|' + mise_en_page.previous_page,
			'prop': 'revisions',
			'rvprop': 'content',
		},
		success: mise_en_page.fill_rh
	    });
        }
    },

    /*
     * Typographie : même lorsque l'on travaille en mode création de page
     * il n'est pas sur de changer aveuglément tout le texte, d'où le
     * le split du texte en fragment où les regexps sont appliqués
     */
    typographie_fragment : function(text, typo_def) {
        var lng = typo_def.length;
        if (lng % 2 != 0)
            return text;  /* FIXME, il faut lever une exception ici ? */
        for (var i = 0; i < lng; i += 2) {
            search = new RegExp(typo_def[i + 0], "g");
            text = text.replace(search, typo_def[i + 1]);
        }
        return text;
    },

    typographie : function (text, typo_def) {
        var new_text = '';
        var last_match = 0;
        // Split the text in part which are safe to transform, e.g we don't want
        // to apply typographie_fragment on a <math>.*</math> or a &nbsp; etc.
        var splitter = new RegExp("<math>.*</math>|<[a-zA-z0-9 =\"']>|[</[a-zA-z0-9 =\"']+>|style=\".*\"|&nbsp;|&mdash;|<!--.*-->|\n:[:]*|\n;[;]*|[[][[].*]]", "gm");
        while ((result = splitter.exec(text)) != null) {
            new_text += mise_en_page.typographie_fragment(text.slice(last_match, splitter.lastIndex - result[0].length), typo_def);
            new_text += result;
            last_match = splitter.lastIndex;
        }
        new_text += mise_en_page.typographie_fragment(text.slice(last_match), typo_def)
        return new_text;
    },

    typographie_textbox : function(pagename_filter, typo_def) {
        if (!pagename_filter.test(mw.config.get("wgPageName")))
            return;

        var wpTextbox1 = document.getElementById("wpTextbox1");
        if (!wpTextbox1)
            return;

        wpTextbox1.value = mise_en_page.typographie(wpTextbox1.value, typo_def);
    },

    get_create_typo : function() {
        var char_min = 'a-zéèàùâêîôûŷäëïöüÿçœæſñ';
        var char_maj = 'A-ZÉÈÀÂÙÊÎÔÛŶÄËÏÖÏŸÇŒÆÑ';
        var char     = char_min + char_maj;
        var bw       = '([^' + char + ']|^)';
        var ew       = '([^' + char + ']|$)';
        var ch       = '[' + char + ']';

        var on_create_typo_def = [
            bw + 'flg\.', '$1fig.',
            bw + '(toi|moi|lui|elle)-môme' + ew, '$1$2-même$3',
            bw + '(nous|vous|elles|eux)-mômes' + ew, '$1$2-mêmes$3',
            'fi', 'fi',
            'fl', 'fl',
            '\s*Digitized by\s*', '',
            '\s*Google\s*', ''
        ];

        return on_create_typo_def;
    },

    line_hyphen_length : function (line) {
	if (line.length >= 8) {
	    if (line.slice(-1) == '-' || line.slice(-1) == '¬')
		return 1;
	    else if (line.slice(-2) == '- ' || line.slice(-2) == '¬ ')
		return 2;
            // this occur for half-broken text layer
	    else if (line.slice(-3) == '-  ' || line.slice(-3) == '¬  ')
		return 3;
	}
	return 0;
    },

    next_word_length : function (next_line) {
	var regexp = new RegExp("^([«»]*[ ]*)['’a-zéèàùâêîôûŷäëïöüÿçœæſñãåóA-ZÉÈÀÂÙÊÎÔÛŶÄËÏÖÏŸÇŒÆÑ-]+( : | :|:|, |,| , | ,| ; | ;|; |;| !|!| \\?|\\?|\\. |\\.| |\\)\\. |\\), )?");
	var result = regexp.exec(next_line);
        if (result && regexp.lastIndex == 0)
            return result[0].length;
	return -1;
    },

    last_word_length : function (cur_line) {
	var regexp = new RegExp("['’a-zéèàùâêîôûŷäëïöüÿçœæſñãåóA-ZÉÈÀÂÙÊÎÔÛŶÄËÏÖÏŸÇŒÆÑ-]+$");
	var result = regexp.exec(cur_line);
	if (result)
	    return cur_line.length - result[0].length;
	return -1;
    },

    validate_hyphen : function (last_word, next_word) {
        var blacklist_first_last = {
            "au" : [ "dessus", "dessous", "devant" ],
            "celui" : [ "ci", "là" ],
            "basse" : [ "cour" ],
            "beau" : [ "frère", "père" ],
            "beaux" : [ "arts", "frères" ],
            "ci" : [ "dessus", "dessous", "devant" ],
            "disent" : [ "ils", "elles" ],
            "dit" : [ "celui", "celle", "ceux", "celles", "il", "elle" ],
            "en" : [ "sorte" ],
            "grand" : [ "duc", "père", "mère", "oncle" ],
            "non" : [ "seulement" ],
            "petit" : [ "fils", "neveu" ],
            "peut" : [ "être" ],
            "quelques" : [ "uns", "unes" ],
            "rendez" : [ "vous" ],
            "sur" : [ "le-champ" ],
            "sur-le" : [ "champ" ],
            "toute" : [ "puissance" ],
        };
        var blacklist_last_first = {
            "même" : [ "toi", "moi", "lui", "elle", "qu‘elle", "qu'elle" ],
            "dire" : [ "c’est-à", "c'est-à" ],
            "à-dire" : [ "c’est", "c'est" ],
            "mêmes" : [ "eux", "elles", "qu’eux", "qu'eux", "qu’elles", "qu'elles", "nous", "vous" ],
        };
        var blacklist_first = {
            "très" : true,
            "arrière" : true,
        };
        var blacklist_last = {
            "un"    : true, "deux"  : true, "trois" : true, "quatre" : true,
            "cinq"  : true, "six"   : true, "sept"  : true, "huit"   : true,
            "neuf"  : true, "dix"   : true, "onze"  : true, "douze"  : true,
            "treize": true, "quatorze" : true, "quinze" : true, "seize" : true, "vingt" : true,
            "nous"  : true, "vous"  : true, "il"    : true,  "ils"   : true,
            "elle"  : true, "elles" : true, "tu"    : true,
            "on"    : true, "y"     : true,
        };

        next_word = next_word.replace(/( : | :|:|, |,| , | ,| ; | ;|; |;| !|!| \?|\?|\. |\.| |\)\. |\), )$/, "");
        next_word = next_word.replace(/ *$/, "");

        if (next_word[0].toUpperCase() == next_word[0])
            return false;

        if (blacklist_first[last_word])
            return false;

        if (blacklist_last[next_word])
            return false;

        if (blacklist_first_last[last_word] && $.inArray(next_word, blacklist_first_last[last_word]) != -1)
            return false;

        if (blacklist_last_first[next_word] && $.inArray(last_word, blacklist_last_first[next_word]) != -1)
            return false;

        return true;
    },

    tweak_next_word : function (next_word) {
        return next_word.replace(/^[«»]*[ ]*(.*)$/, '$1');
    },
   
    remove_hyphen : function (text) {
        var lines = text.split("\n");
        var delete_lines = [];
        if (lines.length > 1) {
            for (var i = 0; i < lines.length - 1; ++i) {
                var cur_line = lines[i];
                var next_line = lines[i + 1];
		var hyphen_length = mise_en_page.line_hyphen_length(cur_line);
		var next_w_length = mise_en_page.next_word_length(next_line);
                if (hyphen_length && next_w_length != -1) {
		    cur_line = cur_line.slice(0, -hyphen_length);
		    var last_w_length = mise_en_page.last_word_length(cur_line);
		    var next_word = next_line.slice(0, next_w_length);
                    next_word = mise_en_page.tweak_next_word(next_word);
		    var last_word = cur_line.slice(last_w_length);
		    if (!mise_en_page.validate_hyphen(last_word, next_word))
                        cur_line += '-';
                    lines[i] = cur_line + next_word;
                    lines[i + 1] = next_line.slice(next_w_length);
                    if (!lines[i+1].length)
                        delete_lines.push(i+1);
		}
            }
            while (delete_lines.length) {
                var idx = delete_lines.pop();
                lines.splice(idx, 1);
            }
	    text = lines.join("\n");
        }
        return text;
    },

    handle_hyphen : function () {
        var textbox = document.getElementById("wpTextbox1");
        if (textbox)
            textbox.value = mise_en_page.remove_hyphen(textbox.value);
    },

    /*
     * level == "auto_create", automatic call on a Page: creation
     * level == "auto_edit", automatic call on a Page: edition excluding case "auto_create"
     * level == "on_button", called on an explicit user action
     */
    exec : function (level) {
        mise_en_page.level = level;
        /* for auto run level, check if we are inhibited by another gadget, this
         * allow for another gadget to take over this one and use it as a library,
         * typically because it wants to do its own api request.
         */
        if (level == "auto_create" && !window.no_mise_en_page) {
            mise_en_page.rh_and_tiret();
            mise_en_page.typographie_textbox(/.*/, mise_en_page.get_create_typo());
            mise_en_page.handle_paragraph();
            mise_en_page.handle_hyphen();
        } else if (level == "auto_edit" && !window.no_mise_en_page) {
            /* no rh and tiret, it's not enough safe in this mode */
        } else if (level == "on_button") {
            mise_en_page.rh_and_tiret();
            mise_en_page.typographie_textbox(/.*/, mise_en_page.get_create_typo());
        } else {
            mw.log("mise_en_page.exec(level) called with an unknown level : " + level);
        }
    },

    editForm : function() {
	window.insert_button.editForm( {
		'img_classic'  : '//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Button_running_header.svg/23px-Button_running_header.svg.png',
		'img_advanced' : '//upload.wikimedia.org/wikipedia/commons/c/c1/LibreOffice_3.4_tango_icon_lc_graphicfiltertoolbox.png',
		'tooltip'      : 'Mise en page',
		'img_id'       : 'wsMiseEnPage',
		'on_click'     : function() { mise_en_page.exec("on_button"); }
	} );
    },
};

$(function () { 
    if (mw.config.get('wgCanonicalNamespace') == 'Page' && $.inArray(mw.config.get("wgAction"), [ "edit", "submit" ]) != -1) {
        if ($('.mw-newarticletext').length) {
            mise_en_page.exec("auto_create");
        } else {
            mise_en_page.exec("auto_edit");
        }
        mw.loader.using( 'user.options' ).done( mise_en_page.editForm );
    }
});
// [[File:Krinkle_RTRC.js]]
(mw.loader.getState('ext.gadget.rtrc') ? mw.loader.load('ext.gadget.rtrc') : mw.loader.load('https://www.mediawiki.org/w/load.php?modules=ext.gadget.rtrc&lang=' + mw.config.get('wgUserLanguage', 'ar')));
/**
 * Add "Purge" content action link.
 *
 * Dependencies: mediawiki.util, mediawiki.api
 *
 * @source https://www.mediawiki.org/wiki/Snippets/Purge_action
 * @revision 2016-05-22
 */
$( function () {
	if ( $( '#ca-purge' ).length || !mw.config.get( 'wgIsArticle' ) ) return;
	var node = mw.util.addPortletLink(
		'p-cactions',
		mw.util.getUrl( null, { action: 'purge' } ),
		mw.config.get( 'skin' ) === 'vector' ? 'محو الاختزان' : '*',
		'ca-purge',
		'محو اختزان الصفحة لإظهار آخر نسخة',
		'*'
	);
	$(node).on( 'click', function (e) {
		new mw.Api().post( { action: 'purge', titles: mw.config.get( 'wgPageName' ) } ).then(function () {
			location.reload();
		}, function () {
			mw.notify( 'فشلت العملية', { type: 'error' } );
		});
		e.preventDefault();
	});
});

// إضافة أزرار ملخصات التعديل
mw.hook('summaryButtons').add(function () {
	addSummaryButton('تنبيه', 'تنبيه', 'group1');
	addSummaryButton('تفخيم', 'إزالة تفخيم', 'group1');
	addSummaryButton('استرجاع', 'استرجاع النسخة المستقرة', 'group1');

	addSummaryButton('توضيح', 'توضيح', 'group2');
	addSummaryButton('زر 5', 'النص البديل 5', 'group2');
addSummaryButton('مراجعة', 'قبول مراجعة المقالة', 'Rev');

});




// [[Wikipedia:Tools/Navigation popups]]
mw.loader.load('https://en.wikipedia.org/w/load.php?modules=ext.gadget.Navigation_popups');

mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Indic-TechCom/Script/IndicOCR.js&action=raw&ctype=text/javascript');

// Organise les liens interwiki selon un certain ordre
// Auteur : Sanao, d'après une idée de Lilyu ; réécriture complète par Arkanosis
 
// Trie les interwiki selon un ordre défini par la variable globale order_lang
$(function() {
 
  var langs = $('#p-lang ul');
  var order = (
    typeof order_lang === 'undefined'
    ? [ 'en', 'de', 'it' ]
    : order_lang
  ).reverse();
 
  $.each(order, function(_, lang) {
    langs.find('li.interwiki-' + lang).prependTo(langs);
  });
 
});


///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Créé un ToDo list (un bouton est ajouté en haut des pages de Wikipédia en français
// Copie de https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/TodoList.js
// 2020-01-05
/*** Todo List ***/

// Adds a todo list that also has a convient popup
// Documentation at [[User:BrandonXLF/TodoList]]
// By [[User:BrandonXLF]]

$.when(mw.loader.using([
	'mediawiki.user',
	'oojs-ui-core',
	'oojs-ui-windows',
	'oojs-ui.styles.icons-movement',
	'oojs-ui.styles.icons-editing-core',
	'oojs-ui.styles.icons-interactions',
	'oojs-ui.styles.icons-moderation',
	'oojs-ui.styles.icons-content'
]),$.ready).then(function(){
	mw.util.addCSS(
		'.userjs-todo-list .item:hover .act { visibility: visible !important; }' + 
		'[data-drop="above"]::before { display: block; border-top: 2px solid #066; margin-top: -2px; content: ""; }' +
		'[data-drop="below"]::after { display: block; border-top: 2px solid #066; margin-top: -2px; content: ""; }' +
		'.userjs-todo-list .items:empty { border: none !important; margin: 0 !important; padding: 0 !important;}' + 
		'.userjs-todo-moreinfo > a { min-width: unset !important; min-height: unset !important; padding: 0.65em !important; }' + 
		'.userjs-todo-moreinfo > a > span { min-width: unset !important; min-height: unset !important; width: 1.3em !important; left: 0 !important; }'
	);
	if (mw.config.get('skin') === 'minerva') {
		mw.util.addCSS(
			'.userjs-todo-list .item .act { visibility: visible !important; }' + 
			'#userjs-todo-popup { top: 0 !important; bottom: 0 !important; left: 0 !important; right: 0 !important; width: 100%; height: 100%; }' + 
			'#userjs-todo-popup .userjs-todo-list { width: 100%; height: 100%; } '
		);
	}
	var api = new mw.Api();
	var link = $(mw.util.addPortletLink('p-personal', mw.util.getUrl('Special:BlankPage/todo'), 'مهامي', 'userjs-todo', 'Click to see your todo list', 'd', '#pt-preferences'));
	var changes = [mw.user.options.get('userjs-todo-script')];
	var undo = 0;
	var req = 0;
	var parent;
	var ispopup = false;
	var loader = $('<input type="file" accept=".json" style="display:none;">').on('change',function(e){
		if (!this.files || !this.files[0]) return;
		var file = this.files[0];
    	var reader = new FileReader();
    	reader.onload = function (e) {
    		save(reader.result, true, true);
    	};
    	reader.readAsText(file);
	}).appendTo(document.body);
	
	$(window).on('beforeunload',function () { if (req > 0) return true; });
	
	function save (what, record, relist) {
		if (typeof what != 'string') { what = JSON.stringify(what); }
		mw.user.options.set('userjs-todo-script', what);
		req++;
		parent.find('.status').text('Saving changes...');
		api.saveOption('userjs-todo-script', what).done(function(){
			req--;
			if (req === 0) {
				parent.find('.status').text('');
			}
		});
		if (record !== false) {
			while (undo > 0) {
				changes.pop();
				undo--;
			}
			changes.push(mw.user.options.get('userjs-todo-script'));
			if (changes.length > 50) changes.shift();
		}
		if (relist) {
			list();
			if (req > 0) {
				parent.find('.status').text('Saving changes...');
			}
		}
	}
	
	Math.clamp = function (max, x, min) {
		return Math.min(max, Math.max(min, x));
	};
	
	function item (parent, array) {
		var date = new Date(+array[2]);
		var url = array[0] || '';
		var txt = array[0] || '';
		if (url.match(/^(https:|http:|:)\/\//) && url.match(/ /)) {
			var reg = /(.*?) (.*)/.exec(url);
			url = reg[1];
			txt = reg[2];
		} else if (!url.match(/^(https:|http:|:)\/\//)) {
			url = mw.util.getUrl(url);
		}
		parent.append($('<div class="item" style="margin:5px 0;white-space:nowrap;"></div>')
			.attr('data-page', array[0] || '')
			.attr('data-info', array[1] || '')
			.attr('data-date', array[2] || '')
			.append((new OO.ui.IconWidget({icon:'draggable',title:'Drag'})).$element
				.css({cursor:'move',height:'1.2em',width:'1.2em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'})
				.on('mousedown',function(){
					$(this).parent().attr('draggable','true');
				})
				.on('mouseup',function(){
					$(this).parent().attr('draggable','false');
				})
			)
			.append('<span><a class="page" href="' + url + '">' + txt + '</a></span>')
			.append(array[0] && array[1] ? ' . . ' : '')
			.append('<span class="info">' + (array[1] || '') + '</span>')
			.append(array[0] || array[1] ? '<span class="act" style="visibility:hidden;"> . . </span>' : '')
			.append((new OO.ui.IconWidget({icon:'trash',title:'احذف',flags:['destructive']})).$element
				.css({cursor:'pointer',visibility:'hidden',height:'1.1em',width:'1.1em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'})
				.addClass('act')
				.click(function(){
					var arr = [];
					$(this).parent().siblings().each(function(i){
						arr.push([$(this).attr('data-page'),$(this).attr('data-info'),$(this).attr('data-date')]);
					});
					$(this).parent().remove();
					save(arr);
				})
			)
			.append((new OO.ui.IconWidget({icon:'edit',title:'عدل',flags:['progressive']})).$element
				.css({cursor:'pointer',visibility:'hidden',height:'1em',width:'1em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'})
				.addClass('act edit')
				.click(function(){
					$(this).css('display','none');
					$('<div style="border:1px solid #a2a9b1;padding:0 4px;margin:0.5em 0;border-radius:4px;"></div>')
						.append((new OO.ui.TextInputWidget({ 
							placeholder: 'Page name or URL',
							value: $(this).parent().attr('data-page')
						})).$element.css({maxWidth:'unset',margin:'4px 0'}))
						.append((new OO.ui.TextInputWidget({ 
							placeholder: 'Comment',
							value: $(this).parent().attr('data-info')
						})).$element.css({maxWidth:'unset',margin:'4px 0'}))
						.append($('<table style="width:100%;border-spacing:0;margin-bottom:0.5em;"></table>').append($('<tr></tr>')
							.append($('<td style="width:50%;padding-right:4px;"></td>').append((new OO.ui.ButtonWidget({ 
									label: 'Save',
									flags: ['progressive']
								}).$element.css('width','100%').children().css('width','100%').parent()).click(function(){
									var editbox = $(this).parent().parent().parent().parent();
									var listitem = editbox.parent();
									listitem.find('.page').text(editbox.find('input[placeholder="Page name or URL"]').val());
									listitem.attr('data-page',editbox.find('input[placeholder="Page name or URL"]').val());
									listitem.find('.info').text(editbox.find('input[placeholder="Comment"]').val());
									if (listitem.find('.info')[0].previousSibling.nodeType != 3 && editbox.find('input[placeholder="Comment"]').val() !== '') {
										listitem.find('.info').before(' . . ');
									} else if (listitem.find('.info')[0].previousSibling.nodeType == 3 && editbox.find('input[placeholder="Comment"]').val() === '') {
										$(listitem.find('.info')[0].previousSibling).remove();
									}
									listitem.attr('data-info',editbox.find('input[placeholder="Comment"]').val());
									var arr = [];
									listitem.parent().children().each(function(i){
										arr.push([$(this).attr('data-page'),$(this).attr('data-info'),$(this).attr('data-date')]);
									});
									save(arr);
									link.find('.redo').remove();
									listitem.find('.edit').css('display','inline-block');
									editbox.remove();
								})
							))
							.append($('<td style="width:50%;padding-left:4px;"></td>').append((new OO.ui.ButtonWidget({ 
									label: 'Cancel',
									flags: ['destructive']
								}).$element.css('width','100%').children().css('width','100%').parent()).click(function(){
									var editbox = $(this).parent().parent().parent().parent();
									var listitem = editbox.parent();
									listitem.find('.edit').css('display','inline-block');
									editbox.remove();
								})
							))
						)).appendTo(this.parentNode);
				})
			)
			.append(array[2] ? (new OO.ui.PopupButtonWidget( {
				icon: 'info',
				framed: false,
				label: 'More information',
				invisibleLabel: true,
				title: 'معلومات أكثر',
				popup: {
					$content: $('<p></p>').text('Added: ' + date.getDate() + ' ' + ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][date.getMonth()] + ', ' + date.getFullYear() + ' at ' + date.getHours() + ':' + ('' + date.getMinutes()).padStart(2,'0')),
					padded: true,
					align: 'forwards'
				}
			})).$element
				.addClass('userjs-todo-moreinfo')
				.css({cursor:'pointer',visibility:'hidden',height:'1.3em',width:'1.3em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'})
				.addClass('act') : ''
			)
			.on('dragover',function(e){
				e.preventDefault();
				e.dataTransfer = e.originalEvent.dataTransfer;
				if (e.offsetY < ($(this).height()/2)) {
					this.setAttribute('data-drop','above');
				} else {
					this.setAttribute('data-drop','below');
				}
			})
			.on('dragleave',function(){
				this.setAttribute('data-drop','');
			})
			.on('drop',function(e){
				e.dataTransfer = e.originalEvent.dataTransfer;
				this.setAttribute('data-drop','');
				var ele = $('[data-dragid="' + e.dataTransfer.getData('text/plain') + '"]')[0];
				if (e.offsetY < ($(this).height()/2)) {
					this.insertAdjacentElement('beforebegin', ele);
				} else {
					this.insertAdjacentElement('afterend', ele);
				}
				var arr = [];
				$(this).parent().children().each(function(i){
					arr.push([$(this).attr('data-page'),$(this).attr('data-info'),$(this).attr('data-date') || '']);
				});
				save(arr);
			})
			.on('dragstart',function(e){
				e.dataTransfer = e.originalEvent.dataTransfer;
				var uid = ('' + Math.random()).replace('.','');
				$(this).attr('data-dragid',uid);
				e.dataTransfer.setData('text/plain',uid);
			})
		);
	}
	function list () {
		$('.userjs-todo-list').remove();
		var todo = parent.append($('<div class="userjs-todo-list" style="overflow:auto;"></div>')
			.append($('<div style="padding:0.5em;" class="todo-menu"></div>')
				.append(new OO.ui.ButtonWidget({
					framed: false,
					icon: 'undo',
					invisibleLabel: true,
					title: 'Undo'
				}).$element.click(function(){
					if (changes[changes.length-undo-2] !== undefined) {
						save(changes[changes.length-undo-2],false,true);
						undo++;
					}
				}))
				.append(new OO.ui.ButtonWidget({
					framed: false,
					icon: 'redo',
					invisibleLabel: true,
					title: 'Redo'
				}).$element.click(function(){
					if (changes[changes.length-undo] !== undefined) {
						save(changes[changes.length-undo],false,true);
						undo--;
					}
				}))
				.append(new OO.ui.ButtonWidget({
					framed: false,
					icon: 'trash',
					invisibleLabel: true,
					title: 'Clear'
				}).$element.click(function(){
					OO.ui.confirm('Are you sure you want to clear your todo list?').done(function(confirmed){
					    if (confirmed) {
					        parent.find('.items').empty();
							save('',true,true);
					    }
					});
				}))
				.append(new OO.ui.ButtonWidget({
					framed: false,
					icon: 'download',
					invisibleLabel: true,
					title: 'Download'
				}).$element.click(function(){
					$($('<a download="todo.json" style="display:none;"></a>').attr('href','data:text/plain;charset=utf-8,' + encodeURIComponent(mw.user.options.get('userjs-todo-script'))).appendTo(document.body)[0].click()).remove();
				}))
				.append(new OO.ui.ButtonWidget({
					framed: false,
					icon: 'upload',
					invisibleLabel: true,
					title: 'Upload'
				}).$element.click(function(){
					loader.click();
				}))
				.append(new OO.ui.ButtonWidget({
					framed: false,
					icon: 'info',
					invisibleLabel: true,
					title: 'Help'
				}).$element.click(function(){
					OO.ui.alert($('<div></div>')
						.append('<h3>Todo List Help</h3>')
						.append('<h4>Adding and editing items</h4>')
						.append($('<ul></ul>')
							.append('<li><b>Page name or URL</b>: A page name or any valid URL.<br><ul><li>Ex: <code>Main Page</code></li><li>Ex: <code>://www.example.com</code></li><li>Ex: <code>https://example.com&nbsp;Example</code></li></ul>')
							.append('<li><b>Comment</b>: An additional comment.</li>')
						)
						.append('<h5>Notes</h5>')
						.append($('<ol style="margin-left:2em!important;"></ol>')
							.append('<li>A valid URL must start with <code>https://</code>, <code>http://</code> or <code>://</code> or else it will be treated as a page name. Page names will by automatically converted to a link to the wiki article with that title.</li>')
							.append('<li>If the URL contains a space, the text after the space will be used as the display text. For example, <code>https://example.com&nbsp;Example</code> will show up as <code>Example</code> since URLs cannot contain spaces. Spaces can be repersented as <code>%20</code>, <code>_</code> or <code>+</code>.</li>')
							.append('<li>Page names cannot be be displayed differently than the page name. If you desire to diplay the name differently, use the URL of the page followed by your desired display text instead.</li>')
							.append('<li>Page name and Comment are optional, but at least one is required.</li>')
						)
						.append('<h4>Managing and deleting items</h4>')
						.append('<h5>Global</h5>')
						.append($('<ul></ul>')
							.append('<li><b>Redo</b> and <b>Undo</b>: Redo and undo changes. You should not expect to be able to undo all changes. Changes including uploading a todo list, deleting an item, reordering items, deleting the todo list, editing an item, redoing a change, and adding an item. Redo will redo the last undone change. Once you reload the editor, all change history is lost.</li>')
							.append('<li><b>Clear</b>: Delete your entire todo list, this should be able to be undone, but don\'t rely on it. Once you reload the editor, this action cannot be undone.</li>')
							.append('<li><b>Download</b>: Download all itmes currently in the todo list as a JSON file. The file can later to uploaded again the replace the current todo list. Do not edit the JSON file unless you understand the risks associated with doing so and you understand the structure of the file.</li>')
							.append('<li><b>Upload</b>: Upload a todo list JSON file. The new list will replace the current list. The operation should be able to be undone. Only upload a file created by the download fiel button, or else you may cause issues with the script, causing it to become non functional.</li>')
						)
						.append('<h5>Item specfic</h5>')
						.append($('<ul></ul>')
							.append($('<li></li>')
								.append((new OO.ui.IconWidget({icon:'draggable'}).$element.css({height:'1.2em',width:'1.2em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'})))
								.append('<b>Drag</b>: <span>Drag to change the position of the item.</span><br>')
							)
							.append($('<li></li>')
								.append((new OO.ui.IconWidget({icon:'trash',flags:['destructive']})).$element.css({height:'1.1em',width:'1.1em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'}))
								.append('<b>Delete</b>: <span>Delete an item.</span><br>')
							)
							.append($('<li></li>')
								.append((new OO.ui.IconWidget({icon:'edit',flags:['progressive']})).$element.css({height:'1em',width:'1em',minWidth:'unset',minHeight:'unset',marginRight:'0.5em'}))
								.append('<b>Edit</b>: <span>Edit an item (page name & comment)</span><br>')
							)
							.append($('<li></li>')
								.append((new OO.ui.IconWidget({icon:'info'})).$element.css({height:'1.3em',width:'1.3em',minWidth:'unset',minHeight:'unset',marginRight:'0.2em'}))
								.append('<b>More information</b>: <span>View more information about an item.</span>')
							)
						)
						.append('<h4>Saving changes</h4>')
						.append('<ul><li>All changes are synced with the API after an action is performed (saving, deleting, dragging etc.).</li><li>When a change is being saved the text "Saving changes..." should appear at the end of the list. Do not leave the page or close the popup until the text dissapears as this may cause changes to not be saved.</li></ul>')
						.append('<h4>About</h4>')
						.append('<div><a href="' + mw.util.getUrl('User:BrandonXLF/TodoList') + '">Todo List</a> (<a href="' + mw.util.getUrl('User:BrandonXLF/TodoList.js') + '">code</a>) by <a href="' + mw.util.getUrl('User:BrandonXLF') + '">User:BrandonXLF</a> (<a href="' + mw.util.getUrl('User talk:BrandonXLF') + '">talk</a>)</div>')
					,{size:'large'});
				}))
			)
			.append($('<div style="padding:0 0.5em 0.5em;"></div>')
				.append((new OO.ui.TextInputWidget({ 
					placeholder: 'Page name or URL',
					value: mw.config.get('wgPageName').replace(/_/g,' ') != 'Special:BlankPage/todo' ? mw.config.get('wgPageName').replace(/_/g,' ') : ''
				})).$element.css({maxWidth:'unset',margin:'4px 0'}))
				.append((new OO.ui.TextInputWidget({ 
					placeholder: 'Comment'
				})).$element.css({maxWidth:'unset',margin:'4px 0'}))
				.append((new OO.ui.ButtonWidget({ 
					label: 'Add'
				}).$element.css('width','100%').children().css('width','100%').parent()).click(function(){
					var opts = JSON.parse(mw.user.options.get('userjs-todo-script') || '[]');
					var arr = [];
					arr.push($(this).parent().parent().find('input[placeholder="Page name or URL"]').val());
					arr.push($(this).parent().parent().find('input[placeholder="Comment"]').val());
					if (!arr.join('')) return;
					arr.push((new Date()).getTime());
					item($('.userjs-todo-list .items'), arr);
					opts.push(arr);
					save(opts);
				}))
			)
			.append($('<div class="items" style="margin:0.5em;padding-top:0.5em;border-top:1px solid #a2a9b1;"></div>'))
			.append('<div class="status" style="padding:0 0.5em 0.5em;"></div>')
		);
		if (ispopup) {
			todo.find('.todo-menu')
				.css('cursor','grab')
				.append((new OO.ui.ButtonWidget({
					framed: false,
					icon: 'close',
					invisibleLabel: true,
					title: 'Close'
				}).$element.css({float:'right',marginRight:'0'}).click(function(){
					parent.remove();
				})))
				.append(($('<a></a>').attr('href',mw.util.getUrl('Special:BlankPage/todo')).append((new OO.ui.ButtonWidget({
					framed: false,
					icon: 'newWindow',
					invisibleLabel: true,
					title: 'Your Todo List'
				}).$element.css('float','right').click(function(){
					location.url = mw.util.getUrl('Special:BlankPage/todo');
				})))))
				.on('mousedown',function(e){
					if (e.target !== this) return;
					this.style.cursor = 'grabbing';
					var x = parent.position().left - e.pageX;
					var y = parent.position().top - e.pageY;
					var b = $(document.body);
					function move (e) {
						parent.css({
							left: Math.clamp($(window).width() - parent.width(), e.pageX + x, 0) + 'px',
							top: Math.clamp($(window).height() - parent.height(), e.pageY +  y, 0) + 'px',
							right: '',
							bottom: ''
						});
					}
					function up () {
						e.target.style.cursor = 'grab';
						b.off('mousemove', move);
						b.off('mouseup', up);
					}
					b.on('mousemove',move);
					b.on('mouseup',up);
				});
		}
		$.each(JSON.parse(mw.user.options.get('userjs-todo-script') || '[]'), function (a,b) { item(todo.find('.items'), b); });
		return todo;
	}
	function repos (pos,css,pvar,cond,pcss,ccss) {
		return $('<div style="pointer-events:all;position:absolute;"></div>').attr('id',pos + 'gfdgfdgfd').css('cursor',pos + '-resize').css(css).on('mousedown',function(e){
			if (e.target !== this) return;
			var p = parent;
			var c = p.find('.userjs-todo-list');
			var q = eval(pvar);
			var q = eval(pvar);
			var b = $(document.body);
			b.css('user-select','none');
			function move (e) {
				if (eval(cond)) return;
				(new Function('e', 'p', 'q', 'p.css(' + pcss + ')'))(e, p, q);
				(new Function('e', 'c', 'q', 'c.css(' + ccss + ')'))(e, c, q);
			}
			function up () {
				b.css('user-select','');
				b.off('mousemove', move);
				b.off('mouseup', up);
			}
			b.on('mousemove', move);
			b.on('mouseup', up);
		});
	}
	if (mw.config.get('wgPageName') === 'Special:BlankPage/todo') {
		document.title = 'Your Todo List - ' + mw.config.get('wgSiteName');
		$('#firstHeading').text('Your Todo List');
		parent = mw.util.$content.empty();
		list();
		link.children().first().click(function(e){
			e.preventDefault();
			mw.notify('Unable to open todo list popup while on the todo list page.',{tag:'rtbyilounmt7udfnod'});
		});
	} else {
		link.children().first().click(function(e){
			e.preventDefault();
			if ($('#userjs-todo-popup')[0]) {
				$('#userjs-todo-popup').remove();
				return;
			}
			ispopup = true;
			parent = $('<div style="overflow:auto;min-height:3em;z-index:' + (mw.config.get('skin') === 'minerva' ? '3' : '4') + ';box-shadow:0 2px 2px 0 rgba(0,0,0,0.25);color:#222;min-width:20em;position:fixed;right:1em;background-color:white;border-radius:4px;border: 1px solid #a2a9b1;font-size:0.75rem;max-width:100vw;" id="userjs-todo-popup"></div>')
				.appendTo(document.body)
				.css('top',link.position().top + link.height() + 8 + 'px')
				.append($('<div style="pointer-events:none;position:absolute;top:0;left:0;bottom:0;right:0;"></div>')
					.append(repos('e',{top:0,right:0,width:'7px',height:'100%'},'p.position().left','e.clientX - q < 40','{right:"",minWidth:"",left:q  + "px"}','{width:e.clientX - q + "px"}'))
					.append(repos('n',{top:0,height:'7px',width:'100%'},'p.position().top + p.height()','q <= e.clientY + 40','{top:Math.max(e.clientY, 0) + "px"}','{height:q - e.clientY + "px"}'))
					.append(repos('s',{bottom:0,height:'7px',width:'100%'},'p.position().top','e.clientY - q < 40','{top:q + "px"}','{height:e.clientY - q + "px"}'))
					.append(repos('w',{left:0,width:'7px',height:'100%'},'p.position().left + parent.width()','q <= e.clientX + 40','{right:"",minWidth:"",left:e.clientX + "px"}','{width:q - e.clientX + "px"}'))
					.append($('<div style="pointer-events:all;position:absolute;height:100%;top:0;right:0;width:7px;height:7px;cursor:ne-resize;"></div>').on('mousedown',function(e){
						e.originalEvent.stopImmediatePropagation();
						$('#egfdgfdgfd').trigger('mousedown');
						$('#ngfdgfdgfd').trigger('mousedown');
					}))
					.append($('<div style="pointer-events:all;position:absolute;height:100%;top:0;left:0;width:7px;height:7px;cursor:nw-resize;"></div>').on('mousedown',function(e){
						e.originalEvent.stopImmediatePropagation();
						$('#wgfdgfdgfd').trigger('mousedown');
						$('#ngfdgfdgfd').trigger('mousedown');
					}))
					.append($('<div style="pointer-events:all;position:absolute;height:100%;bottom:0;right:0;width:7px;height:7px;cursor:se-resize;"></div>').on('mousedown',function(e){
						e.originalEvent.stopImmediatePropagation();
						$('#egfdgfdgfd').trigger('mousedown');
						$('#sgfdgfdgfd').trigger('mousedown');
					}))
					.append($('<div style="pointer-events:all;position:absolute;height:100%;bottom:0;left:0;width:7px;height:7px;cursor:sw-resize;"></div>').on('mousedown',function(e){
						e.originalEvent.stopImmediatePropagation();
						$('#wgfdgfdgfd').trigger('mousedown');
						$('#sgfdgfdgfd').trigger('mousedown');
					}))
				);
			list();
		});
	}
});


/*
 * Does a lookup two previous Page:* from the current, extract the rh from
 * its content, insert it in the header after trying to increase the rh page
 * number. See the FIXME comment(s) for caveats.
 *
 * Originally at User:Phe/Running header.js
 *
 * To use this script manually, add the following to your .js:
 *
 * mw.loader.load("//en.wikisource.org/w/index.php?title=User:Inductiveload/Running_header.js&action=raw&ctype=text/javascript");
 */

( function ( $, mw ) {

	'use strict';

	// Roman numeral functions
	// From http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter
	function int_to_roman( num ) {
		if ( Number( num ) === 0 ) {
			return false;
		}

		var digits = String( Number( num ) ).split( '' ),
			key = [ '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',
				'', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',
				'', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'
			],
			roman = '',
			i = 3;

		while ( i-- ) {
			roman = ( key[ +digits.pop() + ( i * 10 ) ] || '' ) + roman;
		}

		return Array( +digits.join( '' ) + 1 ).join( 'M' ) + roman;
	}

	function roman_to_int( in_str ) {
		var str = in_str.toUpperCase(),
			validator =
			/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/,
			token = /[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,
			key = {
				M: 1000,
				CM: 900,
				D: 500,
				CD: 400,
				C: 100,
				XC: 90,
				L: 50,
				XL: 40,
				X: 10,
				IX: 9,
				V: 5,
				IV: 4,
				I: 1
			},
			num = 0,
			m;
		if ( !( str && validator.test( str ) ) ) { return false; }
		while ( ( m = token.exec( str ) ) ) { num += key[ m[ 0 ] ]; }
		return num;
	}

	var RunningHeaderAutoComplete = function () {
		this.offsets = [ -2, -4, 2, 4, -1, 1 ]; // offsets to try, in order
		this.offset = 0;

		// swap the header around if the offset is odd
		this.recto_verso_swap_sides = true;
		this.flash_textbox = true;

		this.header = document.getElementsByName( 'wpHeaderTextbox' )[ 0 ];
	};

	RunningHeaderAutoComplete.prototype.increment_arabic = function ( rh, inc ) {

		try {
			// now attempt to increment the number
			var r = new RegExp(
				'^(.*[\\|][\\[\\( ]*)(\\d+)([\\]\\)\\. ]*[\\|}].*)$' );
			var regex_res = r.exec( rh );

			var page = Number( r.exec( rh )[ 2 ] ) + inc;
			rh = regex_res[ 1 ] + String( page ) + regex_res[ 3 ];

			this.add_rh( rh );

			return true;
		} catch ( err ) {
			return false;
		}
	};

	RunningHeaderAutoComplete.prototype.increment_roman = function ( rh, inc ) {
		try {
			// now attempt to increment a roman numeral

			var r = new RegExp(
				'^(.*[\\|] *)([ivxlcm]+|[IVXLCM]+)(\\.? *[\\|}].*)$' );
			var regex_res = r.exec( rh );

			var numeral = regex_res[ 2 ];

			var lower_case = false;
			if ( numeral.charCodeAt( 0 ) > 96 && numeral.charCodeAt( 0 ) < 123 ) {
				lower_case = true;
			}

			var number = roman_to_int( numeral ) + inc;

			numeral = int_to_roman( number );

			if ( lower_case ) {
				numeral = numeral.toLowerCase();
			}

			// insert the numeral back into the RH
			rh = regex_res[ 1 ] + numeral + regex_res[ 3 ];

			this.add_rh( rh );

			return true;
		} catch ( err ) {
			return false;
		}
	};

	RunningHeaderAutoComplete.prototype.swap_rh = function ( rh ) {

		rh = rh.replace( /\{\{ *([Rr]h|[Rr]unning header|[[Rr]unningHeader) *\|(.*?)\|(.*?)(?:\|(.*?))?\}\}/,
			'{{running header|$4|$3|$2}}' );
		return rh;
	};

	RunningHeaderAutoComplete.prototype.add_rh = function ( rh ) {

		// remove existing RH
		this.header.value = this.header.value.replace(
			/\{\{ *(rh|rh\/\d|running header|rvh|recto-verso header) *\|.*\}\}\n?/i, '' );

		// swap sides if the offset is odd
		if ( this.recto_verso_swap_sides && ( this.offsets[ this.offset ] % 2 ) !== 0 ) {
			rh = this.swap_rh( rh );
		} else {
			// normalise the template name
			rh = rh.replace( /\{\{ *(rh|running ?header) *\|/i, '{{running header|' );
		}

		var r = new RegExp( /^\s*$/ );

		if ( r.test( this.header.value ) ) {
			this.header.value = rh;
		} else {
			this.header.value = rh + '\n' + this.header.value;
		}
		// flash the textbox
		if ( this.flash_textbox ) {
			this.header.animate( { backgroundColor: 'lightgreen' }, 500 );
		}
	};

	RunningHeaderAutoComplete.prototype.fill_rh = function ( data ) {

		var success = false;

		if ( this.header && !data.query.pages[ 0 ].missing ) {
			var content = data.query.pages[ 0 ].revisions[ 0 ].slots.main.content;
			var r = /\{\{ *(rh|running ?header|rvh|recto-verso header) *\|[^\n<]*\}\}/i;
			var match = r.exec( content );

			if ( match ) {
				// FIXME: needs to be tweaked, actually works only if the first
				// rh parameters consisting of only digits or roman numerals is the one to increment
				var rh = match[ 0 ];

				var pg_offset = this.offsets[ this.offset ];

				// try to increment the number
				success = this.increment_arabic( rh, -pg_offset );

				if ( !success ) { // we failed to get a number, see if there is a roman numeral
					success = this.increment_roman( rh, -pg_offset );
				}

				if ( !success ) {
					// we didn't find a number to increment
					// set equal to the previous page's header, the user needs to edit by hand
					this.add_rh( rh );
				}

				if ( $( 'prp_header' ).css( 'display' ) == 'none' ) {
					// pr_toggle_visibility();
				}
			}
		}
		return success;
	};

	RunningHeaderAutoComplete.prototype.next_offset = function () {
		if ( this.offset < this.offsets.length - 1 ) {
			this.offset++;
			return true;
		}
		return false;
	};

	RunningHeaderAutoComplete.prototype.try_offset = function () {

		var rhac = this;

		var r = new RegExp( '(\\d+)$' );
		var page = Number( r.exec( mw.config.get( 'wgPageName' ) )[ 1 ] ) + this.offsets[
			this.offset ];
		var pagename = mw.config.get( 'wgPageName' ).replace( /\d+$/g, page );

		mw.loader.using( [ 'mediawiki.api' ], function () {
			var api = new mw.Api();
			api.get( {
				action: 'query',
				prop: 'revisions',
				rvprop: 'content',
				rvslots: 'main',
				titles: pagename,
				format: 'json',
				formatversion: 2
			} )
				.done( function ( jsondata ) {
					var success = rhac.fill_rh( jsondata );

					if ( !success && rhac.next_offset() ) {
						rhac.try_offset();
					}
				} )
				.fail( function () {
					if ( rhac.next_offset() ) {
						rhac.try_offset();
					}
				} );
		} );
	};

	RunningHeaderAutoComplete.prototype.set_running_header = function () {

		if ( !this.header ) {
			return;
		}

		this.try_offset();
	};

	function add_portlet( callback ) {
		var portlet = mw.util.addPortletLink(
			'p-tb',
			'#',
			'Running header',
			't-running-header',
			'Add a running header based on the running headers on surrounding pages'
		);

		$( portlet )
			.on( 'click', function ( e ) {
				e.preventDefault();
				callback();
			} );
	}

	function handle_alt_click( elem, callback ) {
		$( elem ).on( 'click', function ( event ) {
			if ( event.altKey ) {
				callback();
			}
		} );
	}

	if ( [ 'Page' ].indexOf( mw.config.get( 'wgCanonicalNamespace' ) ) !== -1 ) {
		var RunningHeaderAutoCompleteInstance = new RunningHeaderAutoComplete();

		var go_fn = function () {
			RunningHeaderAutoCompleteInstance.set_running_header();
		};

		add_portlet( go_fn );
		handle_alt_click( RunningHeaderAutoCompleteInstance.header, go_fn );
	}

}( jQuery, mediaWiki ) );

//* مستخدم:Mr. Ibrahem/common.js*//
//[[وب:مهذب ويكي]]
autoEdMinor=false;autoEdTag="تهذيب";autoEdLinkHover="شغل مهذب الويكي";autoEdLinkName="هذب";importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/core.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodify.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/isbn.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/whitespace.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/wikilinks.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/htmltowikitext.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/headlines.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodecontrolchars.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/unicodehex.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/templates.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/tablestowikitext.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/extrabreaks.js&action=raw&ctype=text/javascript');importScriptURI('//en.wikipedia.org/w/index.php?title=Wikipedia:AutoEd/links.js&action=raw&ctype=text/javascript');function autoEdFunctions(){var a=document.editform.wpTextbox1;a.value=autoEdUnicodify(a.value);a.value=autoEdISBN(a.value);
a.value=autoEdWhitespace(a.value);a.value=autoEdUnicodeHex(a.value);a.value=autoEdWikilinks(a.value);
a.value=autoEdHTMLtoWikitext(a.value);a.value=autoEdHeadlines(a.value);a.value=autoEdUnicodeControlChars(a.value);
a.value=autoEdTemplates(a.value);
a.value=autoEdTablestoWikitext(a.value);a.value=autoEdExtraBreaks(a.value);a.value=autoEdLinks(a.value);
a.value=autoEdExtra(a.value);}

//importScript('user:Majed/translator.js'); 

var homeWiki = "en";
var fromLang = "ar";                                            //the source language
var translatorBarFormat = "$1translate $2 this link from  $3 to $4";      // translate it to your language
var templateTranslatorText = "Template translation";            // translate it to your language 
var removeLinksAliasesText = "Remove Links Aliases";
var doneText = "Done!";                                           // translate it to your language

importScript('en:User:Ebraminio/ArticleTranslator.js');


importScript('User:Zaher.Kadour/OneClickArchiver.js'); // Backlink: [[User:Zaher.Kadour/OneClickArchiver.js]]

// DO NOT COPY IT FOR TRANSLATION, READ THE DOCUMENTATION [[:en:User talk:Ebraminio/ArticleTranslator.js]]

//أزرار مفيدية في صندوق التحرير
//importScript('user:Majed/extrabuttons.js');
//أزرار مفيدية في صندوق التحرير
importScript('user:Mr. Ibrahem/test.js');
//تلوين وصلات اللغات
//importScript('user:Majed/langlinks.js');
//زر معاينة سريعة
importScript('user:Majed/ajaxPreview.js');
//استبدالات وإصلاحات للنص
//importScript('user:Majed/ReplaceAndFix.js');
//معلومات أكثر عن الصفحة
//mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hedonil/XTools/XTools.js&action=raw&ctype=text/javascript');
//معلومات عن الصفحة
//mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:MusikAnimal/MoreMenu.js');
//سكربت للتجارب
//importScript('user:Majed/myscript.js');
//------------------------------------------------------------------------------
// تغيير الألوان في أداة تلوين نصوص صندوق التحرير - يجب تفعيلها أولاً من التفضيلات
syntaxHighlighterConfig = {
	boldOrItalicColor: "#cfb2d5", // النص العريض أو المائل
	//commentColor:      "", //التعليق
	entityColor:       "", //
	externalLinkColor: "#e9e4cd", //الروابط الخارجية
	headingColor:      "#ccff00", //الترويسة
	hrColor:           "", //
	listOrIndentColor: "", //
	//parameterColor:    "", //
	signatureColor:    "", //
	//tagColor:          "", //
	//tableColor:        "", // الجدول
	templateColor:     "#f9f9f9", //القوالب 
	wikilinkColor:     "#d6f1f1 ", //الوصلة الداخلية
};
//------------------------------------------------------------------------------
//إضافة وصلات في الشريط العلوي
//mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=user:IagoQnsi/addptlinks.js');
//
// var ptLinksToAdd = [
//        {
//                label: "صفحات جديدة",
//                title: "صفحات جديدة",
//                url: "خاص:صفحات جديدة",
//                index: 5
//        }
// ];
 //------------------------------------------------------------------------------
 //محتوى الوصلات الداخلية من صندوق التحرير
 if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) > -1 ) {
	mw.loader.load('//en.wikipedia.org/w/index.php?title=User:V111P/js/smartLinkingLoader.js'
			+ '&action=raw&ctype=text/javascript');
}
 //------------------------------------------------------------------------------
//إصلاح مشكلة أداة مقترحات العناوين
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) + 1)
    mw.loader.using(['jquery.ui', 'jquery.textSelection'], function() {
        //enable autocomplete for editbox, relative to editform in an offset of -80 vertical
        $("#wpTextbox1").autoCompleteWikiText({
            positionAt: $('#wpTextbox1').prop('dir') == 'rtl' ? "right top" : "left top",
            positionOf: '#editform',
            positionOffset: "0 0",
            menuCSS: {
                background: '#E0EEF7',
                opacity: 0.8
            },
            itemCSS: {
                padding: 0,
                margin: 0
            }
        });
    });
//------------------------------------------------------------------------------
// قديمة أو لا تعمل أو لم يعد لها حاجة
// كتابة الوصف ووضع الترخيص عند رفع ملف  - لاحاجة له تم إضافته في ويكبيديا بشكل افتراضي
//importScript('user:Majed/upload-description.js');
//------------------------------------------------------------------------------

mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );

mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:ProveIt_GT/ProveIt.js&action=raw&ctype=text/javascript' );


// [[:en:User:ProveIt GT]]

/*[[ويكيبيديا:إضافة أدوات تحرير#النص الأول]]*/
importScript('مستخدم:حصار/AutoEd/complete.js');

importScript('MediaWiki:Gadget-Extra-Edittools.js');

importScript('MediaWiki:Gadget-Extra-Edittools2.js');

//[[ويكيبيديا:أدوات المراجع]]

importScript('Mediawiki:Gadget-RefToolbar.js');

importScript('Mediawiki:Gadget-CustomSideBarLinks.js');

//[[ويكيبيديا:قائمة ملخصات تعديل#إضافة مواد]]
var summaries = window.summaries || [];
summaries = summaries.concat([
                "عنوان",
                {"title": "طفيف"},
                {"title": "تعريب وصلات"},
                {"title": "اضافة خبر"},
                {"title": "زيادة عدد الصور المختارة"},
                {"title": "تنسيق ويكي ، تحديث، تدقيق لغوي ، توسيع"},
                {"title": " مراجعة ، ازالة نصوص ، تنسيق"},
                {"title": " مراجعة ، تنسيق"},
                {"title": "تنسيق ويكي ، تدقيق"},
                {"title": "تنسيق ويكي ، إزالة نصوص"},
        ]);


//Test Script for patrolling new pages
 
function addNewpages(){
          mw.util.addPortletLink("p-tb","http://ar.wikipedia.org/wiki/Special:NewPagesFeed" ,"صفحات جديدة","tb-Newpages","View the list of New pages (NEW Special:New Pages Feed");
}
 
$(addNewpages);