Напомена: Пошто објавите измене, можда ћете морати да обришете кеш прегледача како бисте их видели.

  • Firefox / Safari: Држите Shift и кликните на Reload или притисните Ctrl-F5 или Ctrl-R (⌘-R на Mac-у).
  • Google Chrome: Притисните Ctrl-Shift-R (⌘-Shift-R на Mac-у).
  • Internet Explorer / Edge: Држите Ctrl и кликните на Refresh или притисните Ctrl-F5.
  • Opera: Притисните Ctrl-F5.
/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since Common.js isn't a gadget, there is no place to declare its
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */
'use strict';
// [[Category:Wiktionary scripts]] <nowiki>
/*jshint shadow:true, undef:true, latedef:true, unused:true, es3:true */
/*global jQuery, mw, importScript, importStylesheet */

/** [[WT:PREFS]] v2.0 **/
try {
	(function() {

		var prefs;
		try {
			prefs = window.localStorage.getItem('AGprefs');
		} catch (e) {
			prefs = jQuery.cookie('AGprefs');
		}

		prefs = prefs && JSON.parse(prefs);

		if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') !== -1)
			return;

		if (mw.config.get('wgUserGroups').indexOf('user') === -1) {
			// XXX: [[Wiktionary:Preferences/V2]] is just a temporary page

			mw.loader.using(['mediawiki.util'], function() {
				mw.util.addPortletLink('p-personal', mw.util.getUrl('Wiktionary:Preferences/V2'),
					'Preferences', 'pt-agprefs', 'Personalise Wiktionary (settings are kept per-browser).', '',
					document.getElementById('pt-createaccount'));
			});

			if ((mw.config.get('wgAction') === 'view') && (mw.config.get('wgPageName') === 'Wiktionary:Preferences/V2')) {
				mw.loader.load('ext.gadget.AGprefs'); // [[MediaWiki:Gadget-AGprefs.js]]
			}
		}

		if (!prefs)
			return;

		mw.loader.state('the_pope_is_an_atheist_woman_alien', 'missing');
		for (var key in prefs.modules) {
			if (prefs.modules[key]) {
				mw.loader.load([key]);
			} else {
				// unavoidable race condition. to prevent it, every enabled-by-default gadget should have "site" as a dependency
				if (mw.loader.getState(key) !== 'ready') {
					mw.loader.moduleRegistry[key].dependencies.push('the_pope_is_an_atheist_woman_alien');
					mw.loader.state(key, 'missing');
				} else {
					// XXX
					mw.log.warn(key + " could not be disabled; make sure it has 'site' declared as a dependency");
				}
			}
		}

		for (var key in prefs.sheets) {
			importStylesheet('MediaWiki:Gadget-' + key);
		}

		for (var key in prefs.scripts) {
			importScript('MediaWiki:Gadget-' + key);
		}

		if (mw.config.get('wgUserGroups').indexOf('user') !== -1)
			mw.loader.using([ 'mediawiki.api'], function() {
				var changes = [];
				for (var key in prefs.gadgets)
					changes.push('gadget-' + key + '=' + (prefs.gadgets[key] ? '1' : '0'));

				(new mw.Api()).postWithToken('options', {
					action: 'options',
					change: changes.join('|')
				}).then(function() {
					jQuery.cookie('AGprefs', null);
					try {
						window.localStorage.removeItem('AGprefs');
					} catch (e) { /* */ }
					mw.notify(
						jQuery('<b>Your <a href="/wiki/Wiktionary:Preferences/V2">per-browser preferences</a> have been migrated</b><br/><br/>' +
							'From now on, you should use your <a href="/wiki/Special:Preferences">user preferences page</a>. ' +
							'Preferences will no longer apply after you log out.')
					);
				});
			});

	})();
} catch (e) {
	mw.log.warn(e);
}

