| 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 | | -- 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 uniqueID = remiLib.timeHash(graph) |
| − |
| |
| | local classString = "mw-customtoggle-" .. tostring(uniqueID) | | local classString = "mw-customtoggle-" .. tostring(uniqueID) |
| | local idString = "mw-customcollapsible-" .. tostring(uniqueID) | | local idString = "mw-customcollapsible-" .. tostring(uniqueID) |
| − |
| + | |
| | local button = mw.html.create('div') | | local button = mw.html.create('div') |
| | button | | button |
| Line 21: |
Line 20: |
| | :addClass("globalbutton") | | :addClass("globalbutton") |
| | :wikitext("Show/Hide Branching Rules") | | :wikitext("Show/Hide Branching Rules") |
| − |
| + | |
| | local body = mw.html.create("table") | | local body = mw.html.create("table") |
| | body | | body |
| Line 29: |
Line 28: |
| | :attr("id",idString) | | :attr("id",idString) |
| | :css("width","300px") | | :css("width","300px") |
| − |
| + | |
| | 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 91: |
Line 90: |
| | end | | end |
| | col = mw.html.create("td") | | col = mw.html.create("td") |
| − |
| + | |
| | col | | col |
| | :wikitext(toNode) | | :wikitext(toNode) |
| Line 109: |
Line 108: |
| | return tostring(button) .. "\n" .. 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 117: |
Line 116: |
| | 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 135: |
Line 134: |
| | end | | end |
| | local html = p.renderBranchingTable(mapGraph,collapsed) | | local html = p.renderBranchingTable(mapGraph,collapsed) |
| − |
| + | |
| | return html | | return html |
| − |
| + | |
| | end | | end |
| − |
| + | |
| | return p | | return p |