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

אין תקציר עריכה
מ 114 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-browsertab.js יובאו
 
(86 גרסאות ביניים של 2 משתמשים אינן מוצגות)
שורה 1: שורה 1:
var letters = {
/*
view: ['', 'ויקיפדיה'],
This gadget shortens the tab browser title.
purge: ['', 'ויקיפדיה'],
For example,
submit: ['^', 'עריכה'],
"(1) שיחה:אורי צבי גרינברג – הבדלי גרסאות"
edit: ['^', 'עריכה'],
will be
history: ['!', 'היסטוריה'],
"(1) =ש:אורי צבי גרינברג – השוואה"
diff: ['—', 'השוואה']
To understand RTL, the translated result is
};
"(1) =ShortNamespacePageName – diff".
var params = {
The structure of the new title includes:
action: "expandtemplates",
1) Browser number data, as "(1) ", if existed in the original title.
text: "{{קיצור מרחב השם|" + mw.config.get('wgPageName').replaceAll('_', ' ') + "}}",
2) Action symbol, "=" for diff, "!" for editing, ";" for history, nothing for reading.
prop: "wikitext",
3) Page name with shortened namespace.
format: "json"
4) Text " – "
};
5) Action full name, like "ויקיפדיה" for reading, "השוואה", "עריכה", "היסטוריה".
var action, letter, comment;
There is no change for two different pages comparing or on flow conversations.
if ($('.difference-title').length > 0)
*/
action = 'diff';
$(function () {
else
//exit on non Hebrew
action = mw.config.get('wgAction');
if (mw.config.get('wgUserLanguage') != 'he')
if (letters[action] == null) {
return;
letter = action.split('')[0].toUpperCase();
// convertion data
comment = action;
var converttable = {
} 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($('#contentSub')[0]);
'עזרה': 'עז',
'שיחת עזרה': 'שז',
'קטגוריה': 'קט',
'שיחת קטגוריה': 'שקט',
'פורטל': 'פ',
'שיחת פורטל': 'שפ',
'טיוטה': 'טי',
'שיחת טיוטה': 'שטי',
'יחידה': 'י',
'שיחת יחידה': 'שי',
'נושא': 'נ'
};
// data about action symbols and names
var letters = {
view: ['', 'ויקיפדיה'],
purge: ['', 'ויקיפדיה'],
submit: ['!', 'עריכה'],
edit: ['!', 'עריכה'],
history: [';', 'היסטוריה'],
diff: ['=', 'השוואה']
};
// find namespace
var namespace = mw.config.get('wgNamespaceNumber');
// ignore flow sections
if (namespace === 2600)
return;
// find page name
var pagename = mw.config.get('wgPageName').replace(/_/g, ' ');
// find current action
var action, letter, actionname;
if ($('.difference-title').length)
action = 'diff';
else if ($('#contentSub').length && $('#contentSub').text().indexOf('הבדלים בין דפים') !== -1)
// different pages comparing, do not touch
return;
else
action = mw.config.get('wgAction');
// unknown action
if (letters[action] == null)
return;
else
[letter, actionname] = letters[action];
// get browser number data at title start
var oldtext = $(document).prop('title');
var par = oldtext.match(/^\([^\)]*\)/);
var partext = par ? par[0] + ' ' : '' ;
// set the short name
var namespaces = mw.config.get('wgFormattedNamespaces');
var namespace = namespaces[namespace];
$(document)
.prop('title', partext + letter + String.fromCharCode(8207)
+ pagename.replace(namespace, converttable[namespace] || namespace)
+ ' – ' + actionname);
});