跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
TPC
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
未登录编辑者的页面
了解详情
贡献
讨论
编辑“︁
模块:Message box
”︁
模块
讨论
English
阅读
编辑
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
编辑
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
Harry00025
(
留言
|
贡献
)
2026年5月28日 (四) 05:55的版本
(创建页面,内容为“local p = {} local function commentSprite( pos, link, size ) if not pos then return '' end pos = mw.text.trim( pos ) if pos == '' then return '' end local icon = '
%s|class=comment-icon|link=%s|alt=
' local iconMap = { 'question', 'warning', 'done', 'undone', 'support', 'oppose', 'doing', 'information', 'disallow', 'on hold', 'strong support', 'weak support', 'neutral', 'weak oppose', 'strong oppose', 'transferred', 'withdr…”)
(差异) ←上一版本 |
最后版本
(
差异
) |
下一版本→
(
差异
)
警告:您正在编辑该页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
local p = {} local function commentSprite( pos, link, size ) if not pos then return '' end pos = mw.text.trim( pos ) if pos == '' then return '' end local icon = '[[File:Comment %s.svg|%s|class=comment-icon|link=%s|alt=]]' local iconMap = { 'question', 'warning', 'done', 'undone', 'support', 'oppose', 'doing', 'information', 'disallow', 'on hold', 'strong support', 'weak support', 'neutral', 'weak oppose', 'strong oppose', 'transferred', 'withdrawn' } return icon:format( tonumber( pos ) and iconMap[ tonumber( pos ) ] or pos:lower(), size or '16px', link or '' ) end local function argAlter( args ) if type( args ) ~= 'table' then return nil end local defaultAltMethod = function( base, alt ) return alt or base end local altMethods = { class = function( base, alt ) local result = mw.text.trim( table.concat( { base or '', alt or '' }, ' ' ) ) return ( result == '' ) and nil or result end } for k, _ in pairs( args ) do if k:sub( 1, 1 ) == '_' then k = k:sub( 2 ) end local v = ( altMethods[ k ] or defaultAltMethod )( args[ k ], args[ '_' .. k ] ) if v then args[ k ] = v end end return args end function p.getStyles( f ) local args = f or {} if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) end local loadStyle = require( 'Module:TSLoader' ).call local styles = loadStyle( args[ 1 ] or args.basic or 'Template:Message box/styles.css' ) local currentNamespace = mw.title.getCurrentTitle().namespace return styles .. ( ( ( not args.nocustom ) and ( currentNamespace == 2 or currentNamespace == 3 ) ) and loadStyle( args[ 2 ] or args.custom or 'Template:Message box/custom.css' ) or '' ) end function p.main( f ) local rawTitle = nil local rawText = nil local args = f local frame = mw.getCurrentFrame() if f == frame then args = argAlter( require( 'Module:ProcessArgs' ).merge( true ) ) else -- Will not use type() to detect whether f is a table or not, which is an expensive function. -- So, ideally, calling from templates will not cause an error ( f is a frame ), but will occurs when calling from modules if f is not a table. rawTitle = f.title rawText = f.text end -- Equivalent to args.title and args.text, but without trimming, to avoid formatting issues. -- Variables args.title or args.text will not use to form a real title or text, just indicates whether respective arguments is set or not. -- Arguments from the parent frame take priority of the current frame, per Module:ProcessArgs. rawTitle = frame:preprocess( rawTitle or ( frame:getParent().args._title or frame.args._title ) or ( frame:getParent().args.title or frame.args.title ) ) rawText = frame:preprocess( rawText or ( frame:getParent().args._text or frame.args._text ) or ( frame:getParent().args.text or frame.args.text ) ) -- Create main frame local result = mw.html.create( 'div' ):addClass( 'msgbox' ) if args.mini then result:addClass( 'msgbox-mini' ) if not args.width then result:addClass( 'msgbox-compat' ) end elseif args.compat then if not args.width then result:addClass( 'msgbox-compat' ) end elseif not args.wide then result:addClass( 'msgbox-normal' ) end result:addClass( 'searchaux' ):addClass( args.bgclass or 'msgbox-' .. ( args.type or 'notice' ) ):addClass( args.class ):cssText( args.css ):css{ [ 'background-color' ] = args.bgcol, [ 'border-left-color' ] = args.linecol, [ 'font-size' ] = args[ 'font-size' ], [ 'width' ] = args.width, } -- Create optional icon / image frame if args.icon or args.image then result:addClass( 'has-image' ) local resultOpt = mw.html.create( 'div' ):addClass( 'msgbox-icon-image' ):cssText( args.imagecss ) local imagefield = '' if args.icon then imagefield = imagefield .. commentSprite( args.icon, args.iconlink, args.iconsize ) end if args.image then imagefield = imagefield .. mw.ustring.format( '[[File:%s|%s%s%s|text-top]]', args.image, args.imagesize or ( args.mini and '16px' or '32px' ), args.imagelink and ( '|link=' .. args.imagelink ) or '', args.imageclass and ( '|class=' .. args.imageclass ) or '' ) end resultOpt:wikitext( frame:preprocess( args.imagetextbefore or '' ) .. imagefield .. frame:preprocess( args.imagetextafter or '' ) ) result:node( resultOpt ) end -- Create displaytext frame local resultNext = mw.html.create( 'div' ):addClass( 'msgbox-body' ):addClass( 'align-' .. ( args[ 'text-align' ] or 'left' ) ):cssText( args.textcss ) -- Create optional title frame inside displaytext frame if args.title then local resultNextTitle = mw.html.create( 'div' ):addClass( 'msgbox-title' ) local resultNextTitleText = "<b>" .. rawTitle .. "</b>" if args.customaction then resultNextTitleText = resultNextTitleText .. '<sup>' .. frame:preprocess( args.customaction ) .. '</sup>' end if args.discuss or args.discussPage or args.discussAnchor then local directLinkTarget = args.discussPage or ( mw.title.getCurrentTitle().talkPageTitle and mw.title.getCurrentTitle().talkPageTitle.fullText ) if args.discussAnchor then directLinkTarget = directLinkTarget .. '#' .. args.discussAnchor end local discussText = ' <sup>' .. require( 'Module:Direct link' ).main{ directLinkTarget, '讨论' } .. '</sup>' if args.linkshere then discussText = discussText .. ' <sup>[[Special:WhatLinksHere/' .. mw.title.getCurrentTitle().fullText .. '|' .. require( 'Module:STConversion' ).call{ [ 'zh-cn' ] = '链入', [ 'zh-tw' ] = '連入' } .. ']]</sup>' if mw.title.getCurrentTitle().namespace == 6 then discussText = discussText .. ' <sup>[[Special:GlobalUsage/' .. mw.title.getCurrentTitle().text .. '|全域使用]]</sup>' end end resultNextTitleText = resultNextTitleText .. discussText end resultNextTitle:wikitext( resultNextTitleText ) resultNext:node( resultNextTitle ) end -- Create optional text frame inside displaytext frame, after optional title frame if args.text then resultNext:tag( 'div' ):addClass( 'msgbox-text' ):wikitext( '\n' .. rawText .. '\n' ) -- Lint: p tag would be auto generated by wikitext parser with the new lines here end -- Add displaytext frame to main frame result:node( resultNext ) -- Add templatestyles to final result result = ( args.noautoloadstyles and '' or p.getStyles() ) .. tostring( result ) -- Append tracking categories if args.bgcol then result = result .. '[[Category:使用Message box的bgcol参数的页面]]' end if args.linecol then result = result .. '[[Category:使用Message box的linecol参数的页面]]' end return result end return p
摘要:
请注意,所有对TPC的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
TPC:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
该页面使用的模板:
模块:Message box/doc
(
编辑
)
搜索
搜索
编辑“︁
模块:Message box
”︁
添加话题