Magiczocker (토론 | 기여) (새 문서: local p = {} -- {{Protocol version}} function p.protocol_version( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge(...) |
Minejango2 (토론 | 기여) 잔글편집 요약 없음 |
||
76번째 줄: | 76번째 줄: | ||
if include then |
if include then |
||
− | + | if not args.notitle then |
|
+ | table.insert( html, "=== [[" .. group.link .. '|' .. group.name .. "]] ===\n" ) |
||
+ | end |
||
if group.desc ~= nil then |
if group.desc ~= nil then |
||
table.insert( html, group.desc .. '\n') |
table.insert( html, group.desc .. '\n') |
||
82번째 줄: | 84번째 줄: | ||
table.insert( html, "<table class='wikitable sortable jquery-tablesorter'>\n" ) |
table.insert( html, "<table class='wikitable sortable jquery-tablesorter'>\n" ) |
||
table.insert( html, '<tr>\n' ) |
table.insert( html, '<tr>\n' ) |
||
− | table.insert( html, '<th> |
+ | table.insert( html, '<th>Client version</th>\n' ) |
− | table.insert( html, '<th>Protocol |
+ | table.insert( html, '<th>[[Protocol version]]</th>\n' ) |
if group.has_data_versions then |
if group.has_data_versions then |
||
− | table.insert( html, '<th>Data |
+ | table.insert( html, '<th>[[Data version]]</th>\n' ) |
end |
end |
||
table.insert( html, '</tr>\n' ) |
table.insert( html, '</tr>\n' ) |
||
95번째 줄: | 97번째 줄: | ||
for __, version in ipairs(group.values) do |
for __, version in ipairs(group.values) do |
||
table.insert( html, '<tr>' ) |
table.insert( html, '<tr>' ) |
||
− | table.insert( html, '<td>[[' .. version.name .. ']]</td>' ) |
+ | table.insert( html, '<td>[[' .. version.name .. ']]</td>\n' ) |
if version.protocol ~= last_protocol or version.force_split then |
if version.protocol ~= last_protocol or version.force_split then |
||
last_protocol = version.protocol |
last_protocol = version.protocol |
||
num_same_protocol = 1 |
num_same_protocol = 1 |
||
− | table.insert( html, '<td>' .. version.protocol .. '</td>' ) |
+ | table.insert( html, '<td>' .. version.protocol .. '</td>\n' ) |
protocol_row = #html |
protocol_row = #html |
||
else |
else |
||
num_same_protocol = num_same_protocol + 1 |
num_same_protocol = num_same_protocol + 1 |
||
− | html[protocol_row] = '<td rowspan="' .. num_same_protocol .. '">' .. version.protocol .. '</td>' |
+ | html[protocol_row] = '<td rowspan="' .. num_same_protocol .. '">' .. version.protocol .. '</td>\n' |
end |
end |
||
if group.has_data_versions then |
if group.has_data_versions then |
||
if version.data then |
if version.data then |
||
− | table.insert( html, '<td>' .. version.data .. '</td>' ) |
+ | table.insert( html, '<td>' .. version.data .. '</td>\n' ) |
else |
else |
||
− | table.insert( html, '<td>—</td>' ) |
+ | table.insert( html, '<td>—</td>\n' ) |
end |
end |
||
end |
end |
||
− | table.insert( html, '</tr>' ) |
+ | table.insert( html, '</tr>\n' ) |
end |
end |
||
2019년 7월 20일 (토) 05:01 판
local p = {}
-- {{Protocol version}}
function p.protocol_version( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
end
local version = mw.text.trim( args[1] or '' )
-- load the values from the submodule
local version_data = mw.loadData( 'Module:Protocol version/Versions' ).versions[version]
local category = ''
local value
if version_data then
value = version_data.protocol
else
value = '[[Template:Protocol version#Unknown version|—]]'
local title = mw.title.getCurrentTitle()
if not args.nocat and title.namespace == 0 and not title.isSubpage then
category = '[[Category:Unknown Protocol version]]'
end
end
return value .. category
end
-- {{Data version}}
function p.data_version( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
end
local version = mw.text.trim( args[1] or '' )
-- load the values from the submodule
local version_data = mw.loadData( 'Module:Protocol version/Versions' ).versions[version]
local category = ''
local value
if version_data then
if version_data.data then
value = version_data.data
else
value = "N/A"
end
else
value = '[[Template:Data version#Unknown version|—]]'
local title = mw.title.getCurrentTitle()
if not args.nocat and title.namespace == 0 and not title.isSubpage then
category = '[[Category:Unknown Data version]]'
end
end
return value .. category
end
-- Version table ({{Protocol version/table}})
function p.table( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
end
local html = {}
local groups = mw.loadData( 'Module:Protocol version/Versions' ).groups
for _, group in ipairs(groups) do
local include = true
if #args ~= 0 then
include = nil
for __, name in ipairs(args) do
if name == group.name then
include = true
break
end
end
end
if include then
if not args.notitle then
table.insert( html, "=== [[" .. group.link .. '|' .. group.name .. "]] ===\n" )
end
if group.desc ~= nil then
table.insert( html, group.desc .. '\n')
end
table.insert( html, "<table class='wikitable sortable jquery-tablesorter'>\n" )
table.insert( html, '<tr>\n' )
table.insert( html, '<th>Client version</th>\n' )
table.insert( html, '<th>[[Protocol version]]</th>\n' )
if group.has_data_versions then
table.insert( html, '<th>[[Data version]]</th>\n' )
end
table.insert( html, '</tr>\n' )
local num_same_protocol
local last_protocol = -1
local protocol_row
for __, version in ipairs(group.values) do
table.insert( html, '<tr>' )
table.insert( html, '<td>[[' .. version.name .. ']]</td>\n' )
if version.protocol ~= last_protocol or version.force_split then
last_protocol = version.protocol
num_same_protocol = 1
table.insert( html, '<td>' .. version.protocol .. '</td>\n' )
protocol_row = #html
else
num_same_protocol = num_same_protocol + 1
html[protocol_row] = '<td rowspan="' .. num_same_protocol .. '">' .. version.protocol .. '</td>\n'
end
if group.has_data_versions then
if version.data then
table.insert( html, '<td>' .. version.data .. '</td>\n' )
else
table.insert( html, '<td>—</td>\n' )
end
end
table.insert( html, '</tr>\n' )
end
table.insert( html, '</table>\n' )
end
end
return table.concat( html )
end
return p