卡厄思
梦
境
菜单
首页
回到首页
WIKI工具
全站样式
全站JS
修改导航栏
测试
沙盒
可视化管理器
战斗员管理器
卡牌管理器
伙伴管理器
装备管理器
词典管理器
图鉴
战斗员
伙伴
装备
怪物卡牌
中立卡牌
词典
小工具
配队模拟器
节奏榜生成器
搜索
链入页面
相关更改
特殊页面
页面信息
最近更改
登录
模块
查看“︁词典表格”︁的源代码
←
模块:词典表格
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local data = mw.loadData("模块:词典/data") function p.makeTable(frame) local result = {} -- 表格开始 table.insert(result, '<table class="wikitable sortable" style="width:100%" id="CardSelectTr">') -- 表头 table.insert(result, '<thead>') table.insert(result, '<tr id="CardSelectTabHeader">') table.insert(result, '<th style="width:80px" class="dataHeader">图标</th>') table.insert(result, '<th style="width:150px" class="dataHeader headerSort">名称</th>') table.insert(result, '<th style="width:150px" class="dataHeader headerSort">类型</th>') table.insert(result, '<th class="dataHeader">描述</th>') table.insert(result, '</tr>') table.insert(result, '</thead>') -- 表格主体 table.insert(result, '<tbody>') -- 先收集所有数据并排序 local allEntries = {} for name, entries in pairs(data.dictionary) do for _, entry in ipairs(entries) do table.insert(allEntries, { name = name, entry = entry }) end end -- 按类型排序 table.sort(allEntries, function(a, b) local typeA = a.entry['类型'] or '' local typeB = b.entry['类型'] or '' if typeA == typeB then return a.name < b.name end return typeA < typeB end) -- 遍历排序后的数据 for _, item in ipairs(allEntries) do local name = item.name local entry = item.entry local dataType = entry['类型'] or '' local dataColor = entry['颜色'] or '' table.insert(result, string.format('<tr data-param类型="%s" data-param颜色="%s">', mw.text.encode(dataType), mw.text.encode(dataColor))) -- 图标列 if entry['icon'] and entry['icon'] ~= '' then table.insert(result, '<td>[[File:' .. entry['icon'] .. '|50px]]</td>') else table.insert(result, '<td>暂无图标</td>') end -- 名称列 table.insert(result, '<td>' .. mw.text.encode(name) .. '</td>') -- 类型列(添加颜色) local typeText = entry['类型'] or '' local color = entry['颜色'] or '' local colorStyle = '' if color == '橙' then colorStyle = ' style="color:#ff8c00"' elseif color == '蓝' then colorStyle = ' style="color:#4169E1"' elseif color == '红' then colorStyle = ' style="color:#DC143C"' end table.insert(result, '<td' .. colorStyle .. '>' .. mw.text.encode(typeText) .. '</td>') -- 描述列 table.insert(result, '<td>' .. (entry['描述'] or '') .. '</td>') table.insert(result, '</tr>') end table.insert(result, '</tbody>') table.insert(result, '</table>') return frame:preprocess(table.concat(result, '\n')) end return p
该页面使用的模板:
模块:词典表格/doc
(
查看源代码
)
返回
模块:词典表格
。