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' } |
||
}, |
}, |
||
param_names = { 'bg color', 'text color' }, |
|||
raw_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. |
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. |
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. |
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. |
self.raw_args[k] = v |
||
end |
end |
||
end |
end |
||
if self. |
if self.raw_args['bg color'] then |
||
self:setHeaderBackgroundColor(self. |
self:setHeaderBackgroundColor(self.raw_args['bg color']) |
||
end |
end |
||
if self. |
if self.raw_args['text color'] then |
||
self:setHeaderTextColor(self. |
self:setHeaderTextColor(self.raw_args['text color']) |
||
end |
end |
||
Line 212: | Line 211: | ||
end |
end |
||
if self. |
if self.proc_args[param] then |
||
return self. |
return self.proc_args[param] |
||
end |
end |
||
Line 223: | Line 222: | ||
end |
end |
||
local raw_param_value = self. |
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. |
self.proc_args[param] = content |
||
return content |
return content |