• 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
Add tooltip support (for rates, etc.)
Line 29: Line 29:     
local args_grammar = {
 
local args_grammar = {
node           = '^%s*(%a)%s*$',
+
node             = '^%s*(%a)%s*$',
comma_list     = '[^,]+',
+
comma_list       = '[^,]+',
ship_and_nodes = '^%s*(.-)%s*:%s*(.-)%s*$',
+
ship_and_nodes   = '^%s*(.-)%s*:%s*(.-)%s*$',
just_node     = '^%s*(%a)%s*$',
+
just_node         = '^%s*(%a)%s*$',
node_and_diff = '^%s*(%a)%s*/%s*(%S-)%s*$',
+
node_and_diff     = '^%s*(%a)%s*/%s*(%S-)%s*$',
 +
node_diff_tooltip = '^%s*(%a)%s*/%s*(%S-)%s*{(.-)}%s*$',
 
-- TODO:
 
-- TODO:
 
-- * Add battle ranks:
 
-- * Add battle ranks:
Line 140: Line 141:  
row.nodes[node.name] = nil
 
row.nodes[node.name] = nil
 
end
 
end
for node_and_diff in string.gmatch(nodes, args_grammar.comma_list) do
+
for node_arg in string.gmatch(nodes, args_grammar.comma_list) do
local node, diff = node_and_diff:match(args_grammar.node_and_diff)
+
local node, diff, tooltip = node_arg:match(args_grammar.node_diff_tooltip)
if not node or not diff then
+
if not node then
node = node_and_diff:match(args_grammar.just_node)
+
node, diff = node_arg:match(args_grammar.node_and_diff)
diff = nil
   
end
 
end
if node then
+
if not node then
 +
node = node_arg:match(args_grammar.just_node)
 +
end
 +
diff = diff_names[diff] and diff or '?'
 +
if node and diff then
 
local node = string.upper(node)
 
local node = string.upper(node)
 
if row.nodes[node] then
 
if row.nodes[node] then
Line 154: Line 158:  
else
 
else
 
row.nodes[node] = {
 
row.nodes[node] = {
color = diff and diff_colors[diff] or diff_colors['?'],
+
color = diff_colors[diff],
diff = diff and diff_names[diff] or '?'
+
diff = diff_names[diff],
 +
tooltip = tooltip,
 
}
 
}
 
end
 
end
 
else
 
else
log('ship node syntax error', string.format('%s for %s', node_and_diff, ship))
+
log('ship node syntax error', string.format('%s for %s', node_arg, ship))
 
end
 
end
 
end
 
end
Line 177: Line 182:     
local table_format = {
 
local table_format = {
header          = '{| class="article-table sortable" align="center" width="100%" style="text-align:center;"\n!Type\n!Ship <sup>[[Template:DropList/doc|?]]</sup>\n',
+
header          = '{| class="article-table sortable" align="center" width="100%" style="text-align:center;"\n!Type\n!<span style="border-bottom:1px dotted;">Ship<sup>[[Template:DropList/doc|?]]</sup></span>\n',
 
header_node      = '!${node}\n',
 
header_node      = '!${node}\n',
 
header_boss_node = '!style="background-color:pink;color:red;"|\'\'\'${node}\'\'\'\n',
 
header_boss_node = '!style="background-color:pink;color:red;"|\'\'\'${node}\'\'\'\n',
Line 214: Line 219:  
local node = row.nodes[node.name]
 
local node = row.nodes[node.name]
 
add(node and format{
 
add(node and format{
table_format.node_cell, color = node.color, diff = node.diff
+
table_format.node_cell, color = node.color, diff = node.tooltip and Formatting:tooltip(node.diff, node.tooltip) or node.diff
 
} or table_format.empty_cell)
 
} or table_format.empty_cell)
 
end
 
end
Line 257: Line 262:  
return showTable(parseArgs(args))
 
return showTable(parseArgs(args))
 
end
 
end
  −
-- DropList.test = DropList.show(nil, {nodes = "A,B,C", boss="A,B"})
      
return DropList
 
return DropList
cssedit, gkautomate
7,060

edits

Navigation menu