local p = {}
local paramtest = require('Module:Paramtest')
local default_to = paramtest.default_to
local has_content = paramtest.has_content
function p.display_results( frame )
	local parameters = frame:getParent().args
	local title = parameters['title'] or 'TITLE'
	local startDate = parameters['start'] or 'START DATE'
	local endDate = parameters['end'] or 'END DATE'
	local votesContainer = mw.html.create('div'):done()
	local MAX_ROWS = 20
	local totalvotes = 0
	local topVote = 0
	for i=1,MAX_ROWS,1 do
		if has_content(parameters['option'..i]) then
			local votes = tonumber(default_to(parameters['votes'..i], '0'))
			totalvotes = totalvotes + votes
			if(votes > topVote) then topVote = votes end
	for i=1,MAX_ROWS,1 do
		local optionText = parameters['option'..i]
		if has_content(optionText) then
			local votes = tonumber(default_to(parameters['votes'..i], '0'))
			votesContainer:node(p._make_row(optionText,votes,totalvotes,votes >= topVote))
	local table_string = mw.html.create('')
		:tag('h3'):wikitext(title):css({ ["border-bottom"]="1px solid #B2AF9C", ["text-align"]="center" }):done()
			:tag('div'):wikitext("<br />'''Start Date''': "..startDate..
				"<br />'''End Date''': "..endDate..
				"<br />'''Total Votes''': "..totalvotes):done()
	return tostring(table_string)
function p._make_row(pText, pVotes, pTotal, pWon)
	local function cleanDecimal(pNum) return math.floor(pNum * 100) / 100 end
	local percent = cleanDecimal(pVotes / pTotal * 100)
	local percentText = ''
	if percent ~= 0 then percentText = ' - '..percent..'% of all votes' end
	if pWon then pText = '<span style="color:brown;">☆</span> '..pText end
	local total_row = mw.html.create('div'):addClass('pollAnswer')
			:tag('div'):css({ ['width'] = percent..'%' }):done()
	return total_row
function p._empty(value)
	return not (value == nil or value == "")
return p

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.