Module:Card

require('Module:WikiLink')

local p = {} local metahtml = getmetatable(mw.html.create).__index local params = { colBack = "#17111b"; colBorder = "#000000"; colLight = "#70547c"; cardHeight = 150; } function metahtml:_card(args) local size = tonumber(args.size:match'(%d+)') or 144 local box = self:tag('div') box:addClass('loliCard') :cssText('position:relative;display:inline-flex;flex-direction:column;margin:5px;font-size:15px;font-family:"Franklin Gothic";line-height:100%;padding-right:' .. tonumber((params.cardHeight / 2)+5) ..'px') box:tag('div'):addClass('card-left') :cssText('position:absolute;top:30px;left:5px;display:flex;flex-flow:column wrap') :wikitext(args.left) box:tag('div'):addClass('card-right') :cssText('position:absolute;top:30px;right:5px;display:flex;flex-flow:column wrap;align-items:flex-end') :wikitext(args.right)

box:tag('div'):addClass('card-rightSeries') :cssText('display:flex;flex-direction:column;overflow:hidden;word-break:break-word;outline:2px solid' .. params.colBorder .. ';position:absolute;top:0%;right:0%;width:' .. tonumber((params.cardHeight / 2)+5) ..'px;height:50%; align-items:center;justify-content:center; text-align:center;background:' .. params.colBack .. ';color:#eee;') :wikitext(args.rightSeries) box:tag('div'):addClass('card-rightName') :cssText('display:flex;overflow:hidden;outline:2px solid' .. params.colBorder .. ';position:absolute;top:50%;right:0%;width:' .. tonumber((params.cardHeight / 2)+5) ..'px;height:50%;align-items:center;justify-content:center;text-align:center;background:' .. params.colBack .. ';color:#eee;') :wikitext(args.rightName)

if args.bottom and args.bottom~='' then box:tag('div'):addClass('card-bottom') :cssText('outline:2px solid' .. params.colBorder .. ';text-align:center;color:#17111b;background:#eee;height:150px;object-fit:cover') :wikitext(args.bottom) end return self end

function wikilink(strArg) local str = strArg local table = strSplit(str,",\n") local res = "" for i,ind in ipairs(table) do       local indSub = ind:gsub("&#8203;", ""):gsub("&shy;", ""):gsub("­",""):gsub("",""):gsub("",""):gsub(" -%(.*%) -","") local wikiString = " ".. ind .." " mw.logObject(wikiString) if (i > 1) then res = res .. ", " .. wikiString else res = res .. wikiString end end mw.logObject(res) return res end

function metahtml:Card(args, style) local arg2 = {} style = style or {} arg2.size = style.Size or '144px' arg2.rightSeries = wikilink(args.Series) arg2.rightName = ' '.. args.Name ..' ' arg2.right = args.Right~='' and args.Right or nil arg2.bottom = args.Image~='' and "" or "" return self:_card(arg2) end

function p.Card(args, style) return mw.html.create:Card(args, style) end