Module:SkinData

-- local p = {}

local skinData = mw.loadData('Module:SkinData/data') local lib      = require('Module:Feature') local color    = require('Module:Color') local FN       = require('Module:Filename') local IL       = require('Module:ImageLink')

function p.chromagallery(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].chromas local header = "Chromas" if skinData[args[1]].skins[args[2] or "Original"].forms ~= nil then header = "forms" end local chromatable = {} for chromaname in pairs(t) do       table.insert(chromatable, chromaname) end table.sort(chromatable)

local champname = args[1] local skinname  = args[2] or "Original" local formatname = skinData[args[1]].skins[args[2] or "Original"].formatname local imagewidth = "100px" local s = '' s = s .. ' \n .. lib.ternary(formatname, formatname, skinname .. " " .. champname) .. " " .. header .. "'''\n" if #chromatable > 8 then imagewidth = "80px" s = s .. ' '   else s = s .. ' '   end s = s .. ' '    for i, chromaname in pairs(chromatable) do        local avail = chromaname.availability or "" local border = "" if avail == "Legacy" then border = "legacy-border" else if avail == "Rare" then border = "rare-border" else if avail == "Limited" then border = "limited-border" end end end s = s .. " " .. chromaname .. " \n" end s = s .. ' '   return s end

function p.skinpage(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local champname = args[1] local t = skinData[champname]["skins"] local availabletable = {} local legacytable   = {} local limitedtable  = {} local upcomingtable = {} local canceledtable = {}

for skinname in pairs(t) do       if t[skinname].availability == "Available" then table.insert(availabletable, {skinname, t[skinname]}) end if t[skinname].availability == "Legacy" then table.insert(legacytable,   {skinname, t[skinname]}) end if t[skinname].availability == "Limited" or t[skinname].availability == "Rare" then table.insert(limitedtable,  {skinname, t[skinname]}) end if t[skinname].availability == "Upcoming" then table.insert(upcomingtable, {skinname, t[skinname]}) end if t[skinname].availability == "Canceled" then table.insert(canceledtable, {skinname, t[skinname]}) end end

function skinitem(data) local lang = mw.language.new("en") local skinname    = data[1] local formatname  = data[2].formatname or skinname .. ' ' .. champname local champid     = skinData[champname]["id"] local skinid      = data[2].id        local cost         = data[2].cost local release     = '' local distribution = data[2].distribution if data[2].release == "N/A" then release = "N/A" else release = lang:formatDate("d-M-Y", data[2].release) end

local s = "" s = s .. ' \n    \n    \n      ' .. formatname if skinid ~= nil then s = s .. ' '       end s = s .. ' \n     ' if cost == 'N/A' then -- skip elseif cost == 10 then s = s .. tostring(IL.basic({["link"] = "Gemstone", ["text"] = cost, ["alttext"] = cost .. " Rare Gems", ["image"] = "Rare Gem.png", ["border"] = "false", ["labellink"] = "false"})).. ' / '        else s = s .. tostring(IL.basic({["link"] = "Riot Points", ["text"] = cost, ["alttext"] = cost .. " RP", ["image"] = "RP icon.png", ["border"] = "false", ["labellink"] = "false"})).. ' / '        end s = s .. lib.ternary(release == 'N/A', 'N/A', release) .. ' \n  \n  \n'

return s   end

function chroma(chromatable) s = "" if #chromatable > 0 then for i in ipairs(chromatable) do               s = s .. ' \n' .. frame:preprocess(p.chromagallery{champname, chromatable[i]}) .. '\n' end end return s   end function comp(a, b)       local a = a[2].id or -1 local b = b[2].id or -1 if a < b then return true end end local skintable = { {availabletable, text = 'Available'}, {legacytable,   text = 'Legacy Vault'}, {limitedtable,  text = 'Rare & Limited'}, {upcomingtable, text = 'Upcoming'}, {canceledtable, text = 'Canceled'} }   local s = '' for i, value in ipairs(skintable) do       table.sort(skintable[i][1], comp) local chromatable = {} if #value[1] > 0 then s = s .. (' \n==' .. value.text .. '==\n \n ') for i in pairs(value[1]) do               s = s .. skinitem(value[1][i]) if value[1][i][2].chromas then table.insert(chromatable, value[1][i][1]) end end s = s .. ' \n\n' table.sort(chromatable) s = s .. chroma(chromatable) end end s = s .. ' '   return s end

function p.getAllchampionskins(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]] end

