Changes

no edit summary
Line 1: Line 1:  
local BaseData = require('Module:BaseData')
 
local BaseData = require('Module:BaseData')
 
local Iterator = require('Module:Iterator')
 
local Iterator = require('Module:Iterator')
local format = require('Module:StringInterpolation').format
+
local format = require('Module:Core').format
    
local BaseTable = BaseData{
 
local BaseTable = BaseData{
_table_start = [[{| class="wikitable typography-xl-optout" style="width: -moz-fit-content; width: -webkit-fit-content; width: fit-content;"]],
+
_table_start = [[{| class="wikitable"]],
 
_row_starter = "|-",
 
_row_starter = "|-",
 
_row_starter_with_attributes = [[|- class="${classes}"]],
 
_row_starter_with_attributes = [[|- class="${classes}"]],
Line 11: Line 11:  
_cell_color = {
 
_cell_color = {
 
},
 
},
_cell = [[| class="${classes}" colspan="${colspan}" rowspan="${rowspan}" style="text-align: ${text_align}; background-color: ${bg_color}; padding:3px;" |${values.value}]],
+
_cell = [[| class="${classes}" colspan="${colspan}" rowspan="${rowspan}" style="text-align:${text_align};background-color:${bg_color}" |${values.value}]],
 +
_cell_simple = [[|${values.value}]],
 
_empty_cell = [[|]],
 
_empty_cell = [[|]],
 
_column_cell_templates = {
 
_column_cell_templates = {
Line 17: Line 18:  
_column_empty_cells = {
 
_column_empty_cells = {
 
},
 
},
_header1 = "<h3>${value}</h3>",
+
_header1 = "<h2>${value}</h2>",
 
_custom_row_class = "custom-row",
 
_custom_row_class = "custom-row",
 
_custom_row_prefix = "custom_row_",
 
_custom_row_prefix = "custom_row_",
Line 42: Line 43:  
}
 
}
   −
function BaseTable:Table(args)
+
function BaseTable:Table(args, params)
 
return self{
 
return self{
 
_args = args,
 
_args = args,
 +
_params = params,
 
}:create_table()
 
}:create_table()
 
end
 
end
Line 105: Line 107:  
table.insert(self._items, mw.ustring.sub(item_key, 2))
 
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), self._enemy)
 
table.insert(self._items, item)
 
table.insert(self._items, item)
 
local note = self._args[item_key .. self._notes_suffix]
 
local note = self._args[item_key .. self._notes_suffix]
Line 205: Line 207:  
function BaseTable:start_rows()
 
function BaseTable:start_rows()
 
self._rows = {self._table_start}
 
self._rows = {self._table_start}
if not self._args.no_header then
+
if not self._args.no_header and self._header then
 
    table.insert(self._rows, self._header)
 
    table.insert(self._rows, self._header)
 
     end
 
     end
Line 214: Line 216:  
if row_values ~= "break" then
 
if row_values ~= "break" then
 
if row_values == "header" then
 
if row_values == "header" then
table.insert(self._rows, self._row_starter)
+
    if self._row_starter then
table.insert(self._rows, self._header)
+
    table.insert(self._rows, self._row_starter)
elseif row_values == "empty" then
+
    end
table.insert(self._rows, self._row_starter)
+
if self._header then
 +
    table.insert(self._rows, self._header)
 +
end
 +
    elseif row_values == "empty" then
 +
        if self._row_starter then
 +
    table.insert(self._rows, self._row_starter)
 +
end
 
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
 
table.insert(self._rows, self._column_empty_cells[column] or self._empty_cell)
 
table.insert(self._rows, self._column_empty_cells[column] or self._empty_cell)
Line 223: Line 231:  
elseif type(row_values) == "table" then
 
elseif type(row_values) == "table" then
 
if row_values._row then
 
if row_values._row then
table.insert(self._rows, format(self._row_starter_with_attributes, row_values._row))
+
    if self._row_starter_with_attributes then
 +
    table.insert(self._rows, format(self._row_starter_with_attributes, row_values._row))
 +
end
 
else
 
else
table.insert(self._rows, self._row_starter)
+
    if self._row_starter then
 +
    table.insert(self._rows, self._row_starter)
 +
end
 
end
 
end
 
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
 
if row_values[column] then
 
if row_values[column] then
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
+
if row_values[column].bg_color and row_values[column].bg_color ~= self._transparent then
 +
row_values[column].classes = "highlighted " .. (row_values[column].classes or "")
 +
end
 +
if row_values[column].simple then
 +
table.insert(self._rows, format(self._cell_simple, row_values[column]))
 +
else
 +
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
 +
end
 
end
 
end
 
end
 
end
Line 242: Line 261:  
function BaseTable:build_rows_breaks_as_empty_rows()
 
function BaseTable:build_rows_breaks_as_empty_rows()
 
for index, row_values in ipairs(self._data_rows) do
 
for index, row_values in ipairs(self._data_rows) do
table.insert(self._rows, self._row_starter)
+
    if self._row_starter then
 +
    table.insert(self._rows, self._row_starter)
 +
end
 
if row_values == "break" then
 
if row_values == "break" then
 
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
 
table.insert(self._rows, self._column_empty_cells[column] or self._empty_cell)
 
table.insert(self._rows, self._column_empty_cells[column] or self._empty_cell)
 
end
 
end
elseif row_values == "header" then
+
elseif row_values == "header" and self._header then
 
table.insert(self._rows, self._header)
 
table.insert(self._rows, self._header)
 
elseif type(row_values) == "table" then
 
elseif type(row_values) == "table" then
 
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
 
if row_values[column] then
 
if row_values[column] then
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
+
if row_values[column].simple then
 +
table.insert(self._rows, format(self._cell_simple, row_values[column]))
 +
else
 +
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
 +
end
 
end
 
end
 
end
 
end
Line 264: Line 289:  
     if mw.ustring.sub(custom_row_key, 1, 1) == "#" then
 
     if mw.ustring.sub(custom_row_key, 1, 1) == "#" then
 
         local value = mw.ustring.sub(custom_row_key, 2)
 
         local value = mw.ustring.sub(custom_row_key, 2)
table.insert(self._rows, self._row_starter)
+
        if not self._disable_row_starter and self._row_starter then
 +
    table.insert(self._rows, self._row_starter)
 +
end
 
         table.insert(self._rows, format{
 
         table.insert(self._rows, format{
 
             self._cell,
 
             self._cell,
Line 278: Line 305:  
},
 
},
 
})
 
})
    table.insert(self._rows, self._row_starter)
