Module:Transclude random page: Difference between revisions
Jump to navigation
Jump to search
no edit summary
imported>Camenati (Created page with "local p = {} local mRandom = require('Module:Random') local currentTitle = mw.title.getCurrentTitle() local function getRandomNumber(max) -- Gets a random integer between 1 and max; max defaults to 1 return mRandom.number{max or 1} end local function expandArg(args, key) -- Emulate how unspecified template parameters appear in wikitext. If the -- specified argument exists, its value is returned, and if not the argument -- name is returned inside tr...") |
imported>Camenati No edit summary |
||
| Line 57: | Line 57: | ||
local max = args.max or 1 | local max = args.max or 1 | ||
local r = getRandomNumber(max) | local r = getRandomNumber(max) | ||
local num = ((r - 1) % max) + 1 | |||
local ret = prefix .. getRandomPageContent(frame, pages, num) | |||
if args.more then | if args.more then | ||
ret | ret = ret .. string.format('<div class="noprint" style="float: right;"><b>[[%s|%s]]</b></div>', pages.randompage, args.more) | ||
end | end | ||
if args.leftfooter then | if args.leftfooter then | ||
ret | ret = ret .. string.format('<div class="noprint" style="float: left;">%s</div>', args.leftfooter) | ||
end | end | ||
if args.rightfooter then | if args.rightfooter then | ||
ret | ret = ret .. string.format('<div class="noprint" style="float: right;">%s</div>', args.rightfooter) | ||
end | end | ||
return | return ret | ||
end | end | ||