Module:MultiTabs: Difference between revisions

From EarthMC
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 14: Line 14:
if myTable[i] == "" then
if myTable[i] == "" then
table.remove(myTable, i)
table.remove(myTable, i)
end
elseif myTable[i] == nil then
        table.remove(myTable, i)
        end
end
end
     local int = GetTableLng(myTable)
     local int = GetTableLng(myTable)
Line 24: Line 26:
     end
     end
toReturn = toReturn.."</div>"
toReturn = toReturn.."</div>"
     return frame:preprocess(myTable)
     return frame:preprocess(toReturn)
end
end




return p
return p

Latest revision as of 21:54, 23 October 2023

local p = {} --p stands for package

function GetTableLng(tbl)
  local getN = 0
  for n in pairs(tbl) do 
    getN = getN + 1 
  end
  return getN
end

function p.create( frame )
	local myTable = frame.args
	for i = #myTable, 1, -1 do
		if myTable[i] == "" then
			table.remove(myTable, i)
		elseif myTable[i] == nil then
        	table.remove(myTable, i)
        end
	end
    local int = GetTableLng(myTable)
    local width = 100/int
	local toReturn = '<div style="display:flex;border-bottom: 1px solid black;text-align:center;vertical-align: middle;line-height: 50px;font-size: 20px;">'
    for i = 1,int,1 
	do 
		toReturn = toReturn..'\n<div style="border: 1px solid black;width:'..width..'%;max-width:300px;height:50px;margin:4px;">'..frame.args[i].."</div>"
    end
	toReturn = toReturn.."</div>"
    return frame:preprocess(toReturn)
end


return p