今天是2024年6月29日 第26周 星期六

代人,时大变了。

我们生活在大地上,但我们的梦想超越天空。

“模块:NoteTA”的版本间的差异

来自Akarin
跳到导航 跳到搜索
第3行: 第3行:
  
 
function Tcode( args )
 
function Tcode( args )
   if args.T == nil or args.T == '' then
+
if args.T == nil or args.T == '' then
     return ''
+
return ''
   end
+
end
   local div = mw.html.create( 'div' )
+
local div = mw.html.create( 'div' )
     :attr( 'class', 'noteTA-title' )
+
:attr( 'class', 'noteTA-title' )
     :attr( 'data-noteta-code', mw.uri.encode( args.T ) )
+
:attr( 'data-noteta-code', mw.uri.encode( args.T ) )
     :wikitext( WikitextLC.title( args.T ) )
+
:wikitext( WikitextLC.title( args.T ) )
   if args.dt ~= nil and args.dt ~= '' then
+
if args.dt ~= nil and args.dt ~= '' then
     div:attr( 'data-noteta-desc', mw.uri.encode( args.dt ) )
+
div:attr( 'data-noteta-desc', mw.uri.encode( args.dt ) )
   end
+
end
   return tostring( div )
+
return tostring( div )
 
end
 
end
  
 
function group( name, frame )
 
function group( name, frame )
   if name == nil or name == '' then
+
if name == nil or name == '' then
     return ''
+
return ''
   end
+
end
   local title = mw.title.makeTitle( 'Template', 'CGroup/' .. name )
+
local title = mw.title.makeTitle( 'Template', 'CGroup/' .. name )
   if title and title.exists then
+
if title and title.exists then
     return frame:expandTemplate{ title = title }
+
return frame:expandTemplate{ title = title }
   else
+
else
     return tostring( mw.html.create( 'div' )
+
return tostring( mw.html.create( 'div' )
         -- :attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
+
-- :attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
         :attr( 'class', 'noteTA-missing' )
+
:attr( 'class', 'noteTA-missing' )
         :attr( 'data-noteta-group', name ) )
+
:attr( 'data-noteta-group', name ) )
   end
+
end
 
end
 
end
  
 
function Gcode( args, frame )
 
function Gcode( args, frame )
   local code = {}
+
local code = {}
   for i = 1, 30 do
+
for i = 1, 30 do
     table.insert( code, group( args['G' .. i], frame ) )
+
table.insert( code, group( args['G' .. i], frame ) )
   end
+
end
   code = table.concat( code )
+
code = table.concat( code )
   if code ~= '' then
+
if code ~= '' then
     code = tostring( mw.html.create( 'div' )
+
code = tostring( mw.html.create( 'div' )
         :attr( 'class', 'noteTA-group' )
+
:attr( 'class', 'noteTA-group' )
         :wikitext( code ) )
+
:wikitext( code ) )
     if args.G31 ~= nil then
+
if args.G31 ~= nil then
       code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|G]]'
+
code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|G]]'
     end
+
end
   end
+
end
   return code
+
return code
 
end
 
end
  
 
function local_( i, code, desc )
 
function local_( i, code, desc )
   if code == nil or code == '' then
+
if code == nil or code == '' then
     return ''
+
return ''
   end
+
end
   local div = mw.html.create( 'div' )
+
local div = mw.html.create( 'div' )
     :attr( 'class', 'noteTA-local-' .. i )
+
:attr( 'class', 'noteTA-local-' .. i )
     :attr( 'data-noteta-code', mw.uri.encode( code ) )
+
:attr( 'data-noteta-code', mw.uri.encode( code ) )
     :wikitext( WikitextLC.hidden( code ) )
+
:wikitext( WikitextLC.hidden( code ) )
   if desc ~= nil and desc ~= '' then
+
if desc ~= nil and desc ~= '' then
     div:attr( 'data-noteta-desc', mw.uri.encode( desc ) )
+
div:attr( 'data-noteta-desc', mw.uri.encode( desc ) )
   end
+
end
   return tostring( div )
+
return tostring( div )
 
end
 
end
  
 
function Lcode( args )
 
function Lcode( args )
   local code = {}
+
local code = {}
   for i = 1, 30 do
+
for i = 1, 30 do
     table.insert( code, local_( i, args[i], args['d' .. i] ) )
+
table.insert( code, local_( i, args[i], args['d' .. i] ) )
   end
+
end
   code = table.concat( code )
+
code = table.concat( code )
   if code ~= '' then
+
if code ~= '' then
     code = tostring( mw.html.create( 'div' )
+
code = tostring( mw.html.create( 'div' )
         :attr( 'class', 'noteTA-local' )
+
:attr( 'class', 'noteTA-local' )
         :wikitext( code ) )
+
:wikitext( code ) )
     if args[31] ~= nil then
+
if args[31] ~= nil then
       code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|L]]'
+
code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|L]]'
     end
+
end
   end
+
end
   return code
+
return code
 
end
 
end
  
 
function z.main( frame )
 
function z.main( frame )
   local args = frame:getParent().args
+
local args = frame:getParent().args
   local Tc = Tcode( args )
+
local Tc = Tcode( args )
   local Gc = Gcode( args, frame )
