打开/关闭搜索
搜索
打开/关闭菜单
1K
5.2K
4
8.2K
星砂岛百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
本站正在进行早期测试,目前仍存在许多内容的缺失。
查看“︁模块:UnlockBook”︁的源代码
来自星砂岛百科
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:UnlockBook
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:已验证邮箱用户
您没有权限编辑
模块
命名空间内的页面。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local common = require('Module:Common') local css = require('Module:CSS') local item_common = require('Module:ItemCommon') local item = require('Module:Item') local p = {} local data_cache local mapping_cache local function load_data() if data_cache then return end data_cache, mapping_cache = item_common.loadDomainData( '数据:UnlockBook/unlockbook_index.json', '数据:UnlockBook/unlockbook_mapping.json' ) end local function find_record(key) load_data() return item_common.findRecord(data_cache, mapping_cache, key) end local function get_record_from_frame(frame) return find_record(common.getArg(frame, 1, '')) end local function render_item_card(frame, item_id, count, css_class) local resolved_id = common.trim(item_id) if resolved_id == '' then return '' end local args = { resolved_id } if count and tonumber(count) and tonumber(count) > 1 then args[2] = tostring(count) end if common.trim(css_class) ~= '' then args.class = css_class end local output = item.renderItemWithArgs(frame, args) return common.trim(output) ~= '' and output or '' end local function render_plain_target(entry, show_id) local display_name = common.trim(entry.name or entry.item_name or entry.id or '') if display_name == '' then return '' end local page = common.trim(entry.page or '') local text = display_name if page ~= '' then text = ('[[%s|%s]]'):format(page, display_name) end if show_id and common.trim(entry.item_id or '') == '' then local target_id = common.trim(entry.id or '') if target_id ~= '' then text = text .. ' <span class="unlockbook-target-id"><code>' .. mw.text.encode(target_id) .. '</code></span>' end end return text end local function render_target_entry(frame, entry, css_class, show_id) if type(entry) ~= 'table' then return '' end local count = tonumber(entry.result_count or 0) or 0 local card = render_item_card(frame, entry.item_id, count, css_class) if card ~= '' then return card end return render_plain_target(entry, show_id) end local function render_station_entry(frame, entry) if type(entry) ~= 'table' then return '' end local station_id = common.trim(entry.id or '') local card = render_item_card(frame, station_id, nil, 'block') if card ~= '' then return card end local display_name = common.trim(entry.name or station_id) if display_name == '' then return '' end local page = common.trim(entry.page or '') if page ~= '' then return ('[[%s|%s]]'):format(page, display_name) end return display_name end local function any_item_entry(entries) if type(entries) ~= 'table' then return false end for _, entry in ipairs(entries) do if type(entry) == 'table' and common.trim(entry.item_id or entry.id or '') ~= '' then return true end end return false end local function with_item_css(entries, text) if common.trim(text) == '' then return '' end if any_item_entry(entries) then return (css.quickCall('Item') or '') .. text end return text end function p.findRecord(key) return find_record(key) end function p.getField(frame) local key = common.getArg(frame, 1, '') local field = common.getArg(frame, 2, '') if field == '' then return '' end local record = find_record(key) if not record then return '' end if field == 'image' then local item_id = common.trim(record.id or '') if item_id == '' then return '' end local image_name = item_id .. '.png' if common.filePageExists(image_name) then return image_name end return '' end local value = record[field] if type(value) == 'table' then if field == 'unlock_family_list' or field == 'unlock_target_type_list' or field == 'unlock_target_preview_names' then return common.toText(value) end return '' end return common.toText(value) end function p.targetSummary(frame) local record = get_record_from_frame(frame) if not record then return '' end local targets = record.unlock_targets if type(targets) ~= 'table' or #targets == 0 then return common.trim(record.unlock_station_hint or record.unlock_primary_target or '') end local primary = render_target_entry(frame, targets[1], 'block', false) if primary == '' then return '' end local more_count = math.max((tonumber(record.unlock_target_count or 0) or #targets) - 1, 0) if more_count <= 0 then return with_item_css({ targets[1] }, primary) end local out = {} out[#out + 1] = primary out[#out + 1] = ('<div class="unlockbook-target-summary-note">另含 %d 项</div>'):format(more_count) return with_item_css({ targets[1] }, table.concat(out)) end function p.targetList(frame) local record = get_record_from_frame(frame) if not record then return '' end local targets = record.unlock_targets if type(targets) ~= 'table' or #targets == 0 then return '' end local out = {} out[#out + 1] = '<ul class="unlockbook-target-list">' for _, entry in ipairs(targets) do local rendered = render_target_entry(frame, entry, 'block', true) if rendered ~= '' then out[#out + 1] = '<li>' .. rendered .. '</li>' end end out[#out + 1] = '</ul>' return with_item_css(targets, table.concat(out)) end function p.stationList(frame) local record = get_record_from_frame(frame) if not record then return '' end local stations = record.unlock_stations if type(stations) ~= 'table' or #stations == 0 then return '' end local parts = {} for _, entry in ipairs(stations) do local rendered = render_station_entry(frame, entry) if rendered ~= '' then parts[#parts + 1] = rendered end end if #parts == 0 then return '' end return with_item_css(stations, table.concat(parts)) end return p
该页面嵌入的页面:
模块:UnlockBook/doc
(
查看源代码
)
返回
模块:UnlockBook
。
查看“︁模块:UnlockBook”︁的源代码
来自星砂岛百科