mw.loader.using('mediawiki.util').done(function() {
	/** &withmodule= query parameter **/
	if (mw.util.getParamValue('withmodule'))
		mw.loader.load(mw.util.getParamValue('withmodule').split(','));

	/** &preloadtext= and &preloadminor= **/
	if (mw.config.get('wgAction') === 'edit')
		jQuery(document).ready(function() {
			var wpTextbox1 = document.getElementById('wpTextbox1');
			var wpMinoredit = document.getElementById('wpMinoredit');
			if (!wpTextbox1)
				return;

			var preloadtext = mw.util.getParamValue('preloadtext');
			var preloadminor = mw.util.getParamValue('preloadminor');

			if (preloadtext && !wpTextbox1.value)
				wpTextbox1.value = preloadtext;
			if ((preloadminor !== null) && wpMinoredit)
				wpMinoredit.checked = !/^(0|false|no|)$/i.test(preloadminor);
		});

	/** Monthly subpages; see [[Template:discussion recent months|discussion recent months]] **/
	/*  See also: [[Special:AbuseFilter/43]]  */
	if (/^Wiktionary:(Beer_parlour|Grease_pit|Tea_room|Etymology_scriptorium|Information_desk)$/.test(mw.config.get('wgPageName')))
		jQuery(document).ready(function() {
			var nNSR = document.getElementById('new-section-redirect').getElementsByTagName('a')[0];
			var caAddSection = document.getElementById('ca-addsection');
			if (!caAddSection) {
				caAddSection = mw.util.addPortletLink(mw.config.get('skin') === 'vector' ? 'p-views' : 'p-cactions',
					nNSR.href, '+', 'ca-addsection', "Start a new section", '+', document.getElementById('ca-history')
				);
			} else {
				caAddSection.getElementsByTagName('a')[0].href = nNSR.href;
			}
		});
});