+
local Gc = Gcode( args, frame )
   local Lc = Lcode( args )
+
local Lc = Lcode( args )
   local code = Tc .. Gc .. Lc
+
local code = Tc .. Gc .. Lc
   if code ~= '' then
+
if code ~= '' then
     code = frame:expandTemplate{
+
local hash = 0
       title = 'topicon',
+
for i = 1, code:len() do
       args = {
+
hash = 31 * hash + code:sub(i, i):byte()
         class = 'noteTA-topicon',
+
end
         image = 'Zh conversion icon m.svg',
+
code = frame:expandTemplate{
         alt = '本页使用了标题或全文手工转换',
+
title = 'topicon',
         title = '本页使用了标题或全文手工转换',
+
args = {
         link = '',
+
id = 'noteTA-topicon-' .. hash,
         size = '35px',
+
class = 'noteTA-topicon',
       },
+
image = 'Zh conversion icon m.svg',
     } .. tostring( mw.html.create( 'div' )
+
alt = '本页使用了标题或全文手工转换',
         :attr( 'class', 'noteTA' )
+
title = '本页使用了标题或全文手工转换',
         :wikitext( code ) )
+
link = '',
     if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
+
size = '35px',
       code = code .. '[[Category:放置于模板的noteTA]]'
+
},
     end
+
} .. tostring( mw.html.create( 'div' )
   end
+
:attr( 'id', 'noteTA-' .. hash )
   return code
+
:attr( 'class', 'noteTA' )
 +
:wikitext( code ) )
 +
if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
 +
code = code .. '[[Category:放置于模板的noteTA]]'
 +
end
 +
end
 +
return code
 
end
 
end
  
 
return z
 
return z

2014年6月7日 (六) 18:23的版本

50px 模块文档[查看] [编辑] [历史] [清除缓存]

本模块用于执行{{NoteTA}}模板,请到模板页阅读具体用法。

local z = {}
local WikitextLC = require( 'Module:WikitextLC' )

function Tcode( args )
	if args.T == nil or args.T == '' then
		return ''
	end
	local div = mw.html.create( 'div' )
		:attr( 'class', 'noteTA-title' )
		:attr( 'data-noteta-code', mw.uri.encode( args.T ) )
		:wikitext( WikitextLC.title( args.T ) )
	if args.dt ~= nil and args.dt ~= '' then
		div:attr( 'data-noteta-desc', mw.uri.encode( args.dt ) )
	end
	return tostring( div )
end

function group( name, frame )
	if name == nil or name == '' then
		return ''
	end
	local title = mw.title.makeTitle( 'Template', 'CGroup/' .. name )
	if title and title.exists then
		return frame:expandTemplate{ title = title }
	else
		return tostring( mw.html.create( 'div' )
				-- :attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
				:attr( 'class', 'noteTA-missing' )
				:attr( 'data-noteta-group', name ) )
	end
end

function Gcode( args, frame )
	local code = {}
	for i = 1, 30 do
		table.insert( code, group( args['G' .. i], frame ) )
	end
	code = table.concat( code )
	if code ~= '' then
		code = tostring( mw.html.create( 'div' )
				:attr( 'class', 'noteTA-group' )
				:wikitext( code ) )
		if args.G31 ~= nil then
			code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|G]]'
		end
	end
	return code
end

function local_( i, code, desc )
	if code == nil or code == '' then
		return ''
	end
	local div = mw.html.create( 'div' )
		:attr( 'class', 'noteTA-local-' .. i )
		:attr( 'data-noteta-code', mw.uri.encode( code ) )
		:wikitext( WikitextLC.hidden( code ) )
	if desc ~= nil and desc ~= '' then
		div:attr( 'data-noteta-desc', mw.uri.encode( desc ) )
	end
	return tostring( div )
end

function Lcode( args )
	local code = {}
	for i = 1, 30 do
		table.insert( code, local_( i, args[i], args['d' .. i] ) )
	end
	code = table.concat( code )
	if code ~= '' then
		code = tostring( mw.html.create( 'div' )
				:attr( 'class', 'noteTA-local' )
				:wikitext( code ) )
		if args[31] ~= nil then
			code = code .. '[[Category:NoteTA模板参数使用数量超过限制的页面|L]]'
		end
	end
	return code
end

function z.main( frame )
	local args = frame:getParent().args
	local Tc = Tcode( args )
	local Gc = Gcode( args, frame )
	local Lc = Lcode( args )
	local code = Tc .. Gc .. Lc
	if code ~= '' then
		local hash = 0
		for i = 1, code:len() do
			hash = 31 * hash + code:sub(i, i):byte()
		end
		code = frame:expandTemplate{
			title = 'topicon',
			args = {
				id = 'noteTA-topicon-' .. hash,
				class = 'noteTA-topicon',
				image = 'Zh conversion icon m.svg',
				alt = '本页使用了标题或全文手工转换',
				title = '本页使用了标题或全文手工转换',
				link = '',
				size = '35px',
			},
		} .. tostring( mw.html.create( 'div' )
				:attr( 'id', 'noteTA-' .. hash )
				:attr( 'class', 'noteTA' )
				:wikitext( code ) )
		if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
			code = code .. '[[Category:放置于模板的noteTA]]'
		end
	end
	return code
end

return z