function p.getChampionskin(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"] end

function p.getFormatname(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].formatname end

function p.getAvailability(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].availability end

function p.getDistribution(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].distribution end

function p.getCost(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].cost end

function p.getRelease(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].release end

function p.getRetired(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].retired end

function p.getEarlysale(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].earlysale end

function p.getSet(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].set end

function p.getSetlist(frame) local championtable = {} local sets = {} local hash = {} local setList = mw.html.create('ul') setList:newline for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable)

for _, championname in pairs(championtable) do       local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do           table.insert(skintable, championname) end table.sort(skintable)

for _, skinname in pairs(skintable) do           local t = skinData[championname]["skins"][skinname] if t.set ~= nil then if type(t.set) == "table" then for _, value in pairs(t.set) do                       if (not hash[value]) then table.insert(sets, value) hash[value] = true end end else if (not hash[t.set]) then table.insert(sets, t.set) hash[t.set] = true end end end end end table.sort(sets) for _, setname in pairs(sets) do       setList :tag('li') :wikitext( .. setname .. ) :done :done :newline end return setList end

function p.getSetskins(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local skinList = mw.html.create('ul') local championtable = {} local result = false skinList:newline for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable) for _, championname in pairs(championtable) do       local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do           table.insert(skintable, championname) end table.sort(skintable) for _, skinname in pairs(skintable) do           local hit = false local t = skinData[championname]["skins"][skinname] if t.set ~= nil then if type(t.set) == "table" then for _, subset in pairs(t.set) do                       if subset == args[1] then hit = true result = true end end else if t.set == args[1] then hit = true result = true end end end if hit == true then skinList :tag('li') :tag('div') :addClass('skin-icon') :attr('data-champion', championname) :attr('data-skin', skinname) :wikitext(' ' .. lib.ternary(t["formatname"] ~= nil, t["formatname"], skinname .. " " .. championname) .. '') :done :done :newline end end end

if result == false then skinList :tag('li') :wikitext('No match found for ' .. args[1] .. '.') :done :newline end return skinList end

function p.getNeweffects(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].neweffects end

function p.getNewanimations(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].newanimations end

function p.getTransforming(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].transforming end

function p.getFilter(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].filter end

function p.getNewquotes(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].newquotes end

function p.getNewvoice(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].newvoice end

function p.getExtras(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].extras end

function p.getLore(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].lore end

function p.getChromas(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].chromas end

function p.getChromacount(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].chromas local s = "" local chromatable = {} for chromaname in pairs(t) do       table.insert(chromatable, chromaname) end return #chromatable or "N/A" end

function p.getChromanames(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].chromas local s = "" local chromatable = {} for chromaname in pairs(t) do       table.insert(chromatable, chromaname) end table.sort(chromatable)

for i, chromaname in pairs(chromatable) do       if i ~= 1 then s = s .. ", " .. chromaname else s = s .. chromaname end end return s end

function p.getForms(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].forms end

function p.getFormnames(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].forms local s = "" local formtable = {} for formname in pairs(t) do       table.insert(formtable, formname) end table.sort(formtable)

for i, formname in pairs(formtable) do       if i ~= 1 then s = s .. ", " .. formname else s = s .. formname end end return s end

function p.getFormicon(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].formicon end

function p.getChromagallery(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].chromas local imagewidth = "100px" local s = "" local chromatable = {}

