Aller au contenu

Module:Infobox/Composé chimique

Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 9 mai 2014 à 15:29 et modifiée en dernier par Zolo (discuter | contributions) (mise à jour (incomplète), comment-out des parties à vérifier, simplification de la fonction ispNFPA704). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Composé chimique.


local wikidata = require "Module:Wikidata"
local styleH = {['background'] = '#EEEEEE', ['text-indent'] = '3px', ['text-align'] = 'left', ['font-weight'] = 'normal', ['width'] = '45%', ['padding'] = '2px 7px'}
local styleH1 = {['background'] = '#EEEEEE',  ['text-align'] = 'center', ['font-weight'] = 'normal'}

local function dispNFPA704( )
    local data
    local valHealth = wikidata._formatStatements({property= 'P993'})
    local valFire = wikidata._formatStatements({property= 'P994'})
    local valReactivity = wikidata._formatStatements({property= 'P995'})
    local valOther = wikidata._formatStatements({property= 'P877'})
    
    res = ''
	
	local tableFire = {
		['0'] = 'Produit incombustible.',
		['1'] = 'Produit ne pouvant s\'enflammer qu\'après chauffage.',
		['2'] = 'Produit qui ne peut s\'enflammer qu\'après un chauffage modéré ou une exposition à une source de chaleur relativement élevée. Point d\'éclair compris entre 38 °C et 93 °C.',
		['3'] = 'Liquides et solides susceptibles de s\'enflammer à température ambiante. Point d\'éclair compris entre 38 °C et 23 °C.',
		['4'] = 'Produit susceptible de se vaporiser rapidement ou complètement à température et pression ambiantes, ou de se disperser dans l\'air et de s\'enflammer facilement. Point d\'éclair inférieur à 23 °C.',
	}
	if valFire then
		local textFire = tableFire[valFire] or '? [[Catégorie:Valeur Wikidata inattendue]]'
    	res = res .. '<div style="width: 75px; height: 2em; text-align: center; vertical-align: middle; position: absolute; top: 12px; font-size: large;"><span style="color: black;" title="' .. textFire .. '">' .. valFire ..'</span></div>'
	end

	local tableHealth = {
		['0'] ='Produit non toxique, pouvant être utilisé sans précautions particulières.',
		['1'] = 'Produit pouvant provoquer après une exposition une irritation ou des séquelles mineures.',
		['2'] =  'Produit pouvant provoquer après une exposition intense ou continue (mais non chronique), une incapacité temporaire ou une séquelle mineure résiduelle.',
		['3'] = 'Produit pouvant provoquer après une exposition de courte durée, des séquelles graves temporaires ou bien des séquelles modérées résiduelles.',
		['4'] ='Produit pouvant provoquer après une exposition de très courte durée, un décès ou des séquelles graves.',
	}

	if valHealth then
		local textHealth = tableHealth[valHealth] or '? [[Catégorie:Valeur Wikidata inattendue]]'
    	res = res .. '<div style="width: 75px; height: 2em; text-align: center; vertical-align: middle; position: absolute; top: 12px; font-size: large;"><span style="color: black;" title="' .. textHealth .. '">' .. valHealth ..'</span></div>'
	end	

	local tableReactivity = {
		['0'] = 'Produit généralement inerte.',
		['1'] = 'Produit stable, mais pouvant devenir instable à température et pression élevées.',
		['2'] = 'Produit pouvant subir une transformation chimique violente à température et pression élevées, ou susceptible d\'exploser au contact de l\'eau, ou de former un mélange explosif avec de l\'eau.',
		['3'] = 'Produit pouvant détoner ou exploser, mais nécessitant une forte source d\'allumage, ou un chauffage important en milieu confiné, ou susceptible d\'exploser au contact de l\'eau, ou capable d\'exploser par un choc important.',
		['4'] = 'Produit pouvant détoner ou exploser à température et pression ambiantes.'
	}

	if valReactivity then
		local textReactivity = tableReactivity[valReactivity] or '? [[Catégorie:Valeur Wikidata inattendue]]'
    	res = res .. '<div style="width: 75px; height: 2em; text-align: center; vertical-align: middle; position: absolute; top: 12px; font-size: large;"><span style="color: black;" title="' .. textReactivity .. '">' .. valReactivity ..'</span></div>'
	end	
	
    if valOther '' then
    	res = res .. '<div style="width: 75px; height: 2em; text-align: center; vertical-align: middle; position: absolute; top: 49px; font-size: small;">' .. valOther .. '</div>'
	end
	
    if res ~= '' then
        res = '<div style="position: relative; height: 85px; width: 75px;margin: 0 auto"><div style="position: absolute; height: 75px; width: 75px;">[[Image:NFPA 704.svg|75px|Symbole NFPA 704]]</div>' .. res .. '</div>'
    end
    
    return res
end

function dispSGH()
    local variable = ''
	return variable
end

function dispADR()
    local variable = ''
	return variable
end

-- Main function

