Documentation for this module may be created at Module:Test/doc
local p = {}
local typeColor =
{
User = '255, 128, 255',
Impulse = '179, 255, 255',
Boolean = '115, 115, 115',
AsyncImpulse = '204, 179, 255',
String = '245, 31, 31',
Dummy = '255, 0, 255',
IFormatProvider = '168, 143, 214',
float = '0, 255, 255',
ColorProfile = '255, 196, 54',
colorX = '255, 89, 0'
}
local mt = {__index = function () return "0,0,0" end}
setmetatable(typeColor, mt)
function p.ProtoFlux( frame )
local inputsDecode = mw.text.jsonDecode( frame.args.Inputs );
local outputsDecode = mw.text.jsonDecode( frame.args.Outputs );
local protofluxContainer = mw.html.create( 'table' )
protofluxContainer
:attr( 'cellspacing', '0px')
:attr( 'style', 'color: white; background-color: #11151d;' )
:attr( 'width', "256px" )
:tag( 'tr' )
:attr( 'style', 'height: 50px; background-color: #1a2a36; font-size: 18pt;')
:tag( 'th' )
:attr('width', '15%')
:done()
:tag( 'th' )
:attr('width', '70%')
:wikitext(frame.args.Name)
:done()
:tag( 'th')
:attr('width', '15%');
local maxRows = math.max(#inputsDecode, #outputsDecode)
for i=1,maxRows,1 do
CreateIORow(protofluxContainer, inputsDecode[i], outputsDecode[i]);
end
protofluxContainer
:tag( 'tr' )
:tag( 'td' )
:attr('colspan', '3')
:attr('style', 'text-align: center; padding: 10px; font-size: 18pt; color: rgb(64,64,64); font-weight: bold;' )
:wikitext(frame.args.Category)
return tostring(protofluxContainer);
end
-- Each Input/Output row is really 2 rows high.
function CreateIORow(Container, Input, Output)
local inputRow = Container
:tag( 'tr' )
:attr( 'style', 'height: 36px;');
createIOBindingPost(inputRow, Input, true);
inputRow
:tag( 'td' ) -- The Input name
:attr( 'style', 'text-align: left; border-right: 20px solid #11151d; border-bottom: 4px solid #11151d; border-top: 4px solid #11151d; background-color:' .. getIOColor(Input, 0.6) .. ';')
:wikitext( Input and Input.Name or ' ' )
createIOBindingPost(inputRow, Output, true);
Container
:tag( 'tr')
:attr( 'style', 'height: 36px;')
:tag( 'td' )
:attr( 'style', 'text-align: right; border-left: 20px solid #11151d; border-bottom: 4px solid #11151d; border-top: 4px solid #11151d; background-color: ' .. getIOColor(Output, 0.6) .. ';')
:wikitext( Output and Output.Name or ' ' )
:done()
end
function createIOBindingPost(Container, Connector, isInput)
if Connector and Connector.Type == "Impulse" then
Container
:tag( 'td' )
:attr( 'rowspan', '2' )
:attr( 'style', 'background-color: black; border-style: none;')
:tag( 'svg' )
:attr( 'width', '38')
:attr( 'height', '72')
:attr( 'style', 'display:block; stroke: rgba(179, 255, 255,1); fill: rgba(179, 255, 255,0.3); stroke-linejoin: round;')
:tag( 'polygon' )
:attr('style', 'stroke-width: 3px')
:attr( 'points', '2,2 2,70, 36,36')
else
Container
:tag( 'td' )
:attr( 'rowspan', '2' )
:attr( 'style', 'background-color: ' .. getIOColor(Connector, 0.3) .. '; border: 5px solid ' .. getIOColor(Connector, 1.0) .. (isInput and '; border-left: none;' or ';border-right: none;'))
end
end
function getIOColor(Connector, alpha)
return (Connector and 'rgba(' .. typeColor[Connector.Type] .. ',' .. alpha .. ')' or 'rgba(0,0,0,0)')
end
return p