Line 1: |
Line 1: |
| local p = {} | | local p = {} |
− | | + | |
| -- Module for map branching written by | | -- Module for map branching written by |
| -- Remi_Scarlet | | -- Remi_Scarlet |
| -- I fucking hate lua. | | -- I fucking hate lua. |
− | | + | |
| + | -- 10/24/15 Added colorful blue button thing |
| + | |
| local remiLib = require("Module:RemiLib") | | local remiLib = require("Module:RemiLib") |
− | | + | |
| function p.renderBranchingTable(graph, collapsed) | | function p.renderBranchingTable(graph, collapsed) |
| + | |
| + | local uniqueID = remiLib.timeHash() |
| + | |
| + | local classString = "mw-customtoggle-" .. tostring(uniqueID) |
| + | local idString = "mw-customcollapsible-" .. tostring(uniqueID) |
| + | |
| + | local button = mw.html.create('div') |
| + | button |
| + | :addClass(classString) |
| + | :addClass("globalbutton") |
| + | :wikitext("Show/Hide Branching Rules") |
| + | |
| local body = mw.html.create("table") | | local body = mw.html.create("table") |
| body | | body |
| + | :addClass("mw-collapsible") |
| :addClass("wikitable") | | :addClass("wikitable") |
− | :addClass("mw-collapsible") | + | :addClass("mw-collapsed") |
| + | :attr("id",idString) |
| :css("width","300px") | | :css("width","300px") |
− | if collapsed then
| + | |
− | body:addClass("mw-collapsed")
| |
− | end
| |
− |
| |
| local titleRow = mw.html.create("tr") | | local titleRow = mw.html.create("tr") |
| local th = mw.html.create("th") | | local th = mw.html.create("th") |
Line 78: |
Line 91: |
| end | | end |
| col = mw.html.create("td") | | col = mw.html.create("td") |
− | | + | |
| col | | col |
| :wikitext(toNode) | | :wikitext(toNode) |
Line 94: |
Line 107: |
| end | | end |
| end | | end |
− | return tostring(body) | + | return tostring(button) .. "\n" .. tostring(body) |
| end | | end |
− | | + | |
| function p.branchingTemplate(frame) | | function p.branchingTemplate(frame) |
| -- implementing graph as an adjacency list | | -- implementing graph as an adjacency list |
Line 104: |
Line 117: |
| collapsed = false | | collapsed = false |
| end | | end |
− | | + | |
| for param,value in pairs(frame.args) do | | for param,value in pairs(frame.args) do |
| local split = mw.text.split(param,"_") | | local split = mw.text.split(param,"_") |
Line 122: |
Line 135: |
| end | | end |
| local html = p.renderBranchingTable(mapGraph,collapsed) | | local html = p.renderBranchingTable(mapGraph,collapsed) |
− | | + | |
| return html | | return html |
− | | + | |
| end | | end |
− | | + | |
| return p | | return p |