<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3APoll</id>
	<title>Module:Poll - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3APoll"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Poll&amp;action=history"/>
	<updated>2026-06-17T03:33:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:Poll&amp;diff=34204&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {}  local params = require(&#039;Module:Paramtest&#039;) local commas = require(&#039;Module:Addcommas&#039;)._add local math = math  function p.main(frame) 	local args = frame:getParent().args 	local pollQuestion = args.Question 	local note = args.Note 	local totalVotes = findTotalVotes(args) 	local answers = answerList(args) 	 	local wrapper = mw.html.create(&#039;div&#039;):addClass(&#039;pollbox&#039;):addClass(&#039;pollquestion&#039;):done() 	local tbl = mw.html.create(&#039;table&#039;):done() 	tbl:tag(&#039;caption&#039;)...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Poll&amp;diff=34204&amp;oldid=prev"/>
		<updated>2024-10-15T23:29:39Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  local params = require(&amp;#039;Module:Paramtest&amp;#039;) local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add local math = math  function p.main(frame) 	local args = frame:getParent().args 	local pollQuestion = args.Question 	local note = args.Note 	local totalVotes = findTotalVotes(args) 	local answers = answerList(args) 	 	local wrapper = mw.html.create(&amp;#039;div&amp;#039;):addClass(&amp;#039;pollbox&amp;#039;):addClass(&amp;#039;pollquestion&amp;#039;):done() 	local tbl = mw.html.create(&amp;#039;table&amp;#039;):done() 	tbl:tag(&amp;#039;caption&amp;#039;)...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local params = require(&amp;#039;Module:Paramtest&amp;#039;)&lt;br /&gt;
local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add&lt;br /&gt;
local math = math&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	local pollQuestion = args.Question&lt;br /&gt;
	local note = args.Note&lt;br /&gt;
	local totalVotes = findTotalVotes(args)&lt;br /&gt;
	local answers = answerList(args)&lt;br /&gt;
	&lt;br /&gt;
	local wrapper = mw.html.create(&amp;#039;div&amp;#039;):addClass(&amp;#039;pollbox&amp;#039;):addClass(&amp;#039;pollquestion&amp;#039;):done()&lt;br /&gt;
	local tbl = mw.html.create(&amp;#039;table&amp;#039;):done()&lt;br /&gt;
	tbl:tag(&amp;#039;caption&amp;#039;):wikitext(pollQuestion):done()&lt;br /&gt;
	&lt;br /&gt;
	if #answers ~= 0 then&lt;br /&gt;
		for i, v in ipairs(answers) do&lt;br /&gt;
			local tr = mw.html.create(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			local sword, count&lt;br /&gt;
			local calculation = v.count * 100 / totalVotes&lt;br /&gt;
			tr:tag(&amp;#039;td&amp;#039;):wikitext(v.text):done()&lt;br /&gt;
			&lt;br /&gt;
			if v.text ~= &amp;#039;Skip question&amp;#039; and v.text ~= &amp;#039;Skip&amp;#039; then&lt;br /&gt;
				local swordCount = findSwordsCount(calculation)&lt;br /&gt;
				local td = mw.html.create(&amp;#039;td&amp;#039;):addClass(&amp;#039;pollpercent&amp;#039;):done()&lt;br /&gt;
				local data = mw.html.create(&amp;#039;data&amp;#039;):attr(&amp;#039;value&amp;#039;, swordCount):css({ [&amp;#039;width&amp;#039;] = string.format(&amp;#039;%s%%&amp;#039;, swordCount) }):done()&lt;br /&gt;
				tr:node(td:node(data))&lt;br /&gt;
				tr:tag(&amp;#039;td&amp;#039;):wikitext(string.format(&amp;#039;%s%% (%s votes)&amp;#039;, calculatePercentage(v.count, calculation), commas(v.count))):done()&lt;br /&gt;
			else&lt;br /&gt;
				tr:tag(&amp;#039;td&amp;#039;):addClass(&amp;#039;pollpercent&amp;#039;):wikitext(&amp;#039;[[File:Placeholder.png|link=]]&amp;#039;):done()&lt;br /&gt;
				tr:tag(&amp;#039;td&amp;#039;):wikitext(string.format(&amp;#039;%s votes&amp;#039;, commas(v.count))):done()&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			tbl:node(tr)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if note ~= nil then&lt;br /&gt;
		local tr = mw.html.create(&amp;#039;tr&amp;#039;):addClass(&amp;#039;pollnote&amp;#039;):done()&lt;br /&gt;
		tr:tag(&amp;#039;td&amp;#039;):attr(&amp;#039;colspan&amp;#039;, 3):wikitext(string.format(&amp;quot;Note: %s&amp;quot;, note)):done()&lt;br /&gt;
		tbl:node(tr)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	wrapper:node(tbl)&lt;br /&gt;
	&lt;br /&gt;
	return tostring(wrapper)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function answerList(args)&lt;br /&gt;
	local answers = {}&lt;br /&gt;
	for i = 1, 40, 1 do&lt;br /&gt;
		local answer = args[&amp;#039;Answer&amp;#039;..i]&lt;br /&gt;
		if answer and params.has_content(answer) then&lt;br /&gt;
			local text = answer&lt;br /&gt;
			local count = args[&amp;#039;Votes&amp;#039;..i]&lt;br /&gt;
			table.insert(answers, {&lt;br /&gt;
				text = text,&lt;br /&gt;
				count = count&lt;br /&gt;
			})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return answers&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function findTotalVotes(args)&lt;br /&gt;
	local total = 0&lt;br /&gt;
	for i = 1, 40, 1 do&lt;br /&gt;
		local votes = args[&amp;#039;Votes&amp;#039;..i]&lt;br /&gt;
		if votes and params.has_content(votes) then&lt;br /&gt;
			local answer = args[&amp;#039;Answer&amp;#039;..i]&lt;br /&gt;
			if answer ~= &amp;#039;Skip question&amp;#039; and answer ~= &amp;#039;Skip&amp;#039; then&lt;br /&gt;
				total = total + tonumber(votes)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return total&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function findSwordsCount(calculation)&lt;br /&gt;
	local value = 0&lt;br /&gt;
	if calculation &amp;lt; 0.4 then&lt;br /&gt;
		return value&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if calculation &amp;lt; 25 then&lt;br /&gt;
		value = value + round(calculation)&lt;br /&gt;
	else&lt;br /&gt;
		value = value + 25&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if calculation &amp;lt; 50 then&lt;br /&gt;
		if calculation &amp;gt; 25 then&lt;br /&gt;
			value = value + round(calculation - 25)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		value = value + 25	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if calculation &amp;lt; 75 then&lt;br /&gt;
		if calculation &amp;gt; 54 then&lt;br /&gt;
			value = value + round(calculation - 50)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		value = value + 25&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if calculation &amp;lt; 100 then&lt;br /&gt;
		if calculation &amp;gt; 75 then&lt;br /&gt;
			value = value + round(calculation - 75)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		value = value + 25	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function calculatePercentage(votes, calculation)&lt;br /&gt;
	return math.ceil((round(calculation, 1) * 10)) / 10&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function round(num, numDecimalPlaces)&lt;br /&gt;
  local mult = 10 ^ (numDecimalPlaces or 0)&lt;br /&gt;
  return math.floor(num * mult + 0.5) / mult&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>