跳转到内容

模組:Carousel

维基百科,自由的百科全书

这是本页的一个历史版本,由PhiLiP留言 | 贡献2017年2月14日 (二) 05:15编辑。这可能和当前版本存在着巨大的差异。

local p = {}

function getCandidateList(args)
	local page = mw.title.new(args.pageName)
	return mw.text.jsonDecode(page:getContent(), mw.text.JSON_TRY_FIXING)
end

function p.main(frame)
	local candidateList = getCandidateList{pageName = frame.args.candidateList}
	local timeStart = tonumber(frame.args.timeStart) or 0
	local timeInterval = tonumber(frame.args.timeInterval) or 86400
	local index0 = math.floor((os.time() - timeStart) / 86400) % #candidateList
	local currentPage = candidateList[index0 + 1]
	return mw.getCurrentFrame():expandTemplate { title = currentPage }
end

return p