|
|
| 第1行: |
第1行: |
| local p = {}
| |
|
| |
|
| function p.main(frame)
| |
| local args = frame:getParent() and frame:getParent().args or {}
| |
| for k, v in pairs(frame.args) do
| |
| if args[k] == nil then args[k] = v end
| |
| end
| |
|
| |
| local imgFile = args.url or args[1] or 'Test-background.jpg'
| |
| local position = args.position and mw.text.trim(args.position) or 'center center'
| |
| local opacity = args.opacity and mw.text.trim(args.opacity) or '1'
| |
| local shade = tonumber(args.shade) or 0
| |
| local shadeColor = args.shadeColor and mw.text.trim(args.shadeColor) or 'white'
| |
| local color = args.color and mw.text.trim(args.color) or 'transparent'
| |
| local animate = args.animate and mw.text.trim(args.animate) or 'show'
| |
| local action = args.action and mw.text.trim(args.action)
| |
|
| |
| local defaults = {
| |
| show='2s', shrink='4s ease-out', clear='2s', appear='5s ease', look='5s ease',
| |
| }
| |
| local animTiming = action or defaults[animate] or '2s'
| |
|
| |
| local html = mw.html.create()
| |
| local outer = html:tag('div')
| |
| :attr('class', 'wiki-bg-outer wiki-bg-anim-' .. animate)
| |
| :cssText(
| |
| 'position:fixed;top:0;left:0;width:100%;height:100%;' ..
| |
| 'z-index:-1;pointer-events:none;' ..
| |
| 'opacity:' .. opacity
| |
| )
| |
|
| |
| outer:tag('div'):attr('class', 'wiki-bg-color')
| |
| :cssText('position:fixed;top:0;left:0;width:100%;height:100%;background:' .. color)
| |
|
| |
| outer:wikitext('[[File:' .. imgFile .. '|link=|frameless]]')
| |
|
| |
| -- Always-on auto overlay: white in light mode, dark in dark mode (via CSS @media)
| |
| outer:tag('div'):attr('class', 'wiki-bg-shade-auto')
| |
|
| |
| if shade > 0 then
| |
| outer:tag('div'):attr('class', 'wiki-bg-shade')
| |
| :cssText(
| |
| 'position:fixed;top:0;left:0;width:100%;height:100%;' ..
| |
| 'background:' .. shadeColor .. ';opacity:' .. tostring(shade)
| |
| )
| |
| end
| |
|
| |
| return tostring(html)
| |
| end
| |
|
| |
| return p
| |
这个模块是干什么用的?
该模块用于测试,测试完请清空模块内的内容
基本用法
local p = {}
function p.函数名()
return '返回内容'
end
function p.函数名2()
return '返回内容2'
end
return
以上为最基本的用法,其他请自行学习Lua语言
其他
同样也有一个用于测试模板的模板,点这里进入