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

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

bugfix1001.2
全站通知:

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

来自白荆回廊Wiki
跳到导航 跳到搜索
六十三号咸鱼 (2759304)私信 | 贡献
(Lua提交器:调试Lua代码)
六十三号咸鱼 (2759304)私信 | 贡献
(Lua提交器:调试Lua代码)
第36行: 第36行:
     if v['parent_id'] == id then
     if v['parent_id'] == id then
     local temp = {
     local temp = {
    id = v['id'],
     title = v['title'],
     title = v['title'],
     content = v['content'],
     content = v['content'],
第58行: 第59行:
     title_color = '#7B869C'
     title_color = '#7B869C'
     end
     end
     if level == 2 then
     if level == 2 or level == 3 then
     title_color = '#BBC7CF'
     title_color = '#BBC7CF'
     end
     end
第67行: 第68行:
     :done()
     :done()
     :tag('div'):addClass('wrap-content'):cssText('display:none;')
     :tag('div'):addClass('wrap-content'):cssText('display:none;')
 
    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
     if item['content'] and item['content'] ~= '-' then
     output_html = output_html:tag('div'):addClass('wrap-text'):wikitext(item['content']):done()
     output_html = output_html:tag('div'):addClass('wrap-text'):wikitext(item['content']):done()

2024年2月16日 (五) 23:44的版本

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

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

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'],
    			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'
    if level == 1 then 
    	title_color = '#7B869C'
    end
    if level == 2 or level == 3 then
    	title_color = '#BBC7CF'
    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:none;')
    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

return p