Modul:USCGlist
Die Funktionen sind als Kommentare innerhalb des Sourcecodes beschrieben.Siehe dazu auch die Vorlagen-Doku
--[=[ USCGlink Version 1, 2021-10-27
Ausgabe einen Links, Aufruf PDF-Liste I - VII, internationalisiert
--]=]
p = {}
local uscgen = {
-- Originaltitel
[1] = "Light List, Volume I, Atlantic Coast, St. Croix River, Maine to Shrewsbury River, New Jersey",
[2] = "Light List, Volume II, Atlantic Coast, Shrewsbury River, New Jersey to Little River, South Carolina",
[3] = "Light List, Volume III, Atlantic Coast, Little River, South Carolina to Econfina River, Florida",
[4] = "Light List, Volume IV, Gulf of Mexico",
[5] = "Light List, Volume V, Mississippi River System",
[6] = "Light List, Volume VI, Pacific Coast and Pacific Islands",
[7] = "Light List, Volume VII, Great Lakes"
}
local uscgde = {
[1] = "US-Leuchtfeuerliste, Band I, Atlantikküste, St. Croix River, Maine bis Shrewsbury River, New Jersey",
[2] = "US-Leuchtfeuerliste, Band II, Atlantikküste, Shrewsbury River, New Jersey bis Little River, South Carolina",
[3] = "US-Leuchtfeuerliste, Band III, Atlantikküste, Little River, South Carolina bis Econfina River, Florida",
[4] = "US-Leuchtfeuerliste, Band IV, Golf von Mexiko",
[5] = "US-Leuchtfeuerliste, Band V, Mississippi-Fluss-System",
[6] = "US-Leuchtfeuerliste, Band VI, Pazifikküste und Pazifikinseln",
[7] = "US-Leuchtfeuerliste, Band VII, Große Seen"
}
-- https://www.navcen.uscg.gov/pdf/lightLists/LightList%20V5.pdf#page=
local url1 = "[https://www.navcen.uscg.gov/pdf/lightLists/LightList%20V"
local url2 = ".pdf#page="
local url3de = "]'' (PDF) [[United States Coast Guard|USCG]] (englisch)"
local url3 = "]'' (PDF) (= ''[[Leuchtfeuerliste der US-Küstenwache|Light List]]'') [[United States Coast Guard]] "
local function toroman(nr) -- wandelt arabische in römische Ziffern
local ret = ""
nr = tonumber(nr)
if nr == 1 then
ret = "I-"
elseif nr == 2 then
ret = "II–"
elseif nr == 3 then
ret = "III–"
elseif nr == 4 then
ret = "IV–"
elseif nr == 5 then
ret = "V–"
elseif nr == 6 then
ret = "VI–"
elseif nr == 7 then
ret = "VII–"
else
ret = ""
end
return ret
end
local function tu(a, z) -- wandelt 'a' in Versialen und gibt 'z' Anfangsbuchstabe/n zurück
return string.sub(string.upper(a or ""), 1, z or 1)
end -- function tu(a, z)
function split(s) -- Teilt kombinierte Nummern wie 7-34567 oder sogar IV1234 auf
s = tu(s, -1) or ""
local a, c
local b = 0
if #s > 1 then
a, b = string.match(s .. "?", "([1-7IV]+)[%s%D]*([%s%.%d]*)")
if a == "I" then
a = 1
elseif a == "II" then
a = 2
elseif a == "III" then
a = 3
elseif a == "IV" then
a = 4
elseif a == "V" then
a = 5
elseif a == "VI" then
a = 6
elseif a == "VII" then
a = 7
end -- if a ==
else -- if #s
a = s
end -- if #s
return tonumber(a) or 0, (b or 0)
end -- function split(s)
-- Übergeben werden 1=volume, [2|j|y=year], [3|p|s=page], [i=titel],[n=nummer],[l=USCGlabel]
function p.uscg(frame)
local lang = "DE" -- for Germaan version only!
local page, year, OK = 1, 1, 1
local USCGlabel, USCGnr, VOLnr
local titel = ""
-- Abfrage der Spracheintellung, falls anders als DE
frame = mw.getCurrentFrame()
local lang = tu(mw.getContentLanguage():getCode(), 2)
local frame = frame:getParent()
-- Abfrage der Prameter
for key, val in pairs(frame.args) do -- Parameter sammeln und zuordnen
key = tu(key)
if key == "1" or key == "V" then
VOLnr, listnr = split(val) -- macht Kombis wie wie 5-20985, 5/20985, V,20985 möglich
USCGnr = tonumber(listnr) or 0
if USCGnr < 1 then
USCGnr = nil
end
elseif key == "2" or key == "Y" or key == "J" then
year = tonumber(val) or 0
elseif key == "3" or key == "P" or key == "S" then
page = tonumber(val) or 1
elseif key == "U" or key == "N" then -- USCG-Nummmer
USCGnr = tonumber(val)
elseif key == "L" then -- Nummer mit Label
USCGlabel = "USCG: "
elseif key == "I" then -- Internationale Version
lang = tu(val, 1)
elseif key == "P" then -- Seitennummer erforderlich
page = val
end -- if key 1 2 3 ...
end -- for key, val
--[[ Div. Fehler und Logikkontrollen. Reihenfolge wichtig
Hier, da übergebene Parameter keine nachvollziehbare Reihenfolge haben --]]
if USCGlabel then
USCGlabel = USCGlabel .. toroman(VOLnr) .. (USCGnr or "")
else
USCGlabel = toroman(VOLnr) .. (USCGnr or "")
end
----
if USCGnr or direct then
return "[https://www.navcen.uscg.gov/pdf/lightLists/LightList%20V" ..
(VOLnr or 0) .. ".pdf#page=" .. (page or 0) .. " " .. (USCGlabel or "?") .. "]"
end
----
if year < 2022 and year > 2002 then -- geht nicht vor Gründung und nicht für Zukunft
year = ", " .. year
else
year = " "
end -- if year
----
if lang == "DE" then
if tonumber(page) > 0 then
pagenr = " S. " .. page .. " "
end -- gibt S. 123
USCGtitel = uscgde
url3 = url3de
else
USCGtitel = uscgen
end -- if lang == "DE"
-- allgemeiner Link auf Auswahlseite
if not VOLnr or tonumber(VOLnr) < 1 or tonumber(VOLnr) > 7 then
if USCGlabel then
return "''[https://www.navcen.uscg.gov/?pageName=lightLists Light List (Annual Publication)]'' (PDF) [[United States Coast Guard|USCG]] (englisch)"
else
return "''[https://www.navcen.uscg.gov/?pageName=lightLists Light List (Annual Publication)]'' [[United States Coast Guard|USCG]]"
end
else
titel = USCGtitel[VOLnr]
end -- if not VOLnr
-- Reste raus und FINITO!
return "''" .. url1 .. VOLnr .. url2 .. page .. " " .. titel .. url3 .. year .. (pagenr or "") .. (USCGnr or "")
end -- function p.uscg(frame)
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.