for chromaname in pairs(t) do       table.insert(chromatable, chromaname) end table.sort(chromatable) if #chromatable > 8 then imagewidth = "80px" end for i, chromaname in pairs(chromatable) do       local avail = chromaname.availability or "" local border = "" if avail == "Legacy" then border = "legacy-border" else if avail == "Rare" then border = "rare-border" else if avail == "Limited" then border = "limited-border" end end end s = s .. " " .. chromaname .. " \n" end return frame:preprocess(s) end

function p.getFormgallery(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].forms local s = "" local formtable = {}

for i, formname in ipairs(t) do       table.insert(formtable, formname) end

for i, formname in pairs(formtable) do       s = s .. args[1] .." " .. (string.gsub(args[2], ' ', '') or 'Original') .. " (" .. formname .. ").png|" .. formname .. "\n" end return frame:preprocess("") end

function p.getVu(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end

return skinData[args[1]].skins[args[2] or "Original"].vu end

function p.getSplashartist(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].splashartist local s = "" for i, splashartistname in ipairs(t) do       if i ~= 1 then s = s .. ", " .. splashartistname:gsub("% ", " ") else s = splashartistname end end return s end

function p.getVoiceactor(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local t = skinData[args[1]].skins[args[2] or "Original"].voiceactor local s = "" for i, voiceactorname in ipairs(t) do       if i ~= 1 then s = s .. ", " .. voiceactorname:gsub("% ", " ") else s = voiceactorname end end return s end

function p.skinlist(frame) local lang = mw.language.new( "en" ) local sdtable = mw.html.create('table') sdtable :addClass('sortable article-table nopadding sticky-header') :css('width','100%') :css('text-align','center') :newline :tag('tr') :tag('th') :css('width','26px') :done :newline :tag('th') :wikitext('Skin') :done :newline :tag('th') :tag('span') :attr('title','Availability') :wikitext('') :done :done :newline :tag('th') :tag('span') :attr('title','Release') :wikitext('') :done :done :newline :tag('th') :tag('span') :attr('title','Cost') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Voice filter') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Additional/unique quotes') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','New voiceover') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','New visual and/or sound effects') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','New animations and/or new recall animation') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Appearance can be toggled in-game [e.g. Ctrl + 5], or the skin "evolves" over the course of the game that is not part of the champion&#39;s base mechanics.') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Part of a Collection') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('span') :attr('title','Features lore') :wikitext('') :done :done :newline :tag('th') :css('width','40px') :tag('div') :attr('title','Chromas') :css('width','30px') :css('height','30px') :css('padding','5px') :wikitext('') :done :done :done :newline -- START local championtable = {} for x in pairs(skinData) do           table.insert(championtable, x)        end table.sort(championtable) for _, championname in pairs(championtable) do           local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do               table.insert(skintable, championname) end table.sort(skintable) for _, skinname in pairs(skintable) do               if (                    championname == "Akali"      and skinname == "Crimson"                     or                     championname == "Amumu"      and skinname == "Sewn Chaos"                    or                    championname == "Blitzcrank" and skinname == "Sewn Chaos"                    or                    championname == "Ryze"       and skinname == "Human"                ) then -- skip else local t = skinData[championname]["skins"][skinname] local sdnode = mw.html.create('tr') local temp = "" -- Skincircle if (skinname == "Original") then temp = "!" .. t["release"] else temp = t["release"] end sdnode :tag('td') :addClass('champion-icon') :attr('data-sort-value', championname .. temp) :attr('data-champion', championname) :attr('data-skin', skinname) :wikitext('') :done -- Skinname sdnode :tag('td') :addClass('skin-icon') :attr('data-champion', championname) :attr('data-skin', skinname) :css('text-align', 'left') :wikitext(lib.ternary(t["formatname"] ~= nil, t["formatname"], skinname .. " " .. championname)) :done -- Availability temp = "Circle.svg" if (t["availability"] == "Available") then temp = "Done.svg" end if (t["availability"] == "Legacy") then temp = "YellowLine.jpg" end if (t["availability"] == "Limited") then temp = "Not done.svg" end sdnode :tag('td') :tag('span') :attr('title', t["availability"] or 'Upcoming') :wikitext('') :done -- Release local y, m, d = t["release"]:match("(%d+)-(%d+)-(%d+)") if y == nil or m == nil or d == nil then sdnode :tag('td') :attr('data-sort-value', t["release"]) :wikitext(t["release"]) :done else sdnode :tag('td') :attr('data-sort-value', t["release"]) :wikitext(lang:formatDate('d-M-Y', t["release"])) :done end -- Cost local image = "" if (tostring(t["cost"]) == "150000") then image = "" end if (tostring(t["cost"]) == "10") then image = "" end sdnode :tag('td') :attr('data-sort-value', lib.ternary(tostring(t["cost"]) == "10", "2450", t["cost"])) :tag('span') :css('color', color.skin({t["cost"] .. ""}))                               :wikitext(image .. t["cost"]) :done :done -- Filter sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["filter"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["filter"]) ~= "nil", "", "")) :done -- Newquotes sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["newquotes"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["newquotes"]) ~= "nil", "", "")) :done -- Newvoice sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["newvoice"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["newvoice"]) ~= "nil", "", "")) :done -- Neweffects sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["neweffects"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["neweffects"]) ~= "nil", "", "")) :done -- Newanimations sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["newanimations"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["newanimations"]) ~= "nil", "", "")) :done -- Transforming sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["transforming"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["transforming"]) ~= "nil", "", "")) :done -- Set if (type(t["set"]) ~= "nil") then if (type(t["set"]) == "table") then local multisets = "" for i, current in pairs(t["set"]) do                               if i ~= 1 then multisets = multisets .. ", " .. current else multisets = multisets .. current end end sdnode :tag('td') :attr('data-sort-value', 'Multiple') :tag('span') :attr('title', multisets) :wikitext("") :done :done else sdnode :tag('td') :attr('data-sort-value', t["set"]) :tag('span') :attr('title', t["set"]) :wikitext("") :done :done end else sdnode :tag('td') :attr('data-sort-value', 0) :done end -- Transforming sdnode :tag('td') :attr('data-sort-value', lib.ternary(type(t["lore"]) ~= "nil", 1, 0)) :wikitext(lib.ternary(type(t["lore"]) ~= "nil", "", "")) :done -- Chromas if (type(t["chromas"]) == "table") then sdnode :tag('td') :addClass('chroma-icon') :attr('data-sort-value', 1) :attr('data-champion', championname) :attr('data-skin', skinname) :wikitext("") :done else sdnode :tag('td') :attr('data-sort-value', 0) :done end -- Add skin row to the table sdtable :newline :node(sdnode) end end end -- END sdtable:allDone return tostring(sdtable) end

