אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Templateslist.js"

פון המכלול
קפיצה לניווט קפיצה לחיפוש
אין תקציר עריכה
(נאר סעלעקטירן דאס וואס ווערט ע"פ רוב נישט גענוצט, צו שפארן צייט)
שורה 60: שורה 60:
addSingleTemplateToList('שטומף מעלדונג','','\n{' + '{שטומף}}','', /שטומף/);
addSingleTemplateToList('שטומף מעלדונג','','\n{' + '{שטומף}}','', /שטומף/);
AddTemplateToList('הויפט ארטיקל','{' + '{הויפט ארטיקל','|','}}');
AddTemplateToList('הויפט ארטיקל','{' + '{הויפט ארטיקל','|','}}');
AddTemplateToList('רעפערענץ - נאמען','','{{הע' + 'רה|שם=רעפ-נאמען}}','');
AddTemplateToList('רעפערענץ - נאמען','{{הערה|','שם=רעפ-נאמען','}}');
addSingleTemplateToList('רעפערענץ - קעפל','\n==רעפערענצן==','\n{'+'{רעפערענצן}}','', /== *רעפערענצן *==/);
addSingleTemplateToList('רעפערענץ - קעפל','\n==רעפערענצן==','\n{'+'{רעפערענצן}}','', /== *רעפערענצן *==/);
//AddTemplateToList('הפרת זכויות יוצרים','{' + '{הפרת זכויות יוצרים|מקור=',' המקור שממנו הועתק התוכן ','|זמן={' + '{ס:יום נוכחי}}/{' + '{ס:חודש נוכחי}}/{' + '{ס:שנה נוכחית}}(~~' + '~~' + '~)}}\n');
//AddTemplateToList('הפרת זכויות יוצרים','{' + '{הפרת זכויות יוצרים|מקור=',' המקור שממנו הועתק התוכן ','|זמן={' + '{ס:יום נוכחי}}/{' + '{ס:חודש נוכחי}}/{' + '{ס:שנה נוכחית}}(~~' + '~~' + '~)}}\n');

רעוויזיע פון 10:01, 13 סעפטעמבער 2023

/* צולייגן א ליסטע פון מוסטערן אינעם געצייג באר, געשריבן דורך [https://he.wikipedia.org/wiki/משתמש:ערן] */
$( function() {
var templates = ["צולייגן מוסטער"];

var templatesText = new Array();

// add template to list of templates
function AddTemplateToList(title, before, middle, after)
{
  templates.push(title);
  templatesText[templates.length-1] = [];
  templatesText[templates.length-1][0] = before;
  templatesText[templates.length-1][1] = middle;
  templatesText[templates.length-1][2] = after;
}

// add template to list if it isn't already contained in the article text
function addSingleTemplateToList(title, before, middle, after, testRgx)
{
  if ( !document.getElementById("wpTextbox1") ) return;
  if ( testRgx && testRgx.test(document.getElementById("wpTextbox1").value) ) return;
  if ( document.getElementById("wpTextbox1").value.indexOf(before) == -1 ) AddTemplateToList (title, before, middle, after);

}

//Defines the templates
function beforeListInit()
{
switch ( mw.config.get( 'wgNamespaceNumber' ) ){
case 6://templates for images
//AddTemplateToList('PD-Israel','{'+'{PD-Israel|תאריך=','ציינו שנה אפשרית אחרונה בשנים שלמות','}}');
AddTemplateToList('כפילות עם תמונה מוויקישיתוף','{'+'{גם בוויקישיתוף|}}','','');
AddTemplateToList('PD-because','{'+'{PD-because|2=','הכניסו בשדה זה את תבנית הרישיון מוויקישיתוף ללא סוגריים','}}');
AddTemplateToList('מידע','{{'+'מידע\n|תיאור=','','\n|מקור=\n|תאריך יצירה=\n|יוצר=\n|אישורים והיתרים=\n|גרסאות אחרות=\n}}');
AddTemplateToList('רישיון Cc-by-sa-4.0','{'+'{Cc-by-sa-4.0}}','','');
AddTemplateToList('שימוש הוגן','{'+'{שימוש הוגן|מקור=','ציינו מקור','|ערך=}}');
AddTemplateToList('תמונה בעייתית','{{ס:'+'תמונה בעייתית|','ציינו סיבה','}}');
break;
case 10://templates for templates
AddTemplateToList('פּאראמעטער','{{{','*פּאראמעטער נאמען*|*דיפאלט ארטיקל*','}}}');
AddTemplateToList('קאטעגאריע','\n[' + '[קאטעגאריע:','נאמען פון קאטעגאריע',']]');
AddTemplateToList('he שפראך לינק','\n[' + '[he:תבנית:','שם התבנית',']]');
AddTemplateToList('נישט איינשליסן','<no'+'include>','טעקסט וואס זאָל ערשיינען אינעם מוסטער און נישט אין די בלעטער וואָס נוצן עס','</no'+'include>');
AddTemplateToList('איינשליסן בלויז','<include'+'only>','טעקסט וואס זאָל ערשיינען בלויז אויף בלעטער וואס נוצן דעם מוסטער','</include'+'only>');
AddTemplateToList('נאוויגאציע מוסטער','{{נאוויגאציע'+'\n|בילד=בילד, אריינגערעכנט לינק אין גרייס. דיפאלט - אנע בילד\n|אינהאלט=','','\n}}');

break;
case 14://templates for categories
addSingleTemplateToList('הבהרת חשיבות','{' + '{ס:הבהרת חשיבות}}','','');
AddTemplateToList('פתיח סטנדרטי לקאטעגאריע','{{קאטעגאריע|קשור|','נושא שאליו הערכים בקאטעגאריע קשורים|ערך ראשי','}}');
AddTemplateToList('קאטעגאריע','\n[' + '[קאטעגאריע:','נאמען פון קאטעגאריע',']]');
//AddTemplateToList('תבנית מיזמים','{{מיזמים|ויקישיתוף=','שם הדף בוויקישיתוף','}}');
AddTemplateToList('תוכן עניינים','{{Category'+'TOC}}','','');
break;
default://templates for other namespaces
//AddTemplateToList('אין תמונה','','{{אין'+' תמונה}}',''); 
//AddTemplateToList("דף מותאם", "{" + "{דף מותאם}" + "}" + "", "", "\n");
addSingleTemplateToList('בעבודה','','\n{'+'{בעבודה}}','\n');
addSingleTemplateToList('הבהרת חשיבות','','{' + '{ס:הבהרת חשיבות}}','');
addSingleTemplateToList('שטומף מעלדונג','','\n{' + '{שטומף}}','', /שטומף/);
AddTemplateToList('הויפט ארטיקל','{' + '{הויפט ארטיקל','|','}}');
AddTemplateToList('רעפערענץ - נאמען','{{הערה|','שם=רעפ-נאמען','}}');
addSingleTemplateToList('רעפערענץ - קעפל','\n==רעפערענצן==','\n{'+'{רעפערענצן}}','', /== *רעפערענצן *==/);
//AddTemplateToList('הפרת זכויות יוצרים','{' + '{הפרת זכויות יוצרים|מקור=',' המקור שממנו הועתק התוכן ','|זמן={' + '{ס:יום נוכחי}}/{' + '{ס:חודש נוכחי}}/{' + '{ס:שנה נוכחית}}(~~' + '~~' + '~)}}\n');
addSingleTemplateToList('צו ליינען מער','\n==צו ליינען מער==\n','* שרייבער, \'\'\'בוך\'\'\', ארויסגעבער, פובליצירונג דאטום\n','', /== *צו ליינען מער *==/);
AddTemplateToList('פירט אהער','{' + '{פירט אהער|','בלאט וואס פירט אהער|אנדערע בלאט שילדערונג|אנדערע בלאט נאמען','}}');
addSingleTemplateToList('פירוש נוסף', '{' + '{אנדערע באדייט|','דאס=|אנדער=|זעט=','}}');
addSingleTemplateToList('באדייטן','{' + '{באדייטן|' + '\n','* [[' + 'ארטיקל 1]] - קורצע ערקלערונג אויפן מהות פון ארטיקל 1\n* [[' + 'ארטיקל 2]] - קורצע ערקלערונג אויפן מהות פון ארטיקל 2\n* [[' + 'ארטיקל 3]] - קורצע ערקלערונג אויפן מהות פון ארטיקל 3','\n}}');
AddTemplateToList('ציטוט','{' + '{ציטוט|תוכן=','הזינו ציטוט כאן','}}');
AddTemplateToList('קאטעגאריע','\n[' + '[קאטעגאריע:','נאמען פון קאטעגאריע',']]');
AddTemplateToList('he שפראך לינק','\n[' + '[he:','שם הערך',']]');
addSingleTemplateToList('סארטיר אין קאטעגאריע','{'+'{DEFAULTSORT:','','}}');
addSingleTemplateToList('דרויסנדע לינקס','\n==דרויסנדע לינקס==\n','* שרייבער, [' + 'Address באשרייבונג פונעם ארטיקל], וועבזייטל נאמען\n','', /== *דרויסנדע לינקס *==/);
addSingleTemplateToList('זעט אויך','\n==זעט אויך==\n','* [' + '[ארטיקל נאמען]]\n','',/== *זעט אויך *==/);
//AddTemplateToList('תבנית מיזמים','{{מיזמים|ויקישיתוף=','שם הדף בוויקישיתוף','}}');
}
}

function initTemplatesList() {
    if( mw.config.get( 'wgAction' ) != 'edit' && mw.config.get( 'wgAction' ) != 'submit') return; // not edit page
    var toolbar = $('#toolbar');
    if( !toolbar ) return; // no toolbar
    beforeListInit();
    var select = $('<select>', {'id': 'templatesList'}).change(function(){
        insertTemplate( this.selectedIndex );
        this.selectedIndex = 0;
        return false;
        });
   
    $(templates).each(function(){ select .append($('<option>',{text:this, title: this})) });
    
    // add to toolbar
    toolbar.append( select );
}

function insertTemplate( index ) {
    if( index > 0 ) {
        insertTags( templatesText[index][0], templatesText[index][2], templatesText[index][1] );
    }
}

function addToWikiEditor()
{
	var templateListAdv= {
        label: 'צולייגן מוסטער',
        type: 'select',
        list: { }
    };

    for ( var i = 1; i < templates.length; i++ ) 
	{
        var addiontalMessages={};
        for(var j=0;j<3;j++)
        {
           if(templatesText[i][j]!="")
              addiontalMessages[templatesText[i][j]]=templatesText[i][j];
        }
        mediaWiki.messages.set(addiontalMessages);
        
        templateListAdv.list['template'+i] = 
        {
            label: templates[i],
            action: {
                type: 'encapsulate',
                options: {
                    pre: templatesText[i][0],
                    peri: templatesText[i][1],
                    post: templatesText[i][2]
                }
            }
        }
	}
       $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'heading',
			'tools': {'templateListAdv': templateListAdv}
       });
}

if (mw.user.options.get('usebetatoolbar'))
mw.loader.using(['ext.wikiEditor'], function() { 
if(typeof $.fn.wikiEditor != 'undefined' && typeof $.wikiEditor.modules.toolbar != 'undefined')
                beforeListInit();
	if ($('#wikiEditor-ui-toolbar').length === 1) addToWikiEditor();//in case it loaded after toolbar initaliztion
	else $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections', addToWikiEditor);
});
else
	initTemplatesList();
});