Changes

no edit summary
Line 10: Line 10:  
_cell_color = {
 
_cell_color = {
 
},
 
},
_cell = [[| colspan="1" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.value}]],
+
_cell = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:5px 5px 5px 5px;" |${values.value}]],
 
_column_cell_templates = {
 
_column_cell_templates = {
 
},
 
},
 +
_custom_row_prefix = "custom_row_",
 +
_text_align_suffix = "_text_align",
 +
_bg_color_suffix = "_bg_color",
 +
_content_suffix = "_content",
 
_good_stat_color = "#ffff40",
 
_good_stat_color = "#ffff40",
 
_outstanding_stat_color = "#73ff4d",
 
_outstanding_stat_color = "#73ff4d",
Line 83: Line 87:  
elseif item_key == "#" then
 
elseif item_key == "#" then
 
table.insert(self._items, "header")
 
table.insert(self._items, "header")
 +
elseif mw.ustring.sub(item_key, 1, 1) == "!" then
 +
table.insert(self._items, mw.ustring.sub(item_key, 2))
 
else
 
else
 
local item = self._item_class(self:process_item_key(item_key))
 
local item = self._item_class(self:process_item_key(item_key))
Line 109: Line 115:  
row_values[column] = self[column](self, item)
 
row_values[column] = self[column](self, item)
 
row_values[column].rowspan = 1
 
row_values[column].rowspan = 1
 +
row_values[column].colspan = 1
 
end
 
end
 
end
 
end
 
table.insert(self._data_rows, row_values)
 
table.insert(self._data_rows, row_values)
 
end
 
end
end
  −
  −
function BaseTable:start_rows()
  −
self._rows = {self._table_start, self._header}
  −
end
  −
  −
function BaseTable:build_rows()
  −
for index, row_values in ipairs(self._data_rows) do
  −
if row_values ~= "break" then
  −
table.insert(self._rows, self._row_starter)
  −
if row_values == "header" then
  −
table.insert(self._rows, self._header)
  −
else
  −
for _, column in ipairs(self._columns) do
  −
if row_values[column] then
  −
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
  −
end
  −
end
  −
end
  −
end
  −
end
  −
end
  −
  −
function BaseTable:finish_rows()
  −
table.insert(self._rows, self._row_starter)
  −
table.insert(self._rows, self._header)
  −
table.insert(self._rows, self._table_end)
  −
end
  −
  −
function BaseTable:join_rows()
  −
return table.concat(self._rows, "\n")
  −
end
  −
  −
function BaseTable:create_table_prep()
  −
return
   
end
 
end
   Line 172: Line 144:  
else
 
else
 
row_values[column].rowspan = 1
 
row_values[column].rowspan = 1
 +
row_values[column].colspan = 1
 
end
 
end
 
break
 
break
 
elseif not previous_row_type then
 
elseif not previous_row_type then
 
row_values[column].rowspan = 1
 
row_values[column].rowspan = 1
 +
row_values[column].colspan = 1
 
break
 
break
 
end
 
end
Line 183: Line 157:  
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
 
row_values[column].rowspan = 1
 
row_values[column].rowspan = 1
 +
row_values[column].colspan = 1
 
end
 
end
 
end
 
end
Line 188: Line 163:  
table.insert(self._data_rows, row_values)
 
table.insert(self._data_rows, row_values)
 
end
 
end
 +
end
 +
 +
function BaseTable:start_rows()
 +
self._rows = {self._table_start, self._header}
 +
end
 +
 +
function BaseTable:build_rows()
 +
for index, row_values in ipairs(self._data_rows) do
 +
if row_values ~= "break" then
 +
table.insert(self._rows, self._row_starter)
 +
if row_values == "header" then
 +
table.insert(self._rows, self._header)
 +
elseif type(row_values) == "table" then
 +
for _, column in ipairs(self._columns) do
 +
if row_values[column] then
 +
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
 +
end
 +
end
 +
else
 +
table.insert(self._rows,
 +
format{self._cell,
 +
colspan = #self._columns, rowspan = 1,
 +
text_align = self._args[self._custom_row_prefix .. row_values .. self._text_align_suffix] or self._start_align,
 +
bg_color = self._args[self._custom_row_prefix .. row_values .. self._bg_color_suffix] or self._transparent,
 +
values = {
 +
value = self._args[self._custom_row_prefix .. row_values .. self._content_suffix] or "",
 +
},
 +
}
 +
)
 +
end
 +
end
 +
end
 +
end
 +
 +
function BaseTable:finish_rows()
 +
table.insert(self._rows, self._row_starter)
 +
table.insert(self._rows, self._header)
 +
table.insert(self._rows, self._table_end)
 +
end
 +
 +
function BaseTable:join_rows()
 +
return table.concat(self._rows, "\n")
 +
end
 +
 +
function BaseTable:create_table_prep()
 +
return
 
end
 
end
  
Anonymous user