پودمان:Currency exchanges

نماد توضیحات توضیحات پودمان[ایجاد]
local p = {}

p.data = require('Module:Currency exchanges/data')
p.date = require('Module:Date')

function p.table(frame)
	local out = '<table dir="rtl" class="wikitable sortable" style="text-align: center; margin-right: auto; margin-left: auto;">'
	out = out .. '<tr>'
		out = out .. '<th colspan="5" style="background: #ccc;">'
		local req = {}
		req.args = {'l j F Y h:i:s A','jalali','Asia/Tehran','fa',p.data.time}
		out = out .. '<span style="font-size: 120%;">نرخ برابری ارز</span><br/>به روز رسانی: ' .. p.date.date(req)
		out = out .. '</th>'
	out = out .. '</tr>'
	out = out .. '<tr>'
		out = out .. '<th>کد</th>'
		out = out .. '<th>نام</th>'
		out = out .. '<th>نماد</th>'
		out = out .. '<th>نماد بین‌المللی</th>'
		out = out .. '<th data-sort-type="number">ارزش هر دلار آمریکا</th>'
	out = out .. '</tr>'
	for id,data in pairs(p.data.currencies) do
		out = out .. '<tr>'
			out = out .. '<td>'
				out = out .. id
			out = out .. '</td>'
			out = out .. '<td>'
				if data['fa'] ~= "" then
					out = out .. '[[w:' .. data['fa'] .. '|' .. data['fa_title'] .. ']]<br>'
				end
				if data['en'] ~= '' then
					out = out .. '([[wikipedia:' .. data['en'] .. '|' .. data['en_title'] .. ']])'
				else
					out = out .. '(' .. data['name'] .. ')'
				end
			out = out .. '</td>'
			out = out .. '<td>'
				out = out .. data['local_symbol']
			out = out .. '</td>'
			out = out .. '<td>'
				out = out .. data['symbol']
			out = out .. '</td>'
			out = out .. '<td data-sort-value="' .. data['value'] .. '">'
				out = out .. mw.getLanguage("fa"):formatNum(tonumber(data['value']))
			out = out .. '</td>'
		out = out .. '</tr>'
	end
	out = out .. '</table>'
	return out
end

function p.small_table(frame)
	local currencies = {'EUR','GBP','CNY','IRR','AED'}
	local out = '<table dir="rtl" class="wikitable sortable" style="text-align: center; margin-right: auto; margin-left: auto;">'
	out = out .. '<tr>'
		out = out .. '<th colspan="5" style="background: #ccc;">'
		local req = {}
		req.args = {'l j F Y h:i:s A','jalali','Asia/Tehran','fa',p.data.time}
		out = out .. 'به روز رسانی: ' .. p.date.date(req)
		out = out .. '</th>'
	out = out .. '</tr>'
	out = out .. '<tr>'
		out = out .. '<th>کد</th>'
		out = out .. '<th>نام</th>'
		out = out .. '<th>نماد</th>'
		out = out .. '<th data-sort-type="number">ارزش هر دلار آمریکا</th>'
	out = out .. '</tr>'
	for i in pairs(currencies) do
		local id = currencies[i]
		local data = p.data.currencies[id]
		out = out .. '<tr>'
			out = out .. '<td>'
				out = out .. id
			out = out .. '</td>'
			out = out .. '<td>'
				if data['fa'] ~= "" then
					out = out .. '[[w:' .. data['fa'] .. '|' .. data['fa_title'] .. ']]<br>'
				end
			out = out .. '</td>'
			out = out .. '<td>'
				out = out .. data['local_symbol']
			out = out .. '</td>'
			out = out .. '<td data-sort-value="' .. data['value'] .. '">'
				out = out .. mw.getLanguage("fa"):formatNum(tonumber(data['value']))
			out = out .. '</td>'
		out = out .. '</tr>'
	end
	out = out .. '</table>'
	return out
end

return p