匿名
未登录
中文(中国大陆)
登录
Limbo Wiki
搜索
查看“模块:Pwd”的源代码
来自Limbo Wiki
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
←
模块:Pwd
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
-- Author: User:Staf_Irity local function NonNull(value,def) if(type(value) == "nil") then return def end; return value; end local Data = mw.loadData('Module:pwd/Data'); local p = {} function p.setTable(frame) -- 出bug自己负责,请提供正确的表。 Data = mw.loadData(frame.args[1]) end function p.setJson(frame) -- 出bug自己负责,请提供正确的Json。 Data = mw.text.jsonDecode(frame.args[1]) end --[[@Deprecated function p.setJsonTemplate(frame) {See id#38864}]]-- function p.get(frame) -- @Deprecated if ((type(frame.args[1]) == "nil") or (type(frame.args[2]) == "nil")) then return 'Error: Not Enough Arguments.'; --第一个是名字,第二个是默认的指向 end t = Data[frame.args[1]]; if (type(t) == 'nil') then return 'Error: Table Not Found.' end -- Start -- class = frame.args["class"]; if (type(class) == 'nil') then class='' end if (type(frame.args[DisablePWD]) == 'nil') then class= 'lw-treediv '.. class end class = 'lw-pwd ' ..class style = frame.args["style"]; if (type(style) == 'nil') then style='' end pwd = mw.html.create('span') :attr('class',class) :attr('style',style) :attr('data-mode',frame.args[1]); for i,v in ipairs(t) do if not(i==1) then pwd:tag('br') end for i2,v2 in ipairs(v) do button = pwd:tag('span') :attr('class','lw-treebut') :attr('role','button') id = frame.args[tostring(i)..'-'..tostring(i2)] if (type(id) == 'nil') then id = frame.args[2] end button:attr('id',id):wikitext(v2); end end mw.log(tostring(pwd)); return tostring(pwd); end function p.getSingle(frame) if ((type(frame.args[1]) == "nil") or (type(frame.args[2]) == "nil")) then return 'Error: Not Enough Arguments.'; --第一个是名字,第二个是默认的指向 end t = Data[frame.args[1]]; if (type(t) == 'nil') then return 'Error: Table Not Found.' end -- Start -- class = NonNull(frame.args["class"],''); class = 'lw-treediv lw-pwd ' ..class style = frame.args["style"]; if (type(style) == 'nil') then style='' end pwd = mw.html.create('span') :attr('class',class) :attr('style',style) :attr('data-mode',frame.args[1]); local a = 0; for i,v in ipairs(t) do if not(i==1) then pwd:tag('br') end for i2,v2 in ipairs(v) do a = a + 1; -- mw.log(a); button = pwd:tag('span') :attr('class','lw-treebut') :attr('role','button') id = frame.args["key" .. tostring(a)] if (type(id) == 'nil') then id = frame.args[2] end button:attr('id',id):wikitext(v2); end end -- mw.log(tostring(pwd)); return tostring(pwd); end --[[ p.getSingle{args={'Number','a',['key11']='b'}} 含义:数字密码盘,默认为a,第11个按钮为b p.getSingle{args={'Number','a',['key11']='b',['class']='b',['style']='display:none;'}} 含义:数字密码盘,默认为a,第11个按钮为b,<带有b这一class,默认隐藏>(即当id=b的treebutton被点击后才显示) ]]-- -- p.getMulti{args={'Number','5',List='64112'}} function p.getMulti(frame) -- getMulti(string Type,int Levels,[string]List,<string startClass>,<string prefix>) if ((type(frame.args[1]) == "nil") or (type(frame.args[2]) == "nil") or type(frame.args["List"]) == "nil") then return 'Error: Not Enough Arguments.'; end local t = Data[frame.args[1]]; if (type(t) == 'nil') then return 'Error: Table Not Found.' end local function Str2List(str) local t = {}; for s in string.gmatch(str,"([^%s]+)") do table.insert(t, tonumber(s)) end return t end -- get length local l = 1; -- length local delBut; local backBut; for i,v in ipairs(t) do for i2,v2 in ipairs(v) do l = l + 1; if(v2 == 'X') then delBut = "key" .. tostring(l - 1) end if(v2 == '←') then backBut = "key" .. tostring(l - 1) end end end local pwds = Str2List(frame.args["List"]); local treePWD = {}; local pwdLength = tonumber(frame.args[2]); local tmp1; local tmp2; for it,v in ipairs(pwds) do for i=1, pwdLength do tmp1 = math.fmod(v,l^i); tmp2 = tmp1 / (l^(i-1)); v = v - tmp1; if(type(treePWD[pwdLength-i]) == 'nil') then treePWD[pwdLength-i] = {} end if(type(treePWD[pwdLength-i][v]) == 'nil') then treePWD[pwdLength-i][v] = {} end for i2=pwdLength-i,pwdLength-1 do if(type(treePWD[i2]) == 'nil') then treePWD[i2] = {} end if(type(treePWD[i2][v]) == 'nil') then treePWD[i2][v] = {} end treePWD[i2][v][v] = 2; end treePWD[pwdLength-i][v][v+tmp1] = "key" .. tostring(tmp2); end end -- unzip -- REAL Tree Buttons local prefix = NonNull(frame.args["prefix"],"pwd"); local startClass = NonNull(frame.args["startClass"],prefix .. "0-0"); tmp1 = {-- Start [1] = frame.args[1], ["class"] = startClass, [delBut] = startClass, [backBut] = startClass, }; for it,v in pairs(treePWD[0][0]) do tmp1[v] = prefix .. "1-" .. it end local txt = p.getSingle{args=tmp1};-- Start for i=1,pwdLength-1 do for it,v in pairs(treePWD[i]) do tmp1 = { [1] = frame.args[1], ["class"] = prefix .. i .. "-" .. it, [delBut] = startClass, [backBut] = prefix .. (i-1) .. "-" .. (it - math.fmod(it,l^(pwdLength-i+1))), ["style"] = "display:none;" } for it2,v2 in pairs(treePWD[i][it]) do tmp1[v2] = prefix .. (i+1) .. "-" .. it2 end if(i == pwdLength-1) then tmp1[2] = startClass end txt = txt .. p.getSingle{args=tmp1}; end end mw.log(txt); return txt; end function p.test(frame) -- p.test{args={12,2,3,2,4,9}} 64112 local l = tonumber(frame.args[1]) + 1; local g = table.getn(frame.args) - 1; local num = 0; for i,v in ipairs(frame.args) do if not(i == 1) then num = num + tonumber(v)*(l^(g - i + 1)); end mw.log(tonumber(v)) end mw.log(num); end return p
本页使用的模板:
模板:Pwd.css
(
查看源代码
)
模板:TreeButton
(
查看源代码
)
模块:Pwd
(
查看源代码
)
模块:Pwd/Data
(
查看源代码
)
模块:Pwd/doc
(
查看源代码
)
返回
模块:Pwd
。
导航
导航
首页
最近更改
随机页面
操作申请
帮助
入门指南
编辑指南
写作指南
随机
官方
碎数研
谜题保管所
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志