Module:GHS pictogram

Documentation for this module may be created at Module:GHS pictogram/doc

Documentation for this module may be created at Module:GHS pictogram/doc

local p = {}

local symbols = {
	["1"] = {"GHS-pictogram-explos.svg", "GHS01: Explosive"},
	["exploding bomb"] = {"GHS-pictogram-explos.svg", "GHS01: Explosive"},

	["2"] = {"GHS-pictogram-flamme.svg", "GHS02: Flammable"},
	["flame"] = {"GHS-pictogram-flamme.svg", "GHS02: Flammable"},

	["3"] = {"GHS-pictogram-rondflam.svg", "GHS03: Oxidizing"},
	["flame over circle"] = {"GHS-pictogram-rondflam.svg", "GHS03: Oxidizing"},

	["4"] = {"GHS-pictogram-bottle.svg", "GHS04: Compressed Gas"},
	["gas cylinder"] = {"GHS-pictogram-bottle.svg", "GHS04: Compressed Gas"},

	["5"] = {"GHS-pictogram-acid.svg", "GHS05: Corrosive"},
	["corrosion"] = {"GHS-pictogram-acid.svg", "GHS05: Corrosive"},

	["6"] = {"GHS-pictogram-skull.svg", "GHS06: Toxic"},
	["skull and crossbones"] = {"GHS-pictogram-skull.svg", "GHS06: Toxic"},

	["7"] = {"GHS-pictogram-exclam.svg", "GHS07: Exclamation mark"},
	["exclamation mark"] = {"GHS-pictogram-exclam.svg", "GHS07: Exclamation mark"},

	["8"] = {"GHS-pictogram-silhouette.svg", "GHS08: Health hazard"},
	["health hazard"] = {"GHS-pictogram-silhouette.svg", "GHS08: Health hazard"},

	["9"] = {"GHS-pictogram-pollu.svg", "GHS09: Environmental hazard"},
	["environment"] = {"GHS-pictogram-pollu.svg", "GHS09: Environmental hazard"},
}

function p.main(frame)
	local args = frame:getParent().args
	local output = {}

	for i = 1, 9 do
		local val = args[i]
		if val and mw.text.trim(val) ~= "" then
			val = mw.text.trim(val):lower()
			local symbol, maxLen = nil, 0

			for k, data in pairs(symbols) do
				if val:find(k, 1, true) and #k > maxLen then
					symbol, maxLen = data, #k
				end
			end

			if symbol then
				local function getOpt(name, default)
					local v = args[name .. i]
					if not v or mw.text.trim(v) == "" then v = args[name] end
					return (not v or mw.text.trim(v) == "") and default or mw.text.trim(v)
				end

				table.insert(
					output,
					string.format("[[File:%s|%s|%s]]", symbol[1], getOpt("size", "50px"), getOpt("alt", symbol[2]))
				)
			else
				table.insert(
					output,
					"[[Category:Pages using GHS pictogram with unknown parameters]]"
				)
			end
		end
	end

	return table.concat(output)
end

return p


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.