FANDOM


local p = {}
 
local args = {}
local lyricsbox
 
----------------
--
----------------
 
local function processLBT(titlecell)
	if not args.template then return end
 
	titlecell:wikitext([[{| style="border:1px solid #999; background-color:rgb(190, 190, 190); width: auto;" class="mw-collapsible"
	  |-
    ! style="background-color:grey;" |]]
		  .. mw.getCurrentFrame():expandTemplate({
			  title = 'lbt',
			  args = { args.template, ['type'] = 'navbox' }
		  }) .. '|}')
end
 
--- Processes the main title
local function processTitle()
	local titlerow = mw.html.create('tr'):addClass('lyricsbox-title')
	local titlecell = mw.html.create('th'):attr('colspan',colspan):attr('scope','col')
 
	titlecell:wikitext(args.title or '{{PAGENAME}}')
 
	-- Coloring
	local hasTemplate = args.template ~= nil
	local hasState = not args.state or args.state ~= 'plain'
 
	if hasTemplate ~= hasState then
		if hasTemplate then
			titlecell:css('background-color','grey')
		end
	end
 
	titlerow:node(titlecell)
  lyricsboxbox:node(titlerow)
end
 
local function processRows()
	sections = {}
	for i=1,#rownums do
		local num = rownums[i]
		if not skiprows[num] then
			processHeader(num)
		end
	end
end
 
local function getArgNums(args)
  local nums = {}
  for k, v in pairs(args) do
    if type(k) == 'number' and
      k >= 1 and
      math.floor(k) == k and
      type(v) == 'string' and
      mw.ustring.match(v, '%S') then
      table.insert(nums, k)
    end
  end
  table.sort(nums)
  return nums
end
 
local function preProcessArgs(frame)
	local tmp = {}
 
	if frame == mw.getCurrentFrame() then
		tmp = frame:getParent().args
	else
		tmp = frame
	end
 
	-- Storage tables
	local nums = {}
 
	-- Loop over all the args
	for k,v in pairs(tmp) do
		-- Skip empty args, which are useless
		if v ~= '' then
			local cat,num = tostring(k):match('^(%a+)([1-9]%d*)$')
 
			if cat == 'header' or cat == 'list' then
				nums[num] = true
			end
 
			args[k] = v -- Simple copy
		end
	end
 
	colspan = args.image and 3 or 2
	if args.imageleft then colspan = colspan + 1 end
	rowspan = 0
 
	if args.alternaterows == 'swap' then
		alt = true
	end
 
	for k, v in pairs(nums) do
		rownums[#rownums+1] = tonumber(k)
	end
 
	table.sort(rownums)
 
	-- Calculate skip rows
	local cSection, cSkip
	local showall = args.showall
	for i=1,#rownums do
		local num = rownums[i]
		if args['header'..num] then
			cSection = true
			cSkip = false
			local showme = args['show'..num]
			if showme == 'no' then
				cSkip = true
			elseif showme == 'auto' or (showme ~= 'yes' and showall ~= 'yes') then
				if not args['list'..num] then
					local nextNum = rownums[i+1]
					cSkip = not nextNum or args['header'..nextNum] -- If next has a header -> skip
				end
			end
		end
		if cSection and cSkip then
			skiprows[num] = true
		end
	end
end
 
local function _lyricsbox()
	-- Create the root HTML element
	local trim = function(s)
		return s and mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1") or ''
	end
	local border = args.border or trim(args[1])  or ''
	isChild = (border == 'child' or border == 'subgroup')
 
 	if args.bodyclass then navbox:addClass(args.bodyclass) end
	if args.bodystyle then navbox:cssText(args.bodystyle) end
 
	-- Process...
	if not isChild then
		processTitle()
		processRows()
 
		return tostring(lyricsbox)
	else
		processRows()
	end
end
 
function p.main(frame)
	preProcessArgs(frame)
 
	return _navbox()
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.