Jump to content
Wikipedia The Free Encyclopedia

User:Polygnotus/Scripts/MoreBits.js

From Wikipedia, the free encyclopedia
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.
Documentation for this user script can be added at User:Polygnotus/Scripts/MoreBits.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
 // <nowiki>
 //Used to demonstrate that morebits is loaded, even when Twinkle is not enabled.
 //https://en.wikipedia.org/wiki/Wikipedia:Morebits
 //The idea was to use morebits to put the {{duplicated citations}} template in the correct place according to [[MOS:ORDER]]
 //This doesn't really do anything at the moment.

 mw.loader.using(['ext.gadget.morebits'],function(){
 // Only run on view pages, not on edit pages or other special pages
 if(mw.config.get('wgAction')!=='view')return;

 // Function to demonstrate Morebits status messages
 functiondemonstrateMorebitsStatus(){
 // Initialize Morebits status system
 Morebits.status.init(document.getElementById('mw-content-text'));

 // Create a new overall status
 varoverallStatus=newMorebits.status('Morebits Status Demo');

 // Show an info message
 overallStatus.info('Starting','Beginning the demonstration');

 // Simulate some work and show different status types
 setTimeout(function(){
 varstatus1=newMorebits.status('Step 1');
 status1.info('Processing','Doing some work...');

 setTimeout(function(){
 status1.success('Complete','Step 1 finished successfully');

 varstatus2=newMorebits.status('Step 2');
 status2.warn('Caution','This step might have issues');

 setTimeout(function(){
 status2.error('Failed','Step 2 encountered an error');

 varstatus3=newMorebits.status('Step 3');
 status3.status('In Progress','Final step...');

 setTimeout(function(){
 status3.info('Done','Step 3 completed');
 overallStatus.success('Complete','All steps finished');
 },2000);
 },2000);
 },2000);
 },2000);
 }

 // Add a button to trigger the demonstration
 $(function(){
 var$button=$('<button>')
 .text('Demonstrate Morebits Status')
 .click(demonstrateMorebitsStatus);

 $('#mw-content-text').prepend($button);
 });
 });

 // </nowiki>

AltStyle によって変換されたページ (->オリジナル) /