מדיה ויקי:Common.js: הבדלים בין גרסאות בדף

מתוך אקו-ויקי, מקום מפגש בנושאי אקולוגיה, חברה וכלכלה.
קפיצה לניווט קפיצה לחיפוש
(ניסוי)
מ (שוחזר מעריכות של מגזין יהלום (שיחה) לעריכה האחרונה של Eburcat)
תגית: שחזור
שורה 1: שורה 1:
/* כל הסקריפטים שנכתבים כאן ייטענו עבור כל המשתמשים בכל טעינת עמוד */
+
/* כל סקריפט JavaScript שנכתב כאן ירוץ עבור כל המשתמשים בכל טעינת עמוד */
mw.loader.using( [ 'mediawiki.util', 'mediawiki.api' ] ).then( function() {
+
 
importScript("MediaWiki:DWIM.js"); // For the search box
+
var customizeToolbar = function() {
importScript("MediaWiki:SubPagesLink.js"); // Link to sub pages at the toolbox
+
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
function NewNot() {
+
    'section': 'main',
var PreText = prompt("מה הוא העדכון החדש?");
+
    'group': 'format',
if (PreText) {
+
    'tools': {
new mw.Api().postWithToken('csrf',{
+
      'strike': {
"action": "edit",
+
        label: 'טקסט מחוק',
"title": "תבנית:עדכונים",
+
        type: 'button',
"prependtext": PreText + " | ",
+
        icon: '//ecowiki.org.il/images/8/8d/NewInlineBtn.png',
"summary": "עדכון"
+
        action: {
}).done(function() {mw.notify("בוצע");});
+
          type: 'encapsulate',
}
+
          options: {
if (PreText === ""){
+
            pre: "<s>",
new mw.Api().postWithToken('csrf',{
+
            post: "</s>"  
"action": "edit",
+
          }
"title": "תבנית:עדכונים",
+
        }
"text": "",
+
      }
"summary": "ניקוי התבנית"
+
    }
}).done(function() {mw.notify("התבנית נוקתה");});
+
  } );
}
+
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
}
+
    'section': 'advanced',
function editMamar(Mamar, MamarT) {
+
     'group': 'format',
new mw.Api().postWithToken('csrf',{
+
     'tools': {
"action": "edit",
+
      'strike': {
"title": "תבנית:מאמר " + Mamar,
+
        label: 'הזחה',
"text": MamarT,
+
        type: 'button',
"summary": "עדכון"
+
        icon: '//ecowiki.org.il/images/3/3b/Vector_toolbar_indentation_button_rtl.png',
});
+
        action: {
}
+
          type: 'encapsulate',
function Do123() {
+
          options: {
var NewY = "{{כותרת ראשית\n| כותרת = " + $("#Input1").val() + "\n| תקציר = " + $("#Input2").val() + "\n| תמונה = " + $("#Input3").val() + "\n| גודל תמונה = " + $("#Input4").val() + "\n| תקציר תמונה = " + $("#Input5").val() + "\n}}";
+
            pre: ":"
$.ajax( {
+
          }
url: mw.util.wikiScript(),
+
        }
     data: { action: 'raw', title: 'תבנית:מאמר ראשי'},
+
      }
     dataType: 'text'
+
     }
    } ).done( function( data1 ) {
+
  } );
var MamarRashi = data1;
+
};
$.ajax( {
+
 
url: mw.util.wikiScript(),
+
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
    data: { action: 'raw', title: 'תבנית:מאמר נבחר'},
+
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
     dataType: 'text'
+
mw.loader.using( 'user.options', function () {
    } ).done( function( data2 ) {
+
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
var MamarNivhar = data2;
+
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
editMamar("ראשי", NewY);
+
$.when(
editMamar("נבחר", MamarRashi);
+
mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
editMamar("חדש", MamarNivhar);
+
).then( customizeToolbar );
mw.notify('בוצע');
 
})});
 
}
 
function GetNewY() {
 
mw.loader.using('jquery.ui', function() {
 
function makeline(line) {
 
return $('<tr>')
 
.append($('<td>').text(line.prompt + ':'))
 
.append($('<td>').append($('<input>', {type: 'text', width: '17em', id: line.input})));
 
 
}
 
}
function maketable(ar) {
+
} );
var t = $('<table>');
 
for (var i in ar)
 
t.append(makeline(ar[i]));
 
return t;
 
}
 
var dialog = $('<div>').dialog()
 
.append(maketable([
 
{input: 'Input1', prompt: 'כותרת'},
 
{input: 'Input2', prompt: 'תקציר'},
 
{input: 'Input3', prompt: 'תמונה'},
 
{input: 'Input4', prompt: 'גודל תמונה'},
 
{input: 'Input5', prompt: 'תקציר תמונה'}
 
])
 
)
 
.dialog('option', 'buttons', {
 
'בצע':
 
Do123,
 
'סגור':
 
function() {dialog.dialog('close');}
 
});
 
});
 
}
 
$(mw.util.addPortletLink('p-tb', '#', 'הוספת ידיעה חדשה')).click(GetNewY);
 
$(mw.util.addPortletLink('p-tb', '#', 'עדכון חדש')).click(NewNot);
 
if (mw.config.get('wgAction') == "view") {
 
$.ajax( {
 
url: mw.util.wikiScript(),
 
    data: { action: 'raw', title: 'תבנית:עדכונים'},
 
    dataType: 'text'
 
    } ).done( function( Info ) {
 
$("#firstHeading").after($('<marquee onmouseover="this.stop()" onmouseout="this.start()" direction="right" bgcolor="FF FA FA">').append(Info));
 
});
 
 
}
 
}
});
+
// Add the customizations to LiquidThreads' edit toolbar, if available
 +
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );

גרסה מ־13:19, 23 באוקטובר 2020

/* כל סקריפט JavaScript שנכתב כאן ירוץ עבור כל המשתמשים בכל טעינת עמוד */

var customizeToolbar = function() {
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
    'section': 'main',
    'group': 'format',
    'tools': {
      'strike': {
        label: 'טקסט מחוק',
        type: 'button',
        icon: '//ecowiki.org.il/images/8/8d/NewInlineBtn.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: "<s>",
            post: "</s>" 
          }
        }
      }
    }
  } );
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
    'section': 'advanced',
    'group': 'format',
    'tools': {
      'strike': {
        label: 'הזחה',
        type: 'button',
        icon: '//ecowiki.org.il/images/3/3b/Vector_toolbar_indentation_button_rtl.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: ":"
          }
        }
      }
    }
  } );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options', function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );