Module:Sandbox/ChaoticShadow/InfoboxBuilder: Difference between revisions

Content added Content deleted
No edit summary
(rename variables)
Line 24: Line 24:
{ name = 'text color' }
{ name = 'text color' }
},
},
paramnames = { 'bg color', 'text color' },
param_names = { 'bg color', 'text color' },
args = {},
raw_args = {},
final_args = {},
proc_args = {},
proto_infobox = {},
infobox = mw.html.create('table'):addClass('infobox'),
infobox = mw.html.create('table'):addClass('infobox'),
finished = false
finished = false
Line 134: Line 133:
end
end
local raw_param_value = self.args[param]
local raw_param_value = self.raw_args[param]
local colors = color_table[raw_param_value]
local colors = color_table[raw_param_value]
Line 165: Line 164:
error("name must not be nil or empty")
error("name must not be nil or empty")
end
end
if self.paramnames[v.name] then
if self.param_names[v.name] then
error("name cannot be duplicate")
error("name cannot be duplicate")
end
end
Line 174: Line 173:
default = v.default
default = v.default
}
}
table.insert(self.paramnames, v.name)
table.insert(self.param_names, v.name)
end
end
Line 188: Line 187:
for k,v in pairs(args) do
for k,v in pairs(args) do
if v ~= '' then
if v ~= '' then
self.args[k] = v
self.raw_args[k] = v
end
end
end
end
if self.args['bg color'] then
if self.raw_args['bg color'] then
self:setHeaderBackgroundColor(self.args['bg color'])
self:setHeaderBackgroundColor(self.raw_args['bg color'])
end
end
if self.args['text color'] then
if self.raw_args['text color'] then
self:setHeaderTextColor(self.args['text color'])
self:setHeaderTextColor(self.raw_args['text color'])
end
end
Line 212: Line 211:
end
end
if self.final_args[param] then
if self.proc_args[param] then
return self.final_args[param]
return self.proc_args[param]
end
end
Line 223: Line 222:
end
end
local raw_param_value = self.args[param] or current_param.default
local raw_param_value = self.raw_args[param] or current_param.default
if raw_param_value == nil then
if raw_param_value == nil then
Line 237: Line 236:
end
end
self.final_args[param] = content
self.proc_args[param] = content
return content
return content