Modul:Musikcharts/certifications
| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | |||
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
local p = {}
-- require local css classes
local cssclass = require ("Module:Musikcharts/localclasses")
p.certicon = function (frame, certification, icontype, size)
local certtable = {
["S"] = {"silver", "silber"},
["G"] = {"gold", "gold"},
["P"] = {"platinum", "platin"},
["D"] = {"diamond", "diamant"}
}
local numbers = { "", "Double", "Triple", "Quadruple", "Quintuple", "Sextuple", "Septuple", "Octuple", "Nonuple", "Decuple" }
local numbers2 = { "", "Doppel", "Drei", "Vier", "Fünf", "Sechs", "Sieben", "Acht", "Neun", "Zehn", "Elf", "Zwölf" }
local certraw = certification or frame.args[1]
local icontype = icontype or frame.args["icontype"]
-- delete strip markers
if certraw then
certraw = mw.text.unstrip( certraw )
else
certraw = ""
end
local icon
if string.match (certraw, "%[%[Datei:") or string.match (certraw, "%[%[File:") or string.match (certraw, "%[%[Bild:") or string.match (certraw, "<img") then
icon = certraw
end
local certraw2
if string.match (certraw, ".%+") then
certraw, certraw2 = string.match (certraw, "(.+)%+(.+)")
end
-- find brackets
local brackets
local brackets2
if string.match (certraw, ".+%(") then
certraw, brackets = string.match (certraw, "(.+)%((.-)%)")
end
if certraw2 then
if string.match (certraw2, ".+%(") then
certraw2, brackets2 = string.match (certraw2, "(.+)%((.-)%)")
end
end
local number
local number2
if string.match(certraw, "%d+") then
number = string.match(certraw, "(%d+)")
else
number = 1
end
if certraw2 then
number2 = string.match(certraw2, "(%d+)") or 1
end
local certname
local certname2
for key, value in pairs (certtable) do
if string.match (certraw, key) and not string.match (certraw, "%(") then
certname = key
end
if certraw2 then
if string.match (certraw2, key) and not string.match (certraw2, "%(") then
certname2 = key
end
end
end
local oldicon
local tooltip
local tooltip2
local newicon
local texticon
local supicon
local caption
local caption2
local capcertname
local capcertname2
if certtable[certname] then
capcertname = string.gsub(certtable[certname][2], "^%l", string.upper)
else
capcertname = certname
end
if certtable[certname2] then
capcertname2 = string.gsub(certtable[certname2][2], "^%l", string.upper)
else
capcertname2 = certname2 or ""
end
-- direct files
local deficon
if not certtable[certname] then
deficon = certraw
else
-- create tooltip and caption
if tonumber(number) > 1 then
if tonumber(number) == 2 then
tooltip = numbers2[tonumber(number)] .. certtable[certname][2]
elseif tonumber(number) < 13 then
tooltip = numbers2[tonumber(number)] .. "fach" .. certtable[certname][2]
else
tooltip = number .. "-fach-" .. capcertname
end
caption = number .. "× " .. capcertname
else
tooltip = capcertname
caption = tooltip
end
if brackets then
tooltip = tooltip .. " (" .. brackets .. ")"
caption = caption .. " (" .. brackets .. ")"
end
if certraw2 then
if tonumber(number2) > 1 then
if tonumber(number2) == 2 then
tooltip2 = numbers2[tonumber(number2)] .. certtable[certname2][2]
elseif tonumber(number2) < 13 then
tooltip2 = numbers2[tonumber(number2)] .. "fach" .. certtable[certname2][2]
else
tooltip2 = number2 .. "-fach-" .. capcertname2
end
caption2 = number2 .. "× " .. capcertname2
else
tooltip2 = capcertname2
caption2 = tooltip2
end
end
if brackets2 then
tooltip2 = tooltip2 .. " (" .. brackets2 .. ")"
caption2 = caption2 .. " (" .. brackets2 .. ")"
end
if tooltip2 then
tooltip = tooltip .. " + " .. tooltip2
end
if caption2 then
caption = caption .. " + " .. caption2
end
-- create old files
local certfile = ""
local certfile2 = ""
--[[ if tonumber(number) > 1 then ONLY SINGLE FILES
if tonumber(number) < 11 then
certfile = numbers[tonumber(number)] .. " "
else
certfile = "Decuple "
end
end
if certraw2 then
if tonumber(number2) > 1 then
if tonumber(number2) < 11 then
certfile2 = numbers[tonumber(number2)] .. " "
else
certfile2 = "Decuple "
end
end
end ]]
certfile = certfile .. certtable[certname][1] .. " record icon.svg"
if certraw2 and certtable[certname2] then
certfile = certfile .. "|15px|link=]][[File:" .. certfile2 .. certtable[certname2][1] .. " record icon.svg"
end
-- create old icon style
oldicon = "<div class='" .. cssclass.certcontainer .. "'>[[File:" .. certfile .. "|15px|link=|alt=" .. tooltip .. "]]"
oldicon = oldicon .. "<span class='" .. cssclass.certtooltip .. "'>" .. tooltip .."<i></i></span></div>"
-- create new icon style
if not size then
size = "17"
end
newicon = "<div class='" .. cssclass.certcontainer .. "'><div class='" .. cssclass.certification .. "'>[[File:" .. certtable[certname][1] .. " record icon2.svg|"
newicon = newicon .. size .. "px|link=|alt=" .. tooltip .. "]]"
if tonumber(number) then
if tonumber(number) > 1 then
newicon = newicon .. "<div class='" .. cssclass.certnumber .. "'"
if tonumber(number2) then
newicon = newicon .. " style='left:50%; z-index:10;'"
end
newicon = newicon .. ">×" .. number .. "</div>"
end
end
newicon = newicon .. "</div>"
if certraw2 and certtable[certname2] then
newicon = newicon .. "<div class='" .. cssclass.certification .. "' style='margin-left:-8px'>[[File:" .. certtable[certname2][1] .. " record icon2.svg|"
newicon = newicon .. size .. "px|link=|alt=" .. tooltip .. "]]"
if tonumber(number2) then
if tonumber(number2) > 1 then
newicon = newicon .. "<div class='" .. cssclass.certnumber .. "'>×" .. number2 .. "</div>"
end
end
newicon = newicon .. "</div>"
end
newicon = newicon .. "<span class='" .. cssclass.certtooltip .. "'>" .. tooltip .."<i></i></span></div>"
-- create sup icon style
supicon = "<div class='" .. cssclass.certcontainer .. "'><div class='" .. cssclass.certification .. "'>[[File:" .. certtable[certname][1] .. " record icon.svg|15px|link=|alt=" .. tooltip .. "]]"
if tonumber(number) then
if tonumber(number) > 1 then
supicon = supicon .. "<div class='" .. cssclass.certnumber .. "'"
if tonumber(number2) then
supicon = supicon .. " style='left:50%; z-index:10;'"
end
supicon = supicon .. ">×" .. number .. "</div>"
end
end
supicon = supicon .. "</div>"
if certraw2 and certtable[certname2] then
supicon = supicon .. "<div class='" .. cssclass.certification .. "' style='margin-left:-5px'>[[File:" .. certtable[certname2][1] .. " record icon.svg|15px|link=|alt=" .. tooltip .. "]]"
if tonumber(number2) then
if tonumber(number2) > 1 then
supicon = supicon .. "<div class='" .. cssclass.certnumber .. "'>×" .. number2 .. "</div>"
end
end
supicon = supicon .. "</div>"
end
supicon = supicon .. "<span class='" .. cssclass.certtooltip .. "'>" .. tooltip .."<i></i></span></div>"
-- create text icon
texticon = "[[File:" .. certfile .. "|15px|link=]] " .. caption
end
local ret = ""
if icon then
ret = ret .. "<div style='display:inline-block;'>" .. icon .. "</div>"
elseif deficon then
ret = ret .. "<div style='display:inline-block;'>" .. deficon .. "</div>"
elseif icontype == "text" then
ret = texticon
elseif icontype == "sup" then
ret = supicon
elseif icontype == "new" then
ret = ret .. newicon
elseif icontype == "old" then
ret = ret .. oldicon
else
ret = ret .. supicon
end
return ret
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.
- 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:
- 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.
- 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.
- 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.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.