Module:Large category TOC/sandbox: Difference between revisions

Content deleted Content added
i need to start from scratch later anyways...
No edit summary
Line 6:
 
-- Implements [[Template:Large Category TOC]]
function p.scrollablemain(frametoc_type)
-- It should be much faster to only process these once, and just re use them as variables
local pageurl = mw.title.getCurrentTitle():fullUrl()
Line 12:
-- Begins the "title" parameter of {{Navigation bar}} with Top of the category (no ?from) and numerals (?from=0)
local toc_frame = mw.html.create('div')
local title = '<div style="width:100%;">\n<span class="plainlinks">'..toc..':\n['..pageurl..' Top]'..
:addClass('plainlinks')
'\n['..pageurl..'?from=0 0-9]'
:addClass('hlist')
-- Add ?from=A through Z to the title bar
:attr('id', 'toc')
for i=1,26,1 do
:css('background', 'WhiteSmoke')
local letter = string.sub(azupper,i,i)
:css('clear', 'both')
title = title..'\n['..pageurl..'?from='..letter..' '..letter..']'
:css('width', '98%')
end
-- Closing tags
title = title..'\n</span>\n</div>'
-- Begin the list parameter with ?from=*
local list = '<div style="overflow-x:auto; overflow-y:hidden; width:98%;"><span class="plainlinks">'..
'\n['..pageurl..'?from=* *] •'
 
local header = mw.html.create('div')
-- Add ?from=0 through 9 to the list
:attr('id', 'toctitle')
for i=0,9,1 do
 
list = list..'\n['..pageurl..'?from='..i..' '..i..']'
local body = mw.html.create('div')
:css('text-align', 'center')
if toc_type == 'collapsible' then
toc_frame:addClass('NavFrame')
header:addClass('NavHeader')
body:addClass('NavContent')
:css('background','white')
:css('display','none')
elseif toc_type == 'scrollable' then
body:css('overflow-x','scroll')
:css('overflow-y','hidden')
end
-- A-Z loop that calls the a-z function
local header_content = '<strong>'..toc..':</strong>' ..
' ['..pageurl..' Top]' ..
' ['..pageurl..'?from=0 0&endash;9]'
for i=1,26,1 do
local letter = string.sub(azupper,i,i)
header_content = header_content..' ['..pageurl..'?from='..letter..' '..letter..']'
list = list..atoz(letter,true,true,pageurl)
end
-- Close tags
list = list..'\n</span></div>'
header:wikitext(header_content)
return frame:expandTemplate{title='Navigation bar',args={color='#f9f9f9;',title=title,list=list}}
end
 
-- Implements [[Template:Collapsible large category TOC]]
function p.collapsible(frame)
-- It should be much faster to only process these once, and just re use them as variables
local pageurl = mw.title.getCurrentTitle():fullUrl()
local body_content
local toc_string = '<div class="collapsible" style="background:transparent;">\n'..
'<div class="NavFrame" style="clear:both; background:WhiteSmoke;">\n'..
if toc_type == 'collapsible' then
'<div class="NavHead" style="background:WhiteSmoke;">\n'..
body_content = '<b>#</b> '
'<div class="plainlinks" id="kat_toc" style="background:WhiteSmoke; text-align:center; font-size:100%;">\n'..
else
'<b>Index:</b> ['..pageurl..' *] ['..pageurl..'?from=# 0-9]'
body_content = '['..pageurl..'?from=* <b>*</b>] <b>#</b> '
-- Add ?from=A through Z to the title bar
for i=1,26,1 do
local letter = string.sub(azupper,i,i)
toc_string = toc_string..' ['..pageurl..'?from='..letter..' '..letter..']'
end
-- Closing tags
toc_string = toc_string..'<span style="font-size: 85%;">(Click <i>Show</i> for more navigation options.)</span>'..
'\n</div>\n</div>'..
'<div class="NavContent" style="background:White; display:none;">'..
'<div class="plainlinks" style="background:White; font-size:100%; text-align:center;">'..
'\n----'..
'\n<code style="background:White;"> <b>#</b>'
-- Add ?from=0 through 9 to the list
for i=0,9,1 do
toc_stringbody_content = toc_stringbody_content..'\n ['..pageurl..'?from='..i..' '..i..']'
end
 
-- A-Z loop that calls the a-z function
for i=1,26,1 do
local letter = string.sub(azupper,i,i)
toc_stringbody_content = toc_stringbody_content..atoz(letter,false,true,pageurl)
end
-- Close tags
toc_string = toc_string..'\n</code>\n</div></div></div>'
local function atoz(letter)
return toc_string
local azlist
end
local letterlist
 
local maxind
function atoz(letter,bullets,fullaz,url)
if toc_type == 'aejot' then
local azlist
local letterlist = aejot
local maxind = 5
else
if fullaz then
letterlist = azlower
maxind = 26
end
else
letterlist = aejot
if toc_type == 'aejot' or toc_type == 'scrollable' then
maxind = 5
azlist = '\n• <b>'..letter..'</b> '
end
else
azlist = '\n<br /><b>'..letter..'</b> '
if bullets then
end
azlist = '\n• <b>'..letter..'</b> '
else
for i=1,maxind,1 do
azlist = '\n<br /><b>'..letter..'</b> '
local lowerletter = string.sub(letterlist,i,i)
azlist = azlist..' ['..pageurl..'?from='..letter..lowerletter..' '..letter..lowerletter..'] '
end
return azlist
end
body:wikitext(body_content)
for i=1,maxind,1 do
header:node(body)
local lowerletter = string.sub(letterlist,i,i)
toc_frame:node(header)
azlist = azlist..' ['..url..'?from='..letter..lowerletter..' '..letter..lowerletter..'] '
end
return azlisttostring(toc_frame)
end