/** [[Special:PrefixIndex/Unsupported titles]] **/
if ((mw.config.get('wgAction') === 'view') && /^Unsupported_titles\//.test(mw.config.get('wgPageName')))
	jQuery(document).ready(function() {
		var titleMap = {
			'Left_curly_bracket': '{',
			'Right_curly_bracket': '}',
			'Left_square_bracket': '[',
			'Right_square_bracket': ']',
			'Less_than': '&lt;',
			'Greater_than': '>',
			'Equal_greater_than': '=&gt;',
			'Equal_less_than': '=&lt;',
			'Greater_than_equal': '&gt;=',
			'Less_than_equal': '&lt;=',
			'Hyphen_greater_than': '-&gt;',
			'Less_than_hyphen': '&lt;-',
			'Greater_than_low_line_less_than': '&gt;_&lt;',
			'Double_colon': '::',
			'Enclosing_colons': ': :',
			'Colon_equals': ':=',
			'Colon_capital_thorn': ':Þ',
			'Colon_slash_slash': '://',
			'Colon_left_paren': ':(',
			'Colon_right_paren': ':)',
			'Less_than_greater_than': '&lt;&gt;',
			'Less_than_three': '&lt;3',
			'Enclosing_less_than_greater_than': '&lt; &gt;',
			'Less_than_trailing_slash_greater_than': '&lt; /&gt;',
			'HTML_start_tag_end_tag': '&lt; &gt; &lt;/ &gt;',
			'HTML_comment': '&lt;!-- --&gt;',
			'g_tag': '&lt;g&gt;',
			'Colon_hyphen_left_paren': ':-(',
			'Colon_hyphen_right_paren': ':-)',
			'Vertical_line': '|',
			'Vertical_line_vertical_line': '||',
			'Enclosing_vertical_lines': '| |',
			'C_sharp': 'C#',
			'Number_sign': '#',
			'Enclosing_number_signs': '# #',
			'Colon': ':',
			'Double_period': '..',
			'Full_stop': '.',
			'Low_line': '_',
			'Low_line_interfix': '-_-',
			'Replacement_character': '\ufffd',
			'Square_brackets': '[ ]',
			'Curly_brackets': '{ }',
			'Square_bracketed_ellipsis': '[…]',
			'Enclosing_low_lines': '_ _',
			'C_through_N_to_K': 'C|N>K',
			'о_slash_dot': 'о/.',

			'Thai_name_of_Bangkok': 'กรุงเทพมหานคร อมรรัตนโกสินทร์ มหินทรายุธยามหาดิลกภพ นพรัตน์ราชธานีบุรีรมย์ อุดมราชนิเวศน์มหาสถาน อมรพิมานอวตารสถิต สักกะทัตติยะวิษณุกรรมประสิทธิ์',
			'Ancient_Greek_dish': 'λοπαδοτεμαχοσελαχογαλεοκρανιολειψανοδριμυποτριμματοσι'+
			'λφιοκαραβομελιτοκατακεχυμενοκιχλ\u00ADεπικοσσυφοφαττοπεριστεραλεκτρυονοπτοκεφαλλιοκιγκλοπελειολαγῳοσιραιοβαφητραγανοπτερύγων',

			'Ideographic_space': '[ideographic space]',
			'Space': '[space]',
			'Ogham_space': '[Ogham space]',

			'': ''
		};
		var newTitle = titleMap[mw.config.get('wgPageName').replace(/^Unsupported_titles\//, '')] ||
			(mw.config.get('wgTitle').replace(/^Unsupported titles\//, ''));

		var titleTag = document.getElementsByTagName('title')[0];
		titleTag.innerHTML = titleTag.innerHTML.replace(/^.*(?= -)/, newTitle.replace(/<[^>]+>/g, ''));
		document.getElementById('firstHeading').innerHTML = newTitle;
	});

// 
if (mw.config.get('wgCanonicalSpecialPageName') == 'Badtitle') {
	var m, rxArticlePath = new RegExp('^' + mw.config.get('wgArticlePath').replace('$1', '(.*)') + '$');
	var title;
	if ((m = rxArticlePath.exec(location.pathname))) {
		title = decodeURIComponent(m[1]);
	} else {
		title = mw.util.getParamValue('title');
	}

	// not all titles are listed, because not all actually trigger the "bad title" message
	var revTitleMap = {
		'<': 'Unsupported titles/Less than',
		'>': 'Unsupported titles/Greater than',
		'{': 'Unsupported titles/Left curly bracket',
		'}': 'Unsupported titles/Right curly bracket',
		'[': 'Unsupported titles/Left square bracket',
		']': 'Unsupported titles/Right square bracket',
		'_': 'Unsupported titles/Low line',
		' ': 'Unsupported titles/Space',
		':': 'Unsupported titles/Colon',
		'.': 'Unsupported titles/Full stop',
		'|': 'Unsupported titles/Vertical line',
		'||': 'Unsupported titles/Vertical line vertical line',
		'| |': 'Unsupported titles/Enclosing vertical lines',

		'::': 'Unsupported titles/Double colon',
		': :': 'Unsupported titles/Enclosing colons',
		'<>': 'Unsupported titles/Less than greater than',
		'< >': 'Unsupported titles/Enclosing less than greater than',
		'<3': 'Unsupported titles/Less than three',
		'<g>': 'Unsupported titles/g tag',
		'< > </ >': 'Unsupported titles/HTML start tag end tag',

		'[ ]': 'Unsupported titles/Square brackets',
		'{ }': 'Unsupported titles/Curly brackets',

		'C|N>K': 'Unsupported titles/C through N to K',

		'\ufffd': 'Unsupported titles/Replacement character'
	};
	if (revTitleMap[title]) {
		location.href = mw.util.getUrl(revTitleMap[title]);
	}
}


$("a.CategoryTreeLabelCategory").text(
	function(index, content) {
		return content.replace(
			/^Requests for (?:verification|deletion|cleanup) in (.+) entries$/,
			"$1"
		);
	}
);

// removes "0 c" for categories that do not have subcategories
$(".CategoryTreeEmptyBullet + a + span")
	.html(
		function(index, content) {
			return content.replace(
				"0 c, ",
				""
			);
		}
	);
// </nowiki>
// The rest of the scripts are at [[MediaWiki:Gadget-legacy.js]].
// Most of them should be converted into gadgets as time and resources allow.