Site Notice
hello, world
Difference between revisions of "Module:UserFunctions"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
(27 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
− | local type = args[ | + | local type = args['type'] or args[1] or '' |
− | -- | + | -- 功能 |
if type == 'username' then | if type == 'username' then | ||
− | + | return username(frame) | |
elseif type == 'usergroup' then | elseif type == 'usergroup' then | ||
− | + | return usergroup(frame) | |
+ | elseif type == 'iflogin' then | ||
+ | return iflogin(frame) | ||
+ | elseif type == '' then | ||
+ | return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':未指定功能</span>" | ||
else | else | ||
− | return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''' | + | return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':功能<u>" .. |
− | + | type .. '</u>不存在</span>' | |
end | end | ||
end | end | ||
-- 用户名 | -- 用户名 | ||
− | function | + | function username() |
− | local html = mw.create | + | local html = mw.html.create() |
− | local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'username'):wikitext(' | + | local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'username'):wikitext('用户名'):done() |
return tostring(resHtml) | return tostring(resHtml) | ||
end | end | ||
− | function | + | function usergroup() |
− | local html = mw.create | + | local html = mw.html.create() |
− | local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'usergroup'):wikitext(' | + | local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'usergroup'):wikitext('用户组'):done() |
return tostring(resHtml) | return tostring(resHtml) | ||
+ | end | ||
+ | |||
+ | function iflogin(frame) | ||
+ | local args = getArgs(frame) | ||
+ | local res = '' | ||
+ | for key in pairs(args) do | ||
+ | res = res .. args[key] | ||
+ | end | ||
+ | return res | ||
end | end | ||
return p | return p |
Latest revision as of 17:54, 3 March 2020
https://common.epb.wiki/index.php?title=Module:UserFunctions/doc&action=edit
UserFunctions脚本错误:功能123不存在
用户名
用户组
第一第二第三iflogin
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
local type = args['type'] or args[1] or ''
-- 功能
if type == 'username' then
return username(frame)
elseif type == 'usergroup' then
return usergroup(frame)
elseif type == 'iflogin' then
return iflogin(frame)
elseif type == '' then
return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':未指定功能</span>"
else
return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':功能<u>" ..
type .. '</u>不存在</span>'
end
end
-- 用户名
function username()
local html = mw.html.create()
local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'username'):wikitext('用户名'):done()
return tostring(resHtml)
end
function usergroup()
local html = mw.html.create()
local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'usergroup'):wikitext('用户组'):done()
return tostring(resHtml)
end
function iflogin(frame)
local args = getArgs(frame)
local res = ''
for key in pairs(args) do
res = res .. args[key]
end
return res
end
return p