Line 13: |
Line 13: |
| _rows = {}, | | _rows = {}, |
| _items = {}, | | _items = {}, |
| + | |
| + | _collapse_button_template = [[<div class="mw-customtoggle-${id}">]], |
| + | _collapse_div_start = [[<div id="mw-customcollapsible-${id}" class="mw-collapsible mw-collapsed">]], |
| + | _collapse_div_end = [[</div>]], |
| | | |
| _table_start = [[{|]], | | _table_start = [[{|]], |
Line 66: |
Line 70: |
| self._hq_lvl = self._hq_lvl + 5 | | self._hq_lvl = self._hq_lvl + 5 |
| end | | end |
| + | end |
| + | |
| + | function NanaminFleetKai:generate_id() |
| + | --No built-in hashing algorithms, so we'll just cheat and use the route, HQ level and a random number |
| + | self._id = self._args["route"]:gsub("[^%w]", "") .. self._args["hq"] .. tostring(math.random(1000000,9999999)) |
| end | | end |
| | | |
Line 254: |
Line 263: |
| self:process_hq_level() | | self:process_hq_level() |
| self:process_args(args) | | self:process_args(args) |
| + | local id = self:generate_id() |
| + | table.insert(self._rows, format{self._collapse_button_template, id = id}) |
| + | table.insert(self._rows, format{self._collapse_div_start, id = id}) |
| table.insert(self._rows, self._table_start) | | table.insert(self._rows, self._table_start) |
| self:build_table() | | self:build_table() |
| self:add_extras() | | self:add_extras() |
| table.insert(self._rows, self._table_end) | | table.insert(self._rows, self._table_end) |
| + | table.insert(self._rows, self._collapse_div_end) |
| return table.concat(self._rows, "\n") | | return table.concat(self._rows, "\n") |
| end | | end |