Jump to content

Module:vote timeline

From Wiktionary, the free dictionary

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

function export.timeline (frame)

	local args = frame:getParent().args

	local result = ""

	for k, v in pairs (args) do
		if k == 1 then
			result = result .. '<div class="NavFrame">'
			result = result .. '<div class="NavHead">' .. v .. '</div>'
			result = result .. '<div class="NavContent">'

			result = result .. '<table class="wikitable" style="width: 100%">'

			result = result .. '<tr>'
			result = result .. '<th>Ended</th>'
			result = result .. '<th>Title</th>'
			result = result .. '<th>Result</th>'
			result = result .. '</tr>'
		else
			if k%3 == 2 then
				result = result .. '<tr>'
				result = result .. '<td style="text-align: center; width: 80px"><b>' .. v .. '</b></td>'
			end

			if k%3 == 0 then
				local offset = mw.ustring.find (v, "/", 1, true)
				offset = offset + 1
				local voteNameWithoutPrefix = mw.ustring.sub (v, offset, 100000)
				result = result .. '<td style="text-align: left">[[Wiktionary:Votes/' .. v .. '|' .. voteNameWithoutPrefix .. ']]</td>'
			end

			if k%3 == 1 then
				result = result .. '<td style="text-align: left; width: 250px"><b>' .. v .. '</b></td>'
				result = result .. '</tr>'
			end
		end
	end

	result = result .. '</table>'

	result = result .. '</div>'
	result = result .. '</div>'

	return result

end

return export