« MediaWiki:Gadget-dosage-calculator.js » : différence entre les versions

De Wikimedica
(Parameter description)
(Change text)
Ligne 31 : Ligne 31 :
// Configure the message dialog when it is opened with the window manager's openWindow() method.
// Configure the message dialog when it is opened with the window manager's openWindow() method.
windowManager.openWindow( dialog, {
windowManager.openWindow( dialog, {
  title: new OO.ui.HtmlSnippet(mw.message('welcome-modal-dialog-title').parse()),
  title: new OO.ui.HtmlSnippet('Calculateur de dose'),
  message: new OO.ui.HtmlSnippet(mw.message('welcome-modal-dialog-message').parse()),
  message: new OO.ui.HtmlSnippet('Amoxiciline 90 mg/kg/j'),
  verbose: true,
  verbose: true,
  size: 'medium',
  size: 'medium',
Ligne 38 : Ligne 38 :
    {
    {
      action: 'accept',
      action: 'accept',
      label: "J'accepte les conditions",
      label: "Fermer le calculateur",
      flags: 'primary'
      flags: 'primary'
    }
    }

Version du 12 janvier 2023 à 22:09

/* 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'
		    }
		  ]
		});
	});
};