「于世界交点之处,逢似曾相识之人」

本wiki目前不支持自由编辑,如果有兴趣参与wiki内容编辑,请加入WIKI建设群904200987(游戏交流勿加会被踢)
使用wiki的数据、图片、音频资源,或者搬运页面内容时,请注明出处。具体参照CC BY-NC-SA 4.0协议
感谢Hyacinth对本wiki提供的数据支持
编辑帮助BWIKI反馈

bugfix1001.2
全站通知:

“模块:Vein数据库”的版本间差异

来自白荆回廊Wiki
跳到导航 跳到搜索
六十三号咸鱼 (2759304)私信 | 贡献
六十三号咸鱼 (2759304)私信 | 贡献
(Lua提交器:调试Lua代码)
 
第23行: 第23行:
local output_html = mw.html.create()
local output_html = mw.html.create()


output_html = output_html:tag('div'):cssText('background:rgba(0,0,0,.8);color:#FFF;padding: 4px 16px 8px;margin: 0 auto;max-width:330px;')
output_html = output_html:tag('div'):cssText('background:rgba(0,0,0,.8);color:#FFF;padding: 4px 16px 8px;margin: 0 auto 16px;max-width:330px;')
:tag('div'):cssText('font-size:1.5em;font-family:"Source Han Serif SC", "Source Han Sans CN";'):wikitext(output_data['title']):done()
:tag('div'):cssText('font-size:1.5em;font-family:"Source Han Serif SC", "Source Han Sans CN";'):wikitext(output_data['title']):done()
:tag('hr'):cssText('border-color:#FFF;margin:3px;'):done()
:tag('hr'):cssText('border-color:#FFF;margin:3px;'):done()

2024年11月6日 (三) 11:12的最新版本

此模块的文档可以在模块:Vein数据库/doc创建

local p={}
local db = require('模块:Vein数据库数据')
local vein_list = db.data_list

p["Vein词条"]=function(frame)
	local vein_id = frame.args['id']

	if vein_id == nil then
		return ''
	end
	
	local output_data = {}
	for _i,v in ipairs(vein_list) do
		if vein_id == v['id'] then
			output_data = v
		end
	end
	
	if output_data == {} then
		return ''
	end
	
	local output_html = mw.html.create()

	output_html = output_html:tag('div'):cssText('background:rgba(0,0,0,.8);color:#FFF;padding: 4px 16px 8px;margin: 0 auto 16px;max-width:330px;')
								:tag('div'):cssText('font-size:1.5em;font-family:"Source Han Serif SC", "Source Han Sans CN";'):wikitext(output_data['title']):done()
								:tag('hr'):cssText('border-color:#FFF;margin:3px;'):done()
								:tag('div'):wikitext(output_data['content']):done()
							:done()
    return tostring(output_html)
end

p["Vein数据库"]=function(frame)
	local category = frame.args['category']
	
	if category == nil then
		category = "root"
	end
	
	local output_list = p.get_son_tree(category)
	
	if output_list == nil or #output_list == 0 then
		return ''
	end
	local output_html = mw.html.create()

	for _i,v in ipairs(output_list) do
    	output_html = output_html:node(p.get_tree_out(v,0))
	end

	-- local res = ""
	-- for _i,v in ipairs(output_list) do
 --   	res = res .. mw.dumpObject(v)  ----- dump出循环中的所有内容
	-- end
	-- return res

    return tostring(output_html)
end

function p.get_son_tree(id)
    local output_tree = {}

    for _i,v in ipairs(vein_list) do
    	if v['parent_id'] == id then
    		local temp = {
    			id = v['id'],
    			title = v['title'],
    			content = v['content'],
    			unlock = v['unlock'],
    			has_pic = v['has_pic'],
    			childrens = {}
    		}
    		temp['childrens'] = p.get_son_tree(v['id'])
            table.insert(output_tree,v['sort'],temp)
    	end
    end
    
    if #output_tree == 0 then
    	output_tree = nil
    end
    return output_tree
end

function p.get_tree_out(item,level)
    local output_html = mw.html.create()
    local title_color = '#525C66'
    local display = 'block'
    if level == 1 then 
    	title_color = '#7B869C'
    end
    if level == 2 or level == 3 then
    	title_color = '#BBC7CF'
    	display = 'none'
    end
    if item['childrens'] == nil or #item['childrens'] == 0 then
    	display = 'none'
    end
    output_html = output_html:tag('div'):addClass('drop-down-wrap')
    							:tag('div'):addClass('wrap-title')
        							:tag('div'):addClass('title'):cssText('background:'..title_color):wikitext(item['title']):done()
        							:tag('div'):addClass('glyphicon icon-arrow-plus'):done()
    							:done()
    							:tag('div'):addClass('wrap-content'):cssText('display:'..display..';border-color:'..title_color)
    if item['has_pic'] == '是' then
    	output_html = output_html:tag('div'):addClass('wrap-text'):cssText('text-align:center;'):wikitext('[[文件:词条百科_'..item['id']..'.png|link=]]'):done()
    end
    
    if item['content'] and item['content'] ~= '-' then
    	output_html = output_html:tag('div'):addClass('wrap-text'):wikitext(item['content']):done()
    end
    
    if item['content'] and item['content'] ~= '-' and item['unlock'] then
    	output_html = output_html:tag('hr'):done()
    	    	    	    	 :tag('div'):addClass('wrap-text'):wikitext('解锁条件:' .. item['unlock']):done()
    end
    
	if item['childrens'] ~=nil and #item['childrens'] > 0 then
		for _i,v in ipairs(item['childrens']) do
			output_html = output_html:node(p.get_tree_out(v,level+1))
		end
	end
	
    output_html = output_html:done():done()
    
    return output_html
end

p["Vein数据词条"]=function(frame)
	local title = frame.args['title']
	
	if title == nil then
		return "标题不能为空"
	end
	
	local content = ""
	for _i,v in ipairs(vein_list) do
    	if v['title'] == title then
    		content = v['content']
    	end
    end
	
    return content
end

function p.get_vein_content_by_vein_id(vein_id)
	
	local content = ""
	for _i,v in ipairs(vein_list) do
    	if v['id'] == vein_id then
    		content = v['content']
    	end
    end
	
    return content
end

function p.get_vein_content_by_character_name(character_name,native_world)
	
	local content = "-"
	for _i,v in ipairs(vein_list) do
    	if v['title'] == character_name then
    		content = v['content']
    	end
    end

    return content
end

return p