Module:Eicons

local function parameter(parameter, base) if parameter == 'y' or parameter == 'yes' then return true end if parameter == 'n' or parameter == 'no' then return false end return base end

local function getVersionInfo(raw) if not raw or raw == '' then return false, false, false, false, false, false else return raw:find('d'),raw:find('c'),raw:find('o'),raw:find('m'),raw:find('3'),raw:find('j') end end

local function eicons(vd, vc, vo, vm, v3, vj, _small, frame) local result='' if vd then space = true result = result .. frame:expandTemplate{ title = 'icon/desktop', args = {small = _small } } end if vc then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/console', args = {small = _small } } end if vj then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/japan', args = {small = _small } } end if vo then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/oldgen', args = {small = _small } } end if vm then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/mobile', args = {small = _small } } end if v3 then if space then result = result .. '&thinsp;' end result = result .. frame:expandTemplate{ title = 'icon/3ds', args = {small = _small } } end return result end

local getArg = function(key, frame) local value = frame.args[key] if not value then return nil end value = mw.text.trim(value) if value == '' then return nil else return value end end

-- main return object return {

simple = function(frame) local _versions = getArg(1, frame) local _small = getArg('small', frame) if not _versions or versions=='dcom3' or versions=='dcom3j' then return '' else local vd,vc,vo,vm,v3,vj = getVersionInfo(_versions) return mw.text.tag('span',{class='eico'}, eicons(vd, vc, vo, vm, v3, vj, _small, frame)) end end,

go = function(frame) local _versions = getArg(1, frame) local _small = getArg('small', frame) local _desktop = getArg('desktop', frame) local _console = getArg('console', frame) local _oldgen = getArg('old-gen', frame) local _mobile = getArg('mobile', frame) local _3ds = getArg('3ds', frame) local _japan = getArg('japan', frame) local _invert = getArg('invert', frame)

local vd,vc,vo,vm,v3,vj = getVersionInfo(_versions)

if _invert then vd = not vd		vc = not vc		vo = not vo		vm = not vm		v3 = not v3		vj = false end

if vd and vc and vo and vm and v3 then vd = false vc = false vo = false vm = false v3 = false vj = false end

vd = parameter(_desktop, vd) vc = parameter(_console, vc) vo = parameter(_oldgen, vo) vm = parameter(_mobile, vm) v3 = parameter(_3ds, v3) vj = parameter(_japan, vj)

if vd or vc or vo or vm or v3 or vj then return mw.text.tag('span',{class='eico'}, eicons(vd, vc, vo, vm, v3, vj, _small, frame)) else return '' end end, icons = function(versions, _small, frame) if not versions or versions=='' or versions=='dcom3' or versions=='dcom3j' then return '' end local vd,vc,vo,vm,v3,vj = getVersionInfo(versions) return eicons(vd, vc, vo, vm, v3, vj, _small, frame) end }