Module:Infobox/Widget/Role: Difference between revisions

From TwogPedia
(Created page with "local Role = {} function Role.make(rowName, value, game) value = string.upper(value) local container = mw.html.create('div') :addClass('ib-row') local name = mw.html.create('div') :addClass('ib-rowName') :wikitext(rowName .. ': ') local valueNode = mw.html.create('div') -- If no game then return value without link if game == nil then return container:node(name):node(valueNode:wikitext(value)) end local catName,visibleName if value == 'COACH'...")
 
No edit summary
Line 1: Line 1:
local Role = {}
local Role = {}


function Role.make(rowName, value, game)
function Role.make(rowName, role, game)
value = string.upper(value)
 
local container = mw.html.create('div')
local array = mw.text.split(role, ',')
:addClass('ib-row')
local name = mw.html.create('div')
:addClass('ib-rowName')
:wikitext(rowName .. ': ')
local valueNode = mw.html.create('div')
-- If no game then return value without link
if game == nil then
return container:node(name):node(valueNode:wikitext(value))
end
local catName,visibleName  
for i, v in ipairs(array) do
if value == 'COACH' then
v = mw.text.trim(v)
linkName = 'Coaches'
v = string.upper(v)
visibleName = 'Coach'
local valueNode = mw.html.create('div')
-- If no game then return value without link
if game == nil then
return container:node(valueNode:wikitext(v))
end
local catName,visibleName
-- General
if value == 'COACH' then
linkName = 'Coaches'
visibleName = 'Coach'
end
if value == 'MANAGER' then
linkName = 'Managers'
visibleName = 'Manager'
end
-- Dota 2
if value == 'CARRY' then
linkName = 'Carry_players'
visibleName = 'Carry'
end
if value == 'HARD SUPPORT' then
linkName = 'Hard_support_players'
visibleName = 'Hard support'
end
if value == 'OFFLANE' then
linkName = 'Offlaners'
visibleName = 'Offlane'
end
-- Dota and LoL overlap
if value == 'SUPPORT' then
linkName = 'Support_players'
visibleName = 'Support'
end
if value == 'MID' then
linkName = 'Mid_players'
visibleName = 'Mid'
end
-- LoL
if value == 'TOP' then
linkName = 'Top_players'
visibleName = 'Top'
end
if value == 'BOT' then
linkName = 'Bot_players'
visibleName = 'Bot'
end
if value == 'JUNGLE' then
linkName = 'Junglers'
visibleName = 'Jungle'
end
-- CS:GO Values
if value == 'AWPER' then
linkName = 'AWPers'
visibleName = 'Top'
end
if value == 'SUPPORT' then
linkName = 'Support'
visibleName = 'Support'
end
if value == 'RIFLER' then
linkName = 'Riflers'
visibleName = 'Rifler'
end
if value == 'IGL' or value == 'IN-GAME LEADER' then
linkName = 'In-game_leaders'
visibleName = 'In-game Leader'
end
local categoryLink = '[[:Category:' .. game .. '/' .. linkName .. '|' .. visibleName ..']]'
valueNode:wikitext(categoryLink)
container:node(valueNode)
end
end
local categoryLink = '[[:Category:' .. game .. '/' .. linkName .. '|' .. visibleName ..']]'
valueNode:wikitext(categoryLink)
return container:node(name):node(valueNode)
return container
end
end




return Role
return Role

Revision as of 21:56, 31 August 2022

Documentation for this module may be created at Module:Infobox/Widget/Role/doc

local Role = {}

function Role.make(rowName, role, game)

	local array = mw.text.split(role, ',')
	
	for i, v in ipairs(array) do
		v = mw.text.trim(v)
		v = string.upper(v)
		local valueNode = mw.html.create('div')
		-- If no game then return value without link
		if game == nil then
			return container:node(valueNode:wikitext(v))
		end
		
		local catName,visibleName
		-- General
		if value == 'COACH' then
			linkName = 'Coaches'
			visibleName = 'Coach'
		end
		if value == 'MANAGER' then
			linkName = 'Managers'
			visibleName = 'Manager'
		end
		
		-- Dota 2
		if value == 'CARRY' then
			linkName = 'Carry_players'
			visibleName = 'Carry'
		end
		if value == 'HARD SUPPORT' then
			linkName = 'Hard_support_players'
			visibleName = 'Hard support'
		end
		if value == 'OFFLANE' then
			linkName = 'Offlaners'
			visibleName = 'Offlane'
		end
		
		-- Dota and LoL overlap
		if value == 'SUPPORT' then
			linkName = 'Support_players'
			visibleName = 'Support'
		end
		if value == 'MID' then
			linkName = 'Mid_players'
			visibleName = 'Mid'
		end
		
		-- LoL
		if value == 'TOP' then
			linkName = 'Top_players'
			visibleName = 'Top'
		end
		if value == 'BOT' then
			linkName = 'Bot_players'
			visibleName = 'Bot'
		end
		if value == 'JUNGLE' then
			linkName = 'Junglers'
			visibleName = 'Jungle'
		end
		
		-- CS:GO Values
		if value == 'AWPER' then
			linkName = 'AWPers'
			visibleName = 'Top'
		end
		if value == 'SUPPORT' then
			linkName = 'Support'
			visibleName = 'Support'
		end
		if value == 'RIFLER' then
			linkName = 'Riflers'
			visibleName = 'Rifler'
		end
		if value == 'IGL' or value == 'IN-GAME LEADER' then
			linkName = 'In-game_leaders'
			visibleName = 'In-game Leader'
		end
		
		local categoryLink = '[[:Category:' .. game .. '/' .. linkName .. '|' .. visibleName ..']]'
		valueNode:wikitext(categoryLink)
		container:node(valueNode)
	end
	
	return container
end


return Role