Module:Bankable items: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
local smwjson = require('Module:SMW JSON')
local purge = require('Module:Purge')._purge
local pt = require('Module:Paramtest')
local pt = require('Module:Paramtest')
p = {}
p = {}
Line 11: Line 11:
local use_cols = pt.has_content(cols) or pt.has_content(col_width)
local use_cols = pt.has_content(cols) or pt.has_content(col_width)


local data = mw.smw.ask{
local askdata = mw.smw.ask{
"[[Bank::"..bank.."]]",
"[[Bank::"..bank.."]]",
limit = 4000
limit = 4000
}
}
if askdata == nil then
mw.logObject(data)
return ":''No bankable items found. To force an update, click "
..purge('dml-'..mw.uri.anchorEncode(bank), 'here', 'span')
..".''"
end


data = {}
for _,d in ipairs(askdata) do
for _,v in ipairs(d) do
table.insert(data, v)
end
end
mw.logObject(data)
ret = mw.html.create('ul')
ret = mw.html.create('ul')


for _,value in ipairs(data[1]) do
for _,value in ipairs(data) do
ret:tag('li'):wikitext('[['..value..']]')
ret:tag('li'):wikitext(value)
mw.logObject(value)
end
end
if use_cols then
if use_cols then

Latest revision as of 07:51, 9 December 2024

Module documentation
This documentation is transcluded from Module:Bankable items/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Bankable items/doc. [edit]
Module:Bankable items's function main is invoked by Template:Bankable items.
Module:Bankable items requires Module:Paramtest.
Module:Bankable items requires Module:Purge.

local purge = require('Module:Purge')._purge
local pt = require('Module:Paramtest')
p = {}

function p.main(frame)
	local args = frame:getParent().args
	local bank = args[1] or mw.title.getCurrentTitle().text
	local cols = args["cols"]
	local col_width = args['colWidth']
	
	local use_cols = pt.has_content(cols) or pt.has_content(col_width)

	local askdata = mw.smw.ask{
		"[[Bank::"..bank.."]]",
		limit = 4000
	}
	
	if askdata == nil then
		return ":''No bankable items found. To force an update, click "
				..purge('dml-'..mw.uri.anchorEncode(bank), 'here', 'span')
				..".''"
	end

	data = {}
	for _,d in ipairs(askdata) do
		for _,v in ipairs(d) do
			table.insert(data, v)
		end
	end
	
	mw.logObject(data)
	
	ret = mw.html.create('ul')

	for _,value in ipairs(data) do
		ret:tag('li'):wikitext(value)
	end
	if use_cols then
		ret:css({
			['column-count'] = cols,
			['column-width'] = col_width or '200px'
		})
	end
	
	mw.log(ret)
	
	return(ret)
	
end

return p