- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Changes
Jump to navigation
Jump to search
Line 56:
Line 56:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
no edit summary
end
end
return true
return true
end
function BaseTable:create_header()
self._header = self._header_template
end
function BaseTable:create_items()
for index, item_key in ipairs(self._args) do
if item_key == "-" then
table.insert(self._items, "break")
elseif item_key == "#" then
table.insert(self._items, "header")
else
local item = self._item_class(item_key)
table.insert(self._items, item)
local note = self._args[item_key .. self._notes_suffix]
if note then
note = {note = note}
local note_highlight = self._args[item_key .. self._notes_suffix .. self._highlight_suffix]
if note_highlight then
note.highlight = note_highlight
end
self._notes[item] = note
end
end
end
end
function BaseTable:create_data_rows()
for _, item in ipairs(self._items) do
local row_values
if type(item) == "string" then
row_values = item
else
row_values = {}
for _, column in ipairs(self._columns) do
row_values[column] = self[column](self, item)
row_values[column].rowspan = 1
end
end
table.insert(self._data_rows, row_values)
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
function BaseTable:build_rows_merge_vertical()
for index, item in ipairs(self._items) do
local row_values
if type(item) == "string" then
row_values = item
else
row_values = {}
for _, column in ipairs(self._columns) do
row_values[column] = self[column](self, item)
end
if index > 1 then
for _, column in ipairs(self._columns) do
for i=index-1,1,-1 do
local previous_row = self._data_rows[i]
local previous_row_type = type(previous_row) ~= "string"
local previous_cell = previous_row_type and previous_row[column] or false
if previous_cell then
if self.compare_values(row_values[column].values, previous_cell.values) then
previous_cell.rowspan = previous_cell.rowspan + 1
row_values[column] = nil
else
row_values[column].rowspan = 1
end
break
elseif not previous_row_type then
row_values[column].rowspan = 1
break
end
end
end
else
for _, column in ipairs(self._columns) do
row_values[column].rowspan = 1
end
end
end
table.insert(self._data_rows, row_values)
end
end
function BaseTable:create_table()
self._items = {}
self._notes = {}
self._data_rows = {}
self:create_table_prep()
self:create_items()
self:create_header()
self:start_rows()
self:build_rows()
self:finish_rows()
return self:join_rows()
end
end
return BaseTable
return BaseTable