Module:Userbox

From BitchSpace
Revision as of 02:01, 20 February 2024 by IseeL (talk | contribs) (Created page with "local p = {} function p.main(frame) -- pass frame args wholly to getBox local args = frame:getParent().args return p.getBox(args) end function p.getBox(args) local float = args["float"] or "left" local borderWidth = args["border-width"] or args["border-s"] or 1 local borderColor = args["border-color"] or args["border-c"] or args["id-c"] or "#999" local infoBackground = args["info-background"] or args["info-c"] or "#EEE" local logoBackground...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

local p = {}

function p.main(frame) -- pass frame args wholly to getBox

   local args = frame:getParent().args
   return p.getBox(args)

end

function p.getBox(args)

   local float = args["float"] or "left"
   local borderWidth = args["border-width"] or args["border-s"] or 1
   local borderColor = args["border-color"] or args["border-c"] or args["id-c"] or "#999"
   local infoBackground = args["info-background"] or args["info-c"] or "#EEE"
   local logoBackground = args["logo-background"] or args["id-c"] or "#DDD"
   local logoSize = args["logo-size"] or args["id-s"] or 14
   local logoColor = args["logo-color"] or args["id-fc"] or "black"
   local logoText = args["logo"] or args["id"] or "id"
   local infoSize = args["info-size"] or args["info-s"] or 8
   local infoColor = args["info-color"] or args["info-fc"] or "black"
   local infoText = args["info"] or "info"
   
   local ruserbox = mw.html.create("div")
   ruserbox:attr("id", "ruserboxx")
   ruserbox:css("float", float)
   ruserbox:css("border", borderWidth .. "px solid " .. borderColor)
   ruserbox:css("margin", "1px")
   local table = mw.html.create("table")
   table:attr("cellspacing", "0")
   table:css("width", "238px")
   table:css("background", infoBackground)
   local row = mw.html.create("tr")
   local logoCell = mw.html.create("td")
   logoCell:css("width", "45px")
   logoCell:css("height", "45px")
   logoCell:css("background", logoBackground)
   logoCell:css("text-align", "center")
   logoCell:css("font-size", logoSize .. "pt")
   logoCell:css("color", logoColor)
   logoCell:wikitext("" .. logoText .. "")
   local infoCell = mw.html.create("td")
   infoCell:css("font-size", infoSize .. "pt")
   infoCell:css("padding", "4pt")
   infoCell:css("line-height", "1.25em")
   infoCell:css("color", infoColor)
   infoCell:wikitext(infoText)
   row:node(logoCell)
   row:node(infoCell)
   table:node(row)
   ruserbox:node(table)
   return tostring(ruserbox)

end

return p