function p.newestSkins(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local championtable = {} local releasetable = {}

for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable)

for _, championname in pairs(championtable) do       local skintable  = {} for championname in pairs(skinData[championname]["skins"]) do           table.insert(skintable, championname) end for _, skinname in pairs(skintable) do           table.insert(releasetable, {championname, skinname, skinData[championname]["skins"][skinname].release, skinData[championname]["skins"][skinname].formatname}) end end function comp(a, b)       if a[3] == "Upcoming" or b[3] == "Upcoming" then return false end if a[3] > b[3] then return true end end table.sort(releasetable, comp) local lang = mw.language.new("en") local count = tonumber(args[1]) or 7 local s = "" for i in pairs(releasetable) do       local champ      = releasetable[i][1] local skin      = releasetable[i][2] local formatname = releasetable[i][4] local cost      = p.getCost({champ, skin}) local release   = releasetable[i][3] if release > lang:formatDate("Y-m-d") then -- skip if releasedate is in the future else if skin == "Original" then -- skip else if count >= 1 then count = count - 1 s = s .. "\n" end end end end return frame:preprocess(s) end

-- helper functions function table.val_to_str ( v ) if "string" == type( v ) then v = string.gsub( v, "\n", "\\n" ) if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then return "'" .. v .. "'"   end return '"' .. string.gsub(v,'"', '\\"' ) .. '"' else return "table" == type( v ) and table.tostring( v ) or     tostring( v ) end end function table.key_to_str ( k ) if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then return k else return "[" .. table.val_to_str( k ) .. "]" end end function table.tostring( tbl ) local result, done = {}, {} for k, v in ipairs( tbl ) do   table.insert( result, table.val_to_str( v ) ) done[ k ] = true end for k, v in pairs( tbl ) do   if not done[ k ] then table.insert( result,       table.key_to_str( k ) .. "=" .. table.val_to_str( v ) ) end end return "{" .. table.concat( result, "," ) .. "}" end

