לדלג לתוכן

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

מתוך צפונות ויקי
אין תקציר עריכה
אין תקציר עריכה
שורה 33: שורה 33:
// dependencies=mediawiki.api
// dependencies=mediawiki.api
if ($('#contentSub').length > 0)
if ($('#contentSub').length > 0)
alert(JSON.stringify($('#contentSub')[0]));
alert(JSON.stringify($('#contentSub')));

גרסה מ־12:50, 29 בנובמבר 2021

var letters = {
	view: ['', 'ויקיפדיה'],
	purge: ['', 'ויקיפדיה'],
	submit: ['^', 'עריכה'],
	edit: ['^', 'עריכה'],
	history: ['!', 'היסטוריה'],
	diff: ['—', 'השוואה']
};
var params = {
	action: "expandtemplates",
	text: "{{קיצור מרחב השם|" + mw.config.get('wgPageName').replaceAll('_', ' ') + "}}",
	prop: "wikitext",
	format: "json"
};
var action, letter, comment;
if ($('.difference-title').length > 0)
	action = 'diff';
else
	action = mw.config.get('wgAction');
if (letters[action] == null) {
	letter = action.split('')[0].toUpperCase();
	comment = action;
} else {
	letter = letters[action][0];
	comment = letters[action][1];
}
var api = new mw.Api();
api.get(params)
	.done(function(data) {
		$(document)
			.prop('title', letter + data.expandtemplates.wikitext + ' — ' + comment);
	});
// dependencies=mediawiki.api
if ($('#contentSub').length > 0)
	alert(JSON.stringify($('#contentSub')));