Модуль:Участник:Nitobus/test
Перейти к навигации
Перейти к поиску
Документация
-- https://ru.wikipedia.org/wiki/Lua
-- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual/ru
local p = {} --p означает package (пакет)
local Data = mw.loadData("Модуль:Участник:Nitobus/test/data")
function p.hello( frame )
local args = frame.args
if args == nil then return "Не указан параметр!" end
local Param1 = args[1]
if Param1 == nil then return "Не указан параметр!!" end
Param1 = mw.text.trim(Param1)
--return frame:getParent().args[1]
return "Hello, " .. Param1 .. "! " .. Data.Struct.StructKey1 .. " \n" ..
Data['key1'] .. " " .. Data['List1']['List1_Key1'][1] .. " " .. Data['Array1'][1][1] .. " \n" ..
Data[args[2]] .. " " .. Data[args[3]][args[4]][2] .. " " .. Data[args[5]][2][2] .. " \n"
end
function p.OG( frame )
return Data['1896/1'][1][1] ..' '.. Data['1896/1'][1][2] ..' '.. Data['1896/1'][1][3] ..' '.. Data['1896/1'][1][4] ..' '..
Data['1896/1'][1][5][1] ..' '.. Data['1896/1'][1][5][2] ..' '..Data['1896/1'][1][5][3][1] ..' '..
Data['1896/1'][1][6][1] ..' '.. Data['1896/1'][1][6][2] ..' '..Data['1896/1'][1][6][3][1]
end
function p.createTable( frame )
local div = mw.html.create( 'div' )
div
:attr( 'id', 'testdiv' )
:css( 'width', '100%' )
:wikitext( 'Some text' )
-- :tag( 'hr' )
local _html = mw.html.create()
tbl = _html
:tag('table')
:addClass('wikitable')
:addClass('sortable')
:addClass('plainrowheaders')
:addClass('jquery-tablesorter')
:css('text-align', 'center')
tbl:tag('caption')
:wikitext('caption_text')
local row = tbl:tag('tr')
row:tag('th')
:attr('scope', 'col')
:wikitext('Rank')
:tag('th')
:attr('scope', 'col')
:wikitext('Nation')
:tag('th')
:attr('scope', 'col')
:addClass('headerSort')
:css('width', '4em')
:css('background-color', 'gold')
:wikitext('Gold')
:tag('th')
:attr('scope', 'col')
:addClass('headerSort')
:css('width', '4em')
:css('background-color', 'silver')
:wikitext('Silver')
:tag('th')
:attr('scope', 'col')
:addClass('headerSort')
:css('width', '4em')
:css('background-color', '#c96')
:wikitext('Bronze')
:tag('th')
:attr('scope', 'col')
:css('width', '4em')
:wikitext('Total')
local row2 = tbl:tag('tr')
row2:tag('th')
:attr('scope', 'row')
:css('background-color', color)
:css('text-align','left')
:wikitext('1')
:tag('td')
:wikitext('RUS')
:tag('td')
:wikitext(1)
:tag('td')
:wikitext(2)
:tag('td')
:wikitext(3)
:tag('td')
:wikitext(6)
tbl:tag('tr')
:tag('td')
:wikitext('-')
:tag('td')
:css('font-style', 'italic')
:css('text-align','left')
:wikitext('TOTAL')
:tag('td')
:wikitext(0)
:tag('td')
:wikitext(0)
:tag('td')
:wikitext(0)
:tag('td')
:wikitext(0)
return tostring( div ) .. ' ' .. tostring( tbl )
end
return p