+
if not self._disable_row_starter and self._row_starter then
        table.insert(self._rows, self._header)
+
        table.insert(self._rows, self._row_starter)
 +
    end
 +
    if not self._disable_row_starter and self._header then
 +
            table.insert(self._rows, self._header)
 +
        end
 
elseif self._custom_rows and self._custom_rows[custom_row_key] then
 
elseif self._custom_rows and self._custom_rows[custom_row_key] then
 
if type(self._custom_rows[custom_row_key]) == "table" then
 
if type(self._custom_rows[custom_row_key]) == "table" then
table.insert(self._rows, format(self._row_starter_with_attributes, self._custom_rows[custom_row_key].row or {}))
+
    if self._row_starter_with_attributes then
 +
    table.insert(self._rows, format(self._row_starter_with_attributes, self._custom_rows[custom_row_key].row or {}))
 +
end
 
table.insert(self._rows, self._custom_rows[custom_row_key].content)
 
table.insert(self._rows, self._custom_rows[custom_row_key].content)
 
else
 
else
table.insert(self._rows, self._row_starter)
+
    if self._row_starter then
 +
    table.insert(self._rows, self._row_starter)
 +
end
 
table.insert(self._rows, self._custom_rows[custom_row_key])
 
table.insert(self._rows, self._custom_rows[custom_row_key])
 
end
 
end
else
+
    else
table.insert(self._rows, self._row_starter)
+
        if self._row_starter then
 +
    table.insert(self._rows, self._row_starter)
 +
end
 
local classes = self._args[self._custom_row_prefix .. custom_row_key .. self._classes_suffix]
 
local classes = self._args[self._custom_row_prefix .. custom_row_key .. self._classes_suffix]
 
if classes then
 
if classes then
Line 312: Line 349:  
function BaseTable:finish_rows()
 
function BaseTable:finish_rows()
 
     if not self._args.no_header_bottom then
 
     if not self._args.no_header_bottom then
    table.insert(self._rows, self._row_starter)
+
        if self._row_starter then
    table.insert(self._rows, self._header_bottom or self._header)
+
        table.insert(self._rows, self._row_starter)
 +
    end
 +
    if self._header_bottom or self._header then
 +
        table.insert(self._rows, self._header_bottom or self._header)
 +
    end
 
     end
 
     end
 
table.insert(self._rows, self._table_end)
 
table.insert(self._rows, self._table_end)
cssedit, gkautomate
6,941

edits