Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:FBI QR code: Difference between revisions

From Hacks Guide Wiki
ugh
No edit summary
Line 1: Line 1:
local args = {}
local p = {}
local p = {}


Line 25: Line 23:
-- for the specified prefix. For example, if the prefix was 'data', and
-- for the specified prefix. For example, if the prefix was 'data', and
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
local function getArgNums(prefix)
local function getArgNums(prefix, args)
local nums = {}
local nums = {}
for k, v in pairs(args) do
for k, v in pairs(args) do
Line 35: Line 33:
end
end


function p.makeSections(frame)
function p.makeSections(frame, args)
local sections = {}
local sections = {}
local nums = union(getArgNums('name'), getArgNums('url'))
local nums = union(getArgNums('name', args), getArgNums('url', args))
for k, v in ipairs(nums) do
for k, v in ipairs(nums) do
local name = args['name' .. tostring(num)]
local name = args['name' .. tostring(num)]
local url = args['name' .. tostring(num)]
local url = args['url' .. tostring(num)]
if name and url then
if name and url then
local qr = frame:callParserFunction('#qrlite', {url, format = 'svg', margin = '3'})
local qr = frame:callParserFunction('#qrlite', {url, format = 'svg', margin = '3'})
Line 66: Line 64:
function p.main(frame)
function p.main(frame)
local parent = frame:getParent()
local parent = frame:getParent()
-- adapted from [[Module:Infobox]]
if frame == mw.getCurrentFrame() then
args = frame:getParent().args
else
args = frame
end


local sections = p.makeSections(parent)
local sections = p.makeSections(parent, parent.args)
return p.makeTabber(parent, sections)
return p.makeTabber(parent, sections)
end
end


function p.template(frame)
function p.template(frame)
args = frame.args
local sections = p.makeSections(frame.args)
local sections = p.makeSections(frame)
return p.makeTabber(frame, sections)
return p.makeTabber(frame, sections)
end
end


return p
return p