Module:Test: Difference between revisions

From Resonite Wiki
mNo edit summary
mNo edit summary
Line 1: Line 1:
local p = {}
local p = {}
local typeColor =
{
User = "rgb(255, 128, 255)",
Impulse = "rgb(179, 255, 255)"
}


function p.ProtoFlux( frame )
function p.ProtoFlux( frame )
Line 33: Line 39:
   :tag( 'td' ) -- The Input binding post
   :tag( 'td' ) -- The Input binding post
     :attr( 'rowspan', '2' )
     :attr( 'rowspan', '2' )
     :attr( 'bgcolor', '{{' .. Input.Type .. '-color}}' )
     :attr( 'bgcolor', typeColor[Input.Type] )
     :done()
     :done()
   :tag( 'td' ) -- The Input name
   :tag( 'td' ) -- The Input name
Line 41: Line 47:
   :tag( 'td' ) -- The Output binding post
   :tag( 'td' ) -- The Output binding post
     :attr( 'rowspan', '2' )
     :attr( 'rowspan', '2' )
     :attr( 'bgcolor', '{{' .. Output.Type .. '-color}}' )
     :attr( 'bgcolor', typeColor[Output.Type] )
     :done()
     :done()
   :done()
   :done()

Revision as of 03:37, 13 January 2024

Documentation for this module may be created at Module:Test/doc

local p = {}

local typeColor = 
{
 User = "rgb(255, 128, 255)",
 Impulse = "rgb(179, 255, 255)" 
}

function p.ProtoFlux( frame )
 local inputsDecode = mw.text.jsonDecode( frame.args.Inputs );
 local outputsDecode = mw.text.jsonDecode( frame.args.Outputs );
 local numInputs = #inputsDecode;
 local numOuputs = #outputsDecode;

 local protofluxContainer = mw.html.create( 'table' )
 
 protofluxContainer
  :tag( 'tr' )
   :tag( 'th' )
    :attr('width', '20%')
    :done()
   :tag( 'th' )
    :attr('width', '60%')
    :wikitext(frame.args.Name)
    :done()
   :tag( 'th')
    :attr('width', '20%');

 CreateIORow(protofluxContainer, inputsDecode[1], outputsDecode[1]);

 return tostring(protofluxContainer);

end

-- Each Input/Output row is really 2 rows high. 
function CreateIORow(Container, Input, Output)
 Container
  :tag( 'tr' )
   :tag( 'td' ) -- The Input binding post
    :attr( 'rowspan', '2' )
    :attr( 'bgcolor', typeColor[Input.Type] )
    :done()
   :tag( 'td' ) -- The Input name
    :attr( 'style', 'text-align: left;')
    :wikitext( Input.Name )
    :done()
   :tag( 'td' ) -- The Output binding post
    :attr( 'rowspan', '2' )
    :attr( 'bgcolor', typeColor[Output.Type] )
    :done()
   :done()
  :tag( 'tr')
   :tag( 'td' )
    :attr( 'style', 'text-align: right;')
    :wikitext( Output.Name )
    :done()
   
end

return p