MediaWiki:Common.js

Dari SABDA Labs
Revisi sejak 10 November 2009 06.10 oleh Admin (bicara | kontrib)

Catatan: Setelah menerbitkan, Anda mungkin perlu melewati tembolok peramban web Anda untuk melihat perubahan.

  • Firefox/Safari: Tekan dan tahan Shift sembari mengeklik Reload, atau tekan Ctrl-F5 atau Ctrl-R (⌘-R di Mac)
  • Google Chrome: Tekan Ctrl-Shift-R (⌘-Shift-R di Mac)
  • Edge: Tahan Ctrl sembari mengeklik Refresh, atau tekan Ctrl-F5
/* Any JavaScript here will be loaded for all users on every page load. */

if ( /^MediaWiki(\/.+)?$/.test( wgPageName ) && wgAction == 'view' ) {
	addOnloadHook(function(){
		document.body.className+=" mainpage";
	})
}

/* Force preview for anons */
/* by Marc Mongenet, 2006, fr.wikipedia */
function forcePreview() {
	if( wgUserName != null || wgAction != 'edit' )
		return;
	saveButton = document.getElementById('wpSave');
	if( !saveButton )
		return;
	saveButton.disabled = true;
	saveButton.value = 'Save page (use preview first)';
	saveButton.style.fontWeight = 'normal';
	document.getElementById('wpPreview').style.fontWeight = 'bold';
}
addOnloadHook(forcePreview);
/* End of forcePreview */

/** includePage ************
 * force the loading of another JavaScript file
 * @todo Is this still needed? We have importScript and importScriptURI in wikibits.js
 * Maintainer: [[Commons:User:Dschwen]]
 */
function includePage( name ){
	document.write('<script type="text/javascript" src="' + wgScript + '?title='
		+ name + '&action=raw&ctype=text/javascript"><\/script>' 
	);
}
/* End of includePage */

/* Including extra .js pages */ 

// switches for scripts
// TODO: migrate to JSConfig
// var load_extratabs = true;
var load_edittools = true;

// extra drop down menu on editing for adding special characters
includePage( 'MediaWiki:Edittools.js' );

// Editpage scripts
if( wgAction == 'edit' || wgAction == 'submit' )
	importScript('MediaWiki:Editpage.js')

/* End of extra pages */

/* Test if an element has a certain class **************************************
 *
 * From English Wikipedia, 2008-09-15
 *
 * Description: Uses regular expressions and caching for better performance.
 * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 */
var hasClass = (function() {
	var reCache = {};
	return function ( element, className ) {
		return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
	};
})();