function p.skinHistory(frame) local dlib         = require("Dev:Datecalc") local lang         = mw.language.new( "en" ) local championtable = {} local sdtable      = mw.html.create('table') sdtable :addClass('sortable article-table nopadding sticky-header') :css('width','100%') :css('text-align','center') :newline :tag('tr') :tag('th') :css('width','26px') :done :newline :tag('th') :wikitext('Skin') :done :newline :tag('th') :attr('data-sort-type', "isoDate") :wikitext('Date') :done :newline :tag('th') :attr('data-sort-type', "number") :wikitext('Days Ago') :done :newline :tag('th') :wikitext('In Store') :done :newline :tag('th') :wikitext('Legacy Vault') :done :newline :tag('th') :wikitext('Promotional') :done :newline :tag('th') :wikitext('Total') :done :newline :done :newline for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable) for _, championname in pairs(championtable) do       local t              = skinData[championname]["skins"] local availablecount = 0 local legacycount   = 0 local limitedcount  = 0 local result        = {"","",""} local sdnode        = mw.html.create('tr')

for skinname in pairs(t) do           if (                                 skinname == "Original"                or                championname == "Akali"      and skinname == "Crimson"                 or                 championname == "Amumu"      and skinname == "Sewn Chaos"                or                championname == "Blitzcrank" and skinname == "Sewn Chaos"                or                championname == "Ryze"       and skinname == "Human"            ) then -- skip else if t[skinname].availability == "Available" then availablecount = availablecount + 1 end if t[skinname].availability == "Legacy" then legacycount   = legacycount    + 1 end if t[skinname].availability == "Limited" then limitedcount  = limitedcount   + 1 end if t[skinname].release > result[2] then result[1] = skinname result[2] = t[skinname].release result[3] = t[skinname].formatname end end end sdnode :tag('td') :addClass('champion-icon') :attr('data-sort-value', championname) :attr('data-champion', championname) :attr('data-skin', result[1]) :wikitext('') :done -- Skinname sdnode :tag('td') :addClass('skin-icon') :attr('data-champion', championname) :attr('data-skin', result[1]) :css('text-align', 'left') :wikitext(lib.ternary(result[3] ~= nil, result[3], result[1] .. " " .. championname)) :done local y, m, d = result[2]:match("(%d+)-(%d+)-(%d+)") if y == nil or m == nil or d == nil then sdnode :tag('td') :attr('data-sort-value', result[2]) :wikitext(result[2]) :done :tag('td') :wikitext(result[2]) :done else sdnode :tag('td') :attr('data-sort-value', result[2]) :wikitext(lang:formatDate('d-M-Y', result[2])) :done :tag('td') :wikitext(dlib.main{"diff", lang:formatDate('Y-m-d'), result[2]}) :done end sdnode :tag('td') :wikitext(availablecount) :done sdnode :tag('td') :wikitext(legacycount) :done sdnode :tag('td') :wikitext(limitedcount) :done sdnode :tag('td') :wikitext(availablecount + legacycount + limitedcount) :done

-- Add skin row to the table sdtable :newline :node(sdnode) end -- return "" return sdtable end

