מדיה ויקי:Common.js

מתוך ויקיחדשות, מקור החדשות החופשי

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
/* כל הסקריפטים שנכתבים כאן ייטענו עבור כל המשתמשים בכל טעינת עמוד */
mw.loader.using( [ 'mediawiki.util', 'mediawiki.api' ] ).then( function() {
importScript("MediaWiki:DWIM.js"); // For the search box
importScript("MediaWiki:SubPagesLink.js"); // Link to sub pages at the toolbox
function NewNot() {
	var PreText = prompt("מה הוא העדכון החדש?");
	if (PreText) {
	new mw.Api().postWithToken('csrf',{
		"action": "edit",
		"title": "תבנית:עדכונים",
		"prependtext": PreText + " | ",
		"summary": "עדכון"
	}).done(function() {mw.notify("בוצע");});
	}
	if (PreText === ""){
		new mw.Api().postWithToken('csrf',{
			"action": "edit",
			"title": "תבנית:עדכונים",
			"text": "",
			"summary": "ניקוי התבנית"
		}).done(function() {mw.notify("התבנית נוקתה");});
	}
}
function editMamar(Mamar, MamarT) {
	new mw.Api().postWithToken('csrf',{
		"action": "edit",
		"title": "תבנית:מאמר " + Mamar,
		"text": MamarT,
		"summary": "עדכון"
	});
}
function Do123() {
	var NewY = "{{כותרת ראשית\n| כותרת = " + $("#Input1").val() + "\n| תקציר = " + $("#Input2").val() + "\n| תמונה = " + $("#Input3").val() + "\n| גודל תמונה = " + $("#Input4").val() + "\n| תקציר תמונה = " + $("#Input5").val() + "\n}}";
	$.ajax( {
	url: mw.util.wikiScript(),
    data: { action: 'raw', title: 'תבנית:מאמר ראשי'},
    dataType: 'text'
    } ).done( function( data1 ) {
	var MamarRashi = data1;
	$.ajax( {
	url: mw.util.wikiScript(),
    data: { action: 'raw', title: 'תבנית:מאמר נבחר'},
    dataType: 'text'
    } ).done( function( data2 ) {
	var MamarNivhar = data2;
	editMamar("ראשי", NewY);
	editMamar("נבחר", MamarRashi);
	editMamar("חדש", MamarNivhar);
	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));
});
}
});