Mô đun:Portal image banner

Tài liệu mô đun[tạo]
local p = {}
local randomModule = require('Mô đun:Random')

p.main = function(frame)
	local parent = frame.getParent(frame)
	local parentArgs = parent.args
	local args = cleanupArgs(parentArgs)
	local output = p._main(args)
	return frame:preprocess(output)
end

function cleanupArgs(argsTable)
	local cleanArgs = {}
	for key, val in pairs(argsTable) do
		if type(val) == 'string' then
			val = val:match('^%s*(.-)%s*$')
			if val ~= '' then
				cleanArgs[key] = val
			end
		else
			cleanArgs[key] = val
		end
	end
	return cleanArgs
end

p._main = function(args)
	if not args[1] then
		return error(linked and 'Không có trang nào được chỉ định' or 'Không có trang nào được chỉ định', 0)
	end
	local lines=makeGalleryLinesTable(args)
	return makeOutput(lines, args.overflow, args.maxheight, args.mode, args.croptop)
end

function makeGalleryLine(file, caption, link)
	local title = mw.title.new(file, "File" )
	local linktext = ( link and '{{!}}link=' .. link  or '' )
	local maxImageWidth = '{{!}}800px'
	return '[[' .. title.prefixedText ..(caption and'{{!}}'..caption or '').. maxImageWidth .. linktext ..']]' .. (caption and '\n<div style="text-align:center;">' .. caption ..'</div>' or '\n') 
end

function makeGalleryLineSlideshow(file, caption)
	local title = mw.title.new(file, "File" )
	local captiontext= '[[Tập tin:OOjs_UI_icon_info-progressive.svg|link=:'..title.prefixedText..']]&nbsp;<span style="font-size:110%;">'..(caption or '')..'</span>'
	return title.prefixedText .. '{{!}}' .. captiontext 
end


function makeGalleryLinesTable(args)
	local galleryLinesTable = {}
	local i = 1
	while args[i] do
		if not args.mode then 
			table.insert(galleryLinesTable, makeGalleryLine(args[i], args[i+1],args.link))
		else if args.mode=='slideshow' then
			table.insert(galleryLinesTable, makeGalleryLineSlideshow(args[i], args[i+1], args.link)) 
		else 
			error('Chế độ không được hỗ trợ')
			end
	end
		i = i + 2
	end
	return galleryLinesTable 
end
function makeOutput(imageLines, overflow, maxHeight, mode, croptop)
	local randomiseArgs = {	['t'] = imageLines }
	local randomisedLines = randomModule.main('array', randomiseArgs )
	local output, galleryContent
	if not mode then
	    galleryContent = table.concat(randomisedLines, '\n',1,1)
	    seperate=mw.text.split(galleryContent,'\n')
		output = '<div class="portal-banner-image" style="max-height:' .. (maxHeight or 'initial') .. '; overflow:'..(overflow or 'auto')..
		';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptop or '0')..'%;">'..seperate[1]..'</div></div>'..seperate[2]
	else if mode=='slideshow' then
      	galleryContent = table.concat(randomisedLines, '\n')
		output='<div class="portal-banner-image-slideshow nomobile" style="max-height:' .. (maxHeight or 'initial') .. '; overflow:'..(overflow or 'auto')..
		';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptop or '0')..'%;">'..'{{#tag:gallery|'..galleryContent..'|mode=slideshow}}'..'</div></div>'
	else
		error('Chế độ không được hỗ trợ')
		end
	end
	
		return output
	end
return p
Chúng tôi bán
Bài viết liên quan
Chu Kỳ Bitcoin Halving: Sự Kiện Định Hình Tương Lai Crypto
Chu Kỳ Bitcoin Halving: Sự Kiện Định Hình Tương Lai Crypto
Phát triển, suy thoái, và sau đó là sự phục hồi - chuỗi vòng lặp tự nhiên mà có vẻ như không một nền kinh tế nào có thể thoát ra được
So sánh Hutao và Childe - Genshin Impact
So sánh Hutao và Childe - Genshin Impact
Bài viết có thể rất dài, nhưng phân tích chi tiết, ở đây tôi muốn so sánh 𝐠𝐢𝐚́ 𝐭𝐫𝐢̣ của 2 nhân vật mang lại thay vì tập trung vào sức mạnh của chúng
Hướng dẫn lấy thành tựu Xạ thủ đạn ma - Genshin Impact
Hướng dẫn lấy thành tựu Xạ thủ đạn ma - Genshin Impact
trong bài viết dưới đây mình sẽ hướng các bạn lấy thành tựu Xạ thủ đạn ma
Lịch sử hình thành của Tinh Linh Nước Trong
Lịch sử hình thành của Tinh Linh Nước Trong
Rất lâu rất lâu về trước, lâu đến mức thế giới chưa thành hình, con người chưa xuất hiện, kẻ thống trị chưa đổ bộ, từng có một vùng biển đặc thù, chất nước của nó khác xa so với nước biển hiện tại