function p.skinCatalog(frame) local dlib         = require("Dev:Datecalc") local lang         = mw.language.new( "en" ) local championtable = {} local sdtable      = mw.html.create('table') sdtable :addClass('sortable article-table novpadding hcpadding sticky-header') :css('width','100%') :css('text-align','center') :css('font-size','12px') :newline :tag('tr') :tag('th') :css('font-size','12px') :css('width','140x') :wikitext('Champion') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "number") :wikitext(' Available ') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "number") :wikitext(' Legacy Vault ') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "number") :wikitext(' Rare ') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "number") :wikitext('Unavailable') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "number") :wikitext('Total') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "isoDate") :wikitext('Last Skin') :done :newline :tag('th') :css('font-size','12px') :attr('data-sort-type', "number") :wikitext('Days Ago') :done :newline :done :newline for x in pairs(skinData) do       table.insert(championtable, x)    end table.sort(championtable) for _, championname in pairs(championtable) do       local t              = skinData[championname]["skins"] local availablecount = 0 local availablecircles = "" local legacycount   = 0 local legacycircles = "" local limitedcount  = 0 local rarecircles = "" local rarecount  = 0 local limitedcircles = "" local result        = {"","",""} local sdnode        = mw.html.create('tr') local border        = "" local skintable     = {} for skinname in pairs(t) do           if (                                 skinname == "Original"                or                championname == "Akali"      and skinname == "Crimson"                 or                 championname == "Amumu"      and skinname == "Sewn Chaos"                or                championname == "Blitzcrank" and skinname == "Sewn Chaos"                or                championname == "Ryze"       and skinname == "Human"            ) then -- skip else table.insert(skintable, skinname) end end table.sort(skintable, function(a, b) return t[a].release' end if t[skinname].availability == "Legacy" then legacycount   = legacycount    + 1 legacycircles = legacycircles .. '' end if t[skinname].availability == "Rare" then rarecount   = rarecount    + 1 rarecircles = rarecircles .. '' end if t[skinname].availability == "Limited" then limitedcount  = limitedcount   + 1 limitedcircles = limitedcircles .. '' end if t[skinname].release > result[2] then result[1] = skinname result[2] = t[skinname].release result[3] = t[skinname].formatname end end sdnode :tag('td') :addClass('skin-icon') :attr('data-sort-value', championname) :attr('data-champion', championname) :attr('data-skin', "Original") :css('text-align', 'left') :wikitext(' ' .. championname) :done -- Available skins sdnode :tag('td') :addClass('icon_list') :attr('data-sort-value', availablecount) :css('text-align', 'left') :css('background-color', '#0a1827') :wikitext(availablecircles) :done -- Legacy skins sdnode :tag('td') :addClass('icon_list') :attr('data-sort-value', legacycount) :css('text-align', 'left') :wikitext(legacycircles) :done -- Rare skins sdnode :tag('td') :addClass('icon_list') :attr('data-sort-value', rarecount) :css('text-align', 'left') :css('background-color', '#0a1827') :wikitext(rarecircles) :done -- Limited skins sdnode :tag('td') :addClass('icon_list') :attr('data-sort-value', limitedcount) :css('text-align', 'left') :wikitext(limitedcircles) :done -- Total sdnode :tag('td') :wikitext(availablecount + legacycount + rarecount + limitedcount) :done

-- Last Skin local y, m, d = result[2]:match("(%d+)-(%d+)-(%d+)") if y == nil or m == nil or d == nil then sdnode :tag('td') :addClass('skin-icon') :attr('data-sort-value', result[2]) :attr('data-champion', championname) :attr('data-skin', result[1]) :wikitext(result[2]) :done :tag('td') :wikitext(result[2]) :done else sdnode :tag('td') :addClass('skin-icon') :attr('data-sort-value', result[2]) :attr('data-champion', championname) :attr('data-skin', result[1]) :wikitext(lang:formatDate('d-M-Y', result[2])) :done :tag('td') :wikitext(dlib.main{"diff", lang:formatDate('Y-m-d'), result[2]}) :done end

-- Add skin row to the table sdtable :newline :node(sdnode) end -- return "" return sdtable end

return p

-- --