Модуль:Archive list long
Перейти до навігації
Перейти до пошуку
Документація модуля[створити]
Зараз цей модуль не має відповідної документації. Якщо вам відомі призначення та засади використання цього модуля, будь ласка, напишіть хоча б коротеньку документацію. |
Дописувачі можуть експериментувати на підсторінках пісочниця (створити | дзеркало) та тести (створити) цього модуля. Підсторінки цієї сторінки. |
local p = {}
function p.main(frame)
parent = frame:getParent();
subpath = "";
if(parent.args["root"]) then subpath = parent.args["root"];
else subpath = mw.title.getCurrentTitle().fullText; end
subpath = subpath.."/Архів ";
last_existing = 0; first_nonexisting = 0;
currently_checked = 0; cc_increment = 2;
ex = true;
while(ex) do
currently_checked = currently_checked+cc_increment;
cc_increment = math.ceil(cc_increment*1.5);
ex = mw.title.new(subpath..tostring(currently_checked)).exists;
if(ex) then last_existing = currently_checked;
else first_nonexisting = currently_checked; end
end
while(first_nonexisting ~= last_existing+1) do
currently_checked = math.floor((last_existing+first_nonexisting)/2);
ex = mw.title.new(subpath..tostring(currently_checked)).exists;
if(ex) then last_existing = currently_checked;
else first_nonexisting = currently_checked; end
end
i = 1;
res = {'{| cellpadding="0" width="100%" style="text-align: center; background-color: transparent;"\n'};
while(i<=last_existing) do
if(i%3==1) then table.insert(res, '|-\n'); end
table.insert(res, '| [['..subpath..tostring(i)..'|Архів '..tostring(i)..']]\n');
i = i+1;
end
return frame:preprocess(table.concat(res)..'|}');
end
return p;