Иһинээҕитигэр көс

Модуль:Gradation

Бикитиэкэ диэн сиртэн ылыллыбыт

Для документации этого модуля может быть создана страница Модуль:Gradation/doc

-- uk.wikisource.org/wiki/User:Leh_Palych

local p = {}

-- 
function p.indexes(frame)
	local out, ind

ind = {
	{'Индекс — быһа тардыы эрэ','#dddddd','',0,'Кэҥэтэргэ'},
	{'Индекс — көннөрөргө','#dddddd','',0,'Көннөрөргө'},
	{'Индекс — тиэкис араҥата наада','','quality0',0,'OCR наадалаах'},
	{'Индекс — араарга','','quality2',0,'Араарарга'},
	{'Индекс — ааҕыллыбатах','','quality1',0,'Ааҕарга'},
	{'Индекс — көрүллүбүт','','quality3',0,'Ааҕыллыбыт'},
	{'Индекс — бэлэм','','quality4',0,'Бэлэм'}}

	out = create_table(ind, true)

	return out
end 	
--
function p.pages(frame)
	local out, pages
	pages = {
		{'Кураанах','','quality0',0,'Тиэкиһэ суох'},
		{'Ааҕыллыбатах','','quality1',0,'Ааҕыллыбатах'},
		{'Моһоллоох','','quality2',0,'Моһоллоох'},
		{'Ааҕыллыбыт','','quality3',0,'Ааҕыллыбыт'},
		{'Бэрэбиэркэлэммит','','quality4',0,'Бэрэбиэркэлэммит'},
		}


	out = create_table(pages, false)
	
	return out
end 	
--
function create_table(array, link)
	local out
	local i, num_pages, n_max, cell_end, color, class, pcnt, total, total_pcnt, name

	out = '{| cellspacing=0 cellpadding=0 width=100% style="text-align:center; font-size:73%; border-collapse: collapse; border: 1px dotted #808080;"\n'
	out = out .. '|-\n'
	
	n_max = #array
	
	total = 0
	for i=1, n_max do
		num_pages = mw.site.stats.pagesInCategory( array[i][1], 'pages' )
		array[i][4] = num_pages
		total = total + num_pages
	end

	out = out .. '|'
	total_pcnt = 0
	for i=1, n_max do
		num_pages = array[i][4]
		if num_pages > 0 then
			if i == n_max then
				pcnt = 100 - total_pcnt
				cell_end = ''
			else
				pcnt = math.ceil(num_pages * 100 / total)
				cell_end = '||'
			end
--[[
			if array[i][2] ~= '' then
				array[i][2] = 'background-color:' .. array[i][2] .. '; color:inherit;'
			end
--]]
			if array[i][3] ~= '' then
				array[i][3] = 'class="' .. array[i][3] .. '"'
			end
			
			out = out .. 'style="width:' .. pcnt .. '%;' .. array[i][2] .. '" ' .. array[i][3] .. '|' .. num_pages .. cell_end

			total_pcnt = total_pcnt + pcnt
		end
	end

	out = out .. '\n|}\n'
	out = out .. '<div style="margin:1em 2em 0">\n'
	out = out .. '{| cellspacing=0\n'
	for i=1, n_max do
		num_pages = array[i][4]
		if num_pages > 0 then
			out = out .. '|-\n'
			out = out .. '|<span style="padding:0 0.5em; border: 1px darkgray dotted;' .. array[i][2] .. '" ' .. array[i][3] .. '>&nbsp;</span>'
			if link then
				name = '[[:Категория:' .. array[i][1] .. '|' .. array[i][5] .. ']]'
			else
				name = array[i][5]
			end

			out = out .. '&nbsp;' .. name .. '||&nbsp;:&nbsp;||style="font-size:85%; text-align:right;"|' .. num_pages .. '\n'
		end
	end
	out = out .. '|}\n</div>'

	return out
end 	

--

return p