Site Notice

hello, world

Difference between revisions of "Module:UserFunctions"

From Project-EPB Commons
([InPageEdit] 没有编辑摘要)
([InPageEdit] 没有编辑摘要)
Line 7: Line 7:
 
   -- 识别功能
 
   -- 识别功能
 
   if type == 'username' then
 
   if type == 'username' then
     p.username()
+
     username()
 
   elseif type == 'usergroup' then
 
   elseif type == 'usergroup' then
     p.usergroup(frame)
+
     usergroup(frame)
 
   else
 
   else
 
     return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':功能<u>" ..
 
     return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':功能<u>" ..
Line 17: Line 17:
  
 
-- 用户名
 
-- 用户名
function p.username()
+
function username()
 
   local html = mw.html.create()
 
   local html = mw.html.create()
 
   local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'username'):wikitext('加载中'):done()
 
   local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'username'):wikitext('加载中'):done()
Line 23: Line 23:
 
end
 
end
  
function p.usergroup()
+
function usergroup()
 
   local html = mw.html.create()
 
   local html = mw.html.create()
 
   local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'usergroup'):wikitext('加载中'):done()
 
   local resHtml = html:tag('span'):addClass('UserFunctions'):attr('data-type', 'usergroup'):wikitext('加载中'):done()

Revision as of 17:11, 3 March 2020

https://common.epb.wiki/index.php?title=Module:UserFunctions/doc&action=edit

UserFunctions脚本错误:功能123不存在



UserFunctions脚本错误:功能第一不存在


local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.main(frame)
  local args = getArgs(frame)
  local type = args[1] or args['type']
  -- 识别功能
  if type == 'username' then
    username()
  elseif type == 'usergroup' then
    usergroup(frame)
  else
    return "<span class=\"error\" data-userfunction=\"no-such-function\">'''UserFunctions脚本错误''':功能<u>" ..
      args[1] .. '</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

return p