return {
	style = {['float'] = 'right', ['width'] = '300', ['border'] = '1px solid #AAA', ['clear'] = 'right', ['margin'] = '0 0 0.5em 1em', ['word-wrap'] = 'break-word', ['padding'] = '5px'},
--	class = 'drugInfoBox_infobox_v2', -- n'a pas l'air de fonctionner correctement
    parts = {
        {
			type = 'title',
			value = 'nom',
			style = {['background'] = '#ffdead', ['width'] = '100%', ['font-size'] = '130%', ['line-height'] = '50px', ['height'] = '50px', ['vertical-align'] = 'bottom', ['text-align'] = 'center', ['font-weight'] = 'bold', ['border'] = '2px solid #FFFFFF'},
        },
        {
			type = 'images',
			imageparameters = {'images'},
			captionparameter = 'legende'
        },
        {
			type = 'table',
			title = {
				value = 'Identification',
				style = {['background'] = '#ffdead', ['border'] = '2px solid #FFFFFF', ['font-weight'] = 'bold'}
				},
			style = {['width'] = '100%', ['font-size'] ='95%'},
			rows = {
				{type = 'mixed', label = '[[Dénomination commune internationale|DCI]]', value = 'DCI', styleHeader = styleH},
				{type = 'mixed', label = '[[Nomenclature IUPAC|Nom IUPAC]]', value = 'nomIUPAC', styleHeader = styleH},
				{type = 'mixed', label = '[[Numéro CAS|N° CAS]]', value = 'CAS', property = 'p231', styleHeader = styleH},
				{type = 'mixed', label = '[[Numéro EINECS|N° EINECS]]', value = 'EINECS', property = 'p232', styleHeader = styleH},
				{type = 'mixed', label = '[[Numéro RTECS|N° RTECS]]', value = 'RTECS', property = 'p657', styleHeader = styleH},
				{type = 'mixed', label = '[[Classification anatomique, thérapeutique et chimique|Code ATC]]', value = 'ATC', property = 'p267', styleHeader = styleH},
				{type = 'mixed', label = 'DrugBank', value = 'DrugBank', property = 'p715', styleHeader = styleH},
				{type = 'mixed', label = '[[PubChem]]', value = 'PubChem', class = 'external text', property = 'p662', weblink = 'http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=', styleHeader = styleH},
				{type = 'mixed', label = 'ChEBI', value = 'chEBI', property = 'p683', weblink = 'http://www.ebi.ac.uk/chebi/searchId.do?chebiId=', styleHeader = styleH},
				{type = 'mixed', label = '[[Additif alimentaire|N° E]]', value = 'NrE', property = 'p628', styleHeader = styleH},
				{type = 'mixed', label = '[[Generally recognized as safe|FEMA]]', value = 'FEMA', styleHeader = styleH},
				{type = 'mixed', label = '[[Simplified Molecular Input Line Entry Specification|SMILES]]', value = 'SMILES', property = 'p233', hidden = 1, styleHeader = styleH},
				{type = 'mixed', label = 'InChI', value = 'StdInChI', property = 'p234', hidden = 1, styleHeader = styleH},
				{type = 'mixed', label = 'InChIKey', value = 'StdInChIKey', property = 'p235', hidden = 1, styleHeader = styleH},
				{type = 'mixed', label = 'Apparence', value = 'apparence', styleHeader = styleH}
                }
            },
			{
			type = 'table',
			title = {
				value = 'Propriétés chimiques',
				style = {['background'] = '#ffdead', ['border'] = '2px solid #FFFFFF', ['font-weight'] = 'bold'}
				},
        	style = {['width'] = '100%', ['font-size'] = '95%'},
        	rows  = {
				{type = 'mixed', label = '[[Formule brute]]', value = 'formule', property = 'p274', styleHeader = styleH},
				{type = 'mixed', label = '[[Masse molaire]]', value = 'masseMol', styleHeader = styleH},
				{type = 'mixed', label = '[[Constante_d\'équilibre#.C3.89quilibres_acido-basiques_:_KA.2C_KB|pKa]]', value = 'pKa', styleHeader = styleH},
				{type = 'mixed', label = '[[Dipôle_électrostatique#Moment_dipolaire|Moment dipolaire]]', value = 'momentDipolaire', styleHeader = styleH},
				{type = 'mixed', label = '[[Susceptibilité magnétique]]', value = 'susceptibiliteMagnetique', styleHeader = styleH},
				{type = 'mixed', label = '[[Diamètre moléculaire]]', value = 'diametreMoleculaire', styleHeader = styleH},
				{type = 'mixed', label = '[[Indice d’iode]]', value = 'indiceIode', styleHeader = styleH},
				{type = 'mixed', label = '[[Indice d’acide]]', value = 'indiceAcide', styleHeader = styleH},
				{type = 'mixed', label = '[[Indice de saponification]]', value = 'indiceSaponification', styleHeader = styleH},
                }
            },
			{
			type = 'table',
			title = {
				value = 'Propriétées physiques',
				style = {['background'] = '#f7efa8', ['border'] = '2px solid #FFFFFF', ['font-weight'] = 'bold'}
				},
        	style = {['width'] = '100%', ['font-size'] = '95%'},
			rows = {
				{type = 'mixed', label = '[[Température de transition vitreuse|T° transition vitreuse]]', value = 'TTransitionVitreuse', styleHeader = styleH},
				{type = 'mixed', label = '[[Point de fusion|T° fusion]]', value = 'fusion', styleHeader = styleH},
				{type = 'mixed', label = '[[Point d\'ébullition|T° ébullition]]', value = 'ebullition', styleHeader = styleH},
				{type = 'mixed', label = '[[Solubilité]]', value = 'solubilite', styleHeader = styleH},
				{type = 'mixed', label = '[[Polymère_en_solution#Approche de Hildebrand, paramètre de solubilité|Paramètre de solubilité δ]]', value = 'parametreSolubilite', styleHeader = styleH},
				{type = 'mixed', label = '[[Masse volumique]]', value = 'masseVolumique', styleHeader = styleH},
				{type = 'mixed', label = '[[Point d\'auto-inflammation|T° d\'auto-inflammation]]', value = 'TAutoInflammation', styleHeader = styleH},
				{type = 'mixed', label = '[[Point d’éclair]]', value = 'pointEclair', styleHeader = styleH},
				{type = 'mixed', label = '[[Limite d\'explosivité|Limites d’explosivité dans l’air]]', value = 'limitesExplosivite', styleHeader = styleH},
				{type = 'mixed', label = '[[Pression de vapeur saturante]]', value = 'pressionVapeur', styleHeader = styleH},
				{type = 'mixed', label = '[[Viscosité dynamique]]', value = 'viscosite', styleHeader = styleH},
				{type = 'mixed', label = '[[Point critique (thermodynamique)|Point critique]]', value = 'pointCritique', styleHeader = styleH},
				{type = 'mixed', label = '[[Point triple]]', value = 'pointTriple', styleHeader = styleH},
				{type = 'mixed', label = '[[Conductivité thermique]]', value = 'conductivitéThermique', styleHeader = styleH},
				{type = 'mixed', label = '[[Conductivité électrique]]', value = 'conductivitéÉlectrique', styleHeader = styleH},
				{type = 'mixed', label = '[[Vitesse du son]]', value = 'vitesseSon', styleHeader = styleH}
                }
            },
        {
        	type = 'table',
        	title = {
        		value = 'Thermochimie',
        		style = {['background'] = '#ffdead', ['border'] = '2px solid #FFFFFF', ['font-weight'] = 'bold'},
        		},
        	style = {['width'] = '100%', ['font-size'] = '95%'},
			rows = {
				{type = 'mixed', label = '[[Entropie molaire standard|S°gaz, 1 bar]]', value = 'emsGaz', styleHeader = styleH},
				{type = 'mixed', label = 'S°liquide, 1 bar', value = 'emsLiquide', styleHeader = styleH},
				{type = 'mixed', label = 'S°solide', value = 'emsSolide', styleHeader = styleH},
				{type = 'mixed', label = '[[Enthalpie standard de formation|ΔfH°gaz]]', value = 'esfGaz', styleHeader = styleH},
				{type = 'mixed', label = 'ΔfH°liquide', value = 'esfLiquide', styleHeader = styleH},
				{type = 'mixed', label = 'ΔfH°solide', value = 'esfSolide', styleHeader = styleH},
				{type = 'mixed', label = '[[Enthalpie de fusion]]', value = 'enthFus', styleHeader = styleH},
				{type = 'mixed', label = '[[Enthalpie de vaporisation]]', value = 'enthVap', styleHeader = styleH},
				{type = 'mixed', label = '[[Capacité thermique]]', value = 'capaciteTherm', styleHeader = styleH},
				{type = 'mixed', label = 'PCS', value = 'PCS', styleHeader = styleH},
				{type = 'mixed', label = 'PCI', value = 'PCI', styleHeader = styleH},
                }
            },
        {
        	type = 'table',
			title = {
				value = 'Précautions'
				},
			style = {['width'] = '100%', ['font-size'] = '95%'},
			rows = {}
	--		{
	--		type = 'table', label = '[[NFPA 704]]', value = 'NFPA704', styleHeader = styleH1, value = function() return dispNFPA704( ) end},
      --            helper.doubled_n{label = '[[Système général harmonisé|SGH]]', value = 'SGH', styleHeader = styleH1, value = function() return dispSGH( ) end},
       --           helper.doubled_n{label = '[[Accord européen relatif au transport international des marchandises dangereuses par route|ADR]]', value = 'transport', styleHeader = styleH1, value = function() return dispADR( ) end},
         --       }
        },
       {
       type = 'table',
		style = {['width'] = '100%', ['font-size'] = '95%'},
		title = {
			value = 'Unités du [[Système international d\'unités|SI]] et [[Atmosphère normalisée|CNTP]], sauf indication contraire.',
			style = {['background'] = '#ffdead', ['border'] = '2px solid #FFFFFF'}
				},
 		rows = {}
 		}
    }
}