משתמש:מושך בשבט/mytemplateslist.js: הבדלים בין גרסאות בדף
קפיצה לניווט
קפיצה לחיפוש
אין תקציר עריכה |
אין תקציר עריכה |
||
שורה 33: | שורה 33: | ||
AddTemplateToList('[[רש"י/דף|מה שיוצג]]','','\n{'+'{[[רש"י/דף|מה שיוצג]]}}','\n'); | AddTemplateToList('[[רש"י/דף|מה שיוצג]]','','\n{'+'{[[רש"י/דף|מה שיוצג]]}}','\n'); | ||
AddTemplateToList('[[תוספות/{{כאן}}|טקסט]]','','\n{'+'{[[תוספות/{{כאן}}|טקסט]]}}','\n'); | AddTemplateToList('[[תוספות/{{כאן}}|טקסט]]','','\n{'+'{[[תוספות/{{כאן}}|טקסט]]}}','\n'); | ||
AddTemplateToList(' | AddTemplateToList('{{גופן|3|אריאל|גמ'}}','{' + '{{{גופן|3|אריאל|גמ'}}','|','}}'); | ||
AddTemplateToList('הערת שוליים - הפניה','','{{הע' + 'רה|שם=שם-הערה}}',''); | AddTemplateToList('הערת שוליים - הפניה','','{{הע' + 'רה|שם=שם-הערה}}',''); | ||
AddTemplateToList('הערת שוליים - כותרת','\n==הערות שוליים==','\n{'+'{הערות שוליים}}','', /== *הערות שוליים *==/); | AddTemplateToList('הערת שוליים - כותרת','\n==הערות שוליים==','\n{'+'{הערות שוליים}}','', /== *הערות שוליים *==/); |
גרסה מ־13:50, 18 בספטמבר 2020
/* הוספת רשימת תבניות בסרגל הכלים,מבוסס עלהדף המקביל בוויקיפדיה העברית שנכתב על ידי [[משתמש:ערן]] */
$( 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' ) ){
default://templates for other namespaces
AddTemplateToList('[[תוספות/דף|מה שיוצג]]','','{{[[תוספות/דף|מה שיוצג]]}}','\n');
AddTemplateToList('[[רש"י/דף|מה שיוצג]]','','\n{'+'{[[רש"י/דף|מה שיוצג]]}}','\n');
AddTemplateToList('[[תוספות/{{כאן}}|טקסט]]','','\n{'+'{[[תוספות/{{כאן}}|טקסט]]}}','\n');
AddTemplateToList('{{גופן|3|אריאל|גמ'}}','{' + '{{{גופן|3|אריאל|גמ'}}','|','}}');
AddTemplateToList('הערת שוליים - הפניה','','{{הע' + 'רה|שם=שם-הערה}}','');
AddTemplateToList('הערת שוליים - כותרת','\n==הערות שוליים==','\n{'+'{הערות שוליים}}','', /== *הערות שוליים *==/);
AddTemplateToList('שולי הגליון','','\n{'+'{שולי הגליון}}','\n');
AddTemplateToList('הפרת זכויות יוצרים','{' + '{הפרת זכויות יוצרים|מקור=',' המקור שממנו הועתק התוכן ','|זמן={' + '{ס:יום נוכחי}}/{' + '{ס:חודש נוכחי}}/{' + '{ס:שנה נוכחית}}(~~' + '~~' + '~)}}\n');
AddTemplateToList('מפנה','{' + '{מפנה|','הדף המפנה|הסבר על הדף האחר|שם הדף האחר','}}');
AddTemplateToList('פירוש נוסף', '{' + '{פירוש נוסף|','נוכחי=|אחר=|ראו=','}}');
AddTemplateToList('ציטוט','{' + '{ציטוט|תוכן=','הזינו ציטוט כאן','}}');
AddTemplateToList('קטגוריה','\n[' + '[קטגוריה:','שם הקטגוריה',']]');
AddTemplateToList('מיון בקטגוריה','{'+'{מיון רגיל:','','}}');
AddTemplateToList('קישורים חיצוניים','\n==קישורים חיצוניים==\n','* שם כותב, [' + 'Address תיאור המאמר], שם האתר\n','', /== *קישורים חיצוניים *==/);
AddTemplateToList('פרמטר','{{{','*שם הפרמטר*|*ערך ברירת מחדל*','}}}');
AddTemplateToList('קטגוריה','\n[' + '[קטגוריה:','שם הקטגוריה',']]');
AddTemplateToList('קטע שיופיע רק בדף התבנית','<no'+'include>','טקסט שיופיע בתבנית ולא בדפים המשתמשים בה','</no'+'include>');
AddTemplateToList('קטע שיופיע רק בדפים המכילים את התבנית','<include'+'only>','טקסט שיופיע בדפים המשתמשים בתבנית בלבד','</include'+'only>');
AddTemplateToList('הבהרת חשיבות','{' + '{ס:הבהרת חשיבות}}','','');
AddTemplateToList('פתיח סטנדרטי לקטגוריה','{{קטגוריה|קשור|','נושא שאליו הערכים בקטגוריה קשורים|ערך ראשי','}}');
AddTemplateToList('קטגוריה','\n[' + '[קטגוריה:','שם הקטגוריה',']]');
AddTemplateToList('תוכן עניינים','{{Category'+'TOC}}','','');
}
}
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();
});