Module:Geological range explained

--

local periods =

local colors =

local nameToYear = local yearToName = local startToEnd =

local function nStep(t, year, i) if type(t)

"table" then for _,x in ipairs(t) do local preYear = year if type(x)

"table" then table.insert(startToEnd[i],) year = tonumber(x[2]) and x[2] or year if year

preYear then table.insert(yearToName[#yearToName], x[1]) else table.insert(yearToName,) end nameToYear[x[1]] = year if x.aliases then for _,alias in ipairs(x.aliases) do nameToYear[alias] = year table.insert(startToEnd[i][#startToEnd[i]], alias) table.insert(yearToName[#yearToName], alias) end end end nStep(x, year, i+1) end endend

nStep(periods, "", 1)

for _,nextP in ipairs(startToEnd) do for k,period in ipairs(nextP) do for _,name in ipairs(period) do startToEnd[name] = nextP[k+1] and nextP[k+1][1] or "present" end endend

local function findandrep(text, one, two) return mw.ustring.sub(mw.ustring.gsub(tostring(text), one, two), 1, -1)end

local function round(num, rou) return num and tonumber(string.format("%." .. (rou or 0) .. "f", num))end

local function getByTable(text, t) text = mw.getContentLanguage:lc(text) for _,inside in pairs(t) do for i=2,30 do if inside[i] and inside[i]

text then return inside[1] end end endend

local function periodID(id) local text = mw.getContentLanguage:lc(tostring(id)) local found = if found[text] then text = found[text] else text = findandrep(text, "-", "") text = findandrep(text, "%f[%w]palaeo", "paleo") text = findandrep(text, "%f[%w]early%f[%W]", "lower") text = findandrep(text, "%f[%w]mid%f[%W]", "middle") text = findandrep(text, "%f[%w]late%f[%W]", "upper") end return textend

local function periodStart(period, rou) return period and round(nameToYear[periodID(period)], rou or 5)end

local function periodEnd(period, rou) return period and periodStart(startToEnd[periodID(period)], rou or 5)end

local function periodColor(period) return getByTable(mw.getContentLanguage:lc(period), colors)end

local function mark(typ, num1, num2, num3) local g, h = typ.width, typ.all local result if (num1-num2)>5 then result = "

" if num3 then else result = result .. "

" end else if num3 then else result = "

" .. "↓

" end end return resultend

local function bar(typ, val1, val2, val3) local g, h = typ.width, typ.all local gen = g

250 and (val3 and "6" or "12px; top:6").."px" or "100%" return "

"..(val2 and ""..val2.."" or "").."

"end

local function compare(year, num) local period for k,inside in pairs(yearToName) do if num

1 then if year <= inside[1] then period = inside[2] end elseif num

2 then if year >= inside[1] and (yearToName[k-1] and year <= yearToName[k-1][1]) then if year

yearToName[k-1][1] then period = yearToName[k-1][2] else period = inside[2] end end end end return "" or "") .. mw.getContentLanguage:ucfirst(period) .. ""end

local function _show(veri) local result = local year1 = tonumber(veri[1]) or periodStart(veri[1]) local year2 = tonumber(veri[2]) or periodEnd(veri[2]) or periodEnd(veri[1]) or tonumber(veri[1]) local year1_e = tonumber(veri["earliest"]) or periodStart(veri["earliest"]) or year1 local year2_e = tonumber(veri["latest"]) or periodEnd(veri["latest"]) or year2 local typ = year1 >= 650 and or table.insert(result, "

") if veri["prefix"] then table.insert(result, veri["prefix"]) end table.insert(result, ((veri[3] or veri["text"]) or (tostring(year1) .. (year2 and "-"..tostring(year2) or "") .. " Ma")) .. (veri[1] and "
" or "") .. (tonumber(veri[1]) and compare(year1, 1) or veri[1]) .. (veri[2] and "-" or "") .. ((tonumber(veri[2])) and compare(year2, 2) or (veri[2] or "")) )

local ref = veri["ref"] or veri["reference"] or veri["refs"] or veri["references"] if ref then table.insert(result, ref) end table.insert(result, " ") local ps = veri["PS"] or veri["ps"] if ps then table.insert(result, ps) end table.insert(result, "

") table.insert(result, "

") if typ.all

4600 then table.insert(result, bar(typ, "Hadean")) table.insert(result, bar(typ, "Hadean", "

Had'n", 1)) table.insert(result, bar(typ, "eoarchean")) table.insert(result, bar(typ, "Paleoarchean")) table.insert(result, bar(typ, "Mesoarchean")) table.insert(result, bar(typ, "neoarchean")) table.insert(result, bar(typ, "archean", "Archean", 1)) table.insert(result, bar(typ, "paleoproterozoic")) table.insert(result, bar(typ, "mesoproterozoic")) table.insert(result, bar(typ, "neoproterozoic")) table.insert(result, bar(typ, "proterozoic", "Proterozoic", 1)) table.insert(result, bar(typ, "Paleozoic")) table.insert(result, bar(typ, "Mesozoic")) table.insert(result, bar(typ, "Cenozoic")) table.insert(result, bar(typ, "phanerozoic", "Pha.", 1)) else table.insert(result, "

" .."PreЄ

") table.insert(result, bar(typ, "cambrian", "Є")) table.insert(result, bar(typ, "ordovician", "O")) table.insert(result, bar(typ, "silurian", "S")) table.insert(result, bar(typ, "devonian", "D")) table.insert(result, bar(typ, "carboniferous", "C")) table.insert(result, bar(typ, "permian", "P")) table.insert(result, bar(typ, "triassic", "T")) table.insert(result, bar(typ, "jurassic", "J")) table.insert(result, bar(typ, "cretaceous", "K")) table.insert(result, bar(typ, "paleogene", "Pg")) table.insert(result, bar(typ, "neogene", "N")) end

table.insert(result, "

") if year1 and year2 then table.insert(result, mark(typ, year1_e, year2_e, 42)) end table.insert(result, mark(typ, year1, year2)) table.insert(result, "

\n") return table.concat(result)end

local function show(frame) return _show(frame:getParent.args)end

return