匿名
未登录
中文(中国大陆)
登录
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 = {} --[[@Deprecated function p.setTable(frame)]]-- --[[@Deprecated function p.setJson(frame)]]-- --[[@Deprecated function p.setJsonTemplate(frame) {See id#38864}]]-- function get(t,list,class,style,dm) local pwd = mw.html.create('span') :attr('class',class) :attr('style',style) :attr('data-mode',dm); 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; button = pwd:tag('span') :attr('class','lw-treebut') :attr('role','button') :attr('id',NonNull(list[a],list[0])) :wikitext(v2); end end return tostring(pwd); end -- WIP 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 = 'lw-treediv lw-pwd ' .. NonNull(frame.args["class"],''); style = NonNull(frame.args["style"],""); 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 -- get length local l = 1; -- length local delBut,backBut; for i,v in ipairs(t) do for i2,v2 in ipairs(v) do if(v2 == 'X') then delBut = l end if(v2 == '←') then backBut = l end l = l + 1; end end local pwds = {}; for i in string.gmatch(frame.args["List"],"([^%s]+)") do table.insert(pwds, tonumber(i)) end local treePWD = {}; local pwdLength = tonumber(frame.args[2]); local tmp1; for it,v in ipairs(pwds) do for i=1, pwdLength do tmp1 = math.fmod(v,l^i); 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] = 0; end treePWD[pwdLength-i][v][v+tmp1] = tmp1 / (l^(i-1)); end end -- unzip -- REAL Tree Buttons local prefix = NonNull(frame.args["prefix"],"pwd"); local startClass = NonNull(frame.args["startClass"],prefix .. "0-0"); tmp1 = {-- Start [delBut] = startClass, [backBut] = startClass, }; local tmp2 = ""; if(not(type(frame.args["startClass"]) == "nil")) then tmp2 = "display:none;" end for it,v in pairs(treePWD[0][0]) do tmp1[v] = prefix .. "1-" .. it end local txt = get(t, tmp1, 'lw-treediv lw-pwd '.. startClass , tmp2, frame.args[1]);-- Start tmp2 = nil; for i=1,pwdLength-1 do for it,v in pairs(treePWD[i]) do tmp1 = { [delBut] = startClass, [backBut] = prefix .. (i-1) .. "-" .. (it - math.fmod(it,l^(pwdLength-i+1))), } for it2,v2 in pairs(treePWD[i][it]) do tmp1[v2] = prefix .. (i+1) .. "-" .. it2 end if(i == pwdLength-1) then tmp1[0] = startClass end txt = txt .. get(t, tmp1, 'lw-treediv lw-pwd '.. prefix .. i .. "-" .. it, "display:none;", frame.args[1]); 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工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志