MediaWiki:Gadget-dosage-calculator.js

De Wikimedica

Note : après avoir enregistré vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

/* This modal dialog displays a tool for drug dosage calculations. */

console.log("Loading dosage calculator ...");

/*
	@param string dose (ex: 90, 1,5)
	@param string unit (ex: mg, mcg)
	@param string frequency (ex: DIE, BID, q12h)
*/
drugKgDosageCalculator = function(dose, unit, frequency) 
{
	// Lazy load the following librairies
	$.when( mw.loader.using( [ 'mediawiki.api', 'oojs-ui-core', 'oojs-ui-windows' ] )).then( function() {
		
		var dialog = new OO.ui.MessageDialog();
		
		// Create and append a window manager.
		var windowManager = new OO.ui.WindowManager();
		$( 'body' ).append( windowManager.$element );
		
		// Add the dialog to the window manager.
		windowManager.addWindows( [ dialog ] );
		
		dialog.getActionProcess = function(action) // Set the cookie and close the dialog when the user clicks the button.
		{ 
			document.cookie = "wikimedica-skip-welcome-message=1; expires=Thu, 18 Dec 2030 12:00:00 UTC; path=/"; 
			this.close();
			return OO.ui.MessageDialog.super.prototype.getActionProcess.call( this, action );
		}
		
		// Configure the message dialog when it is opened with the window manager's openWindow() method.
		windowManager.openWindow( dialog, {
		  title: new OO.ui.HtmlSnippet('Calculateur de dose'),
		  message: new OO.ui.HtmlSnippet('Amoxiciline 90 mg/kg/j'),
		  verbose: true,
		  size: 'medium',
		  actions: [
		    {
		      action: 'accept',
		      label: "Fermer le calculateur",
		      flags: 'primary'
		    }
		  ]
		});
	});
};