MediaWiki:Common.js
Dari SABDA Labs
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); }; })(); /* JavaScript file for enhanced recentchanges */ /* * Add the CSS to hide parts that should be collapsed * * We do this with JS so everything will be expanded by default * if JS is disabled */ appendCSS('.mw-changeslist-hidden {'+ ' display:none;'+ '}'+ 'div.mw-changeslist-expanded {'+ ' display:block;'+ '}'+ 'span.mw-changeslist-expanded {'+ ' display:inline !important;'+ ' visibility:visible !important;'+ '}' ); /* * Switch an RC line between hidden/shown * @param int idNumber : the id number of the RC group */ function toggleVisibility(idNumber) { var openarrow = document.getElementById("mw-rc-openarrow-"+idNumber); var closearrow = document.getElementById("mw-rc-closearrow-"+idNumber); var subentries = document.getElementById("mw-rc-subentries-"+idNumber); if (openarrow.className == 'mw-changeslist-expanded') { openarrow.className = 'mw-changeslist-hidden'; closearrow.className = 'mw-changeslist-expanded'; subentries.className = 'mw-changeslist-expanded'; } else { openarrow.className = 'mw-changeslist-expanded'; closearrow.className = 'mw-changeslist-hidden'; subentries.className = 'mw-changeslist-hidden'; } }