Module:ETEvent: Difference between revisions

From WIDEVERSE Wiki
Jump to navigation Jump to search
m (1 revision imported)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 8: Line 8:
function p.main( frame )
function p.main( frame )
local args = frame:getParent().args
local args = frame:getParent().args
local name, edate, etime, fc, icon, details = defaults{
local name, edate, etime, icon, details = defaults{
{args.name, 'Unnamed'},
{args.name, 'Unnamed'},
{args.date, 'January 1 1970'},
{args.date, 'January 1 1970'},
{args.time, '00:00'},
{args.time, '00:00'},
{args.fc, 'RSW'},
{args.icon, 'Weird gloop.png'},
{args.icon, 'Weird gloop.png'},
{args.details, 'No Details'}
{args.details, 'No Details'}
}
}
local length = tonumber(args.length) or 60
local length = tonumber(args.length) or 60
local world = tonumber(args.world) or 39
local datetime = edate..' '..etime..' UTC'
local datetime = edate..' '..etime..' UTC'
Line 25: Line 23:
:tag('td') :wikitext( namedisp ) :done()
:tag('td') :wikitext( namedisp ) :done()
:tag('td') :wikitext( lang:formatDate('F j, G:i' , datetime) ) :done()
:tag('td') :wikitext( lang:formatDate('F j, G:i' , datetime) ) :done()
:tag('td') :wikitext( fc ) :done()
:tag('td') :wikitext( 'World '..world ) :done()
:tag('td') :wikitext( details ) :done()
:tag('td') :wikitext( details ) :done()
local isotime = lang:formatDate('c', datetime)
local isotime = lang:formatDate('c', datetime)
local smwjson = '{"name":"'..name..'","time":"'..lang:formatDate('c', datetime)..'","length":'..length..',"fc":"'..fc..'","world":'..world..'}'
local smwjson = '{"name":"'..name..'","time":"'..lang:formatDate('c', datetime)..'","length":'..length..'}'
mw.smw.set({ ['Events JSON']=smwjson })
mw.smw.set({ ['Events JSON']=smwjson })

Latest revision as of 15:36, 9 June 2022

Documentation for this module may be created at Module:ETEvent/doc

-- <nowiki>

local p = {}
local defaults = require('Module:Paramtest').defaults
local lang = mw.language.getContentLanguage()


function p.main( frame )
	local args = frame:getParent().args
	local name, edate, etime, icon, details = defaults{
		{args.name, 'Unnamed'},
		{args.date, 'January 1 1970'},
		{args.time, '00:00'},
		{args.icon, 'Weird gloop.png'},
		{args.details, 'No Details'}
	}
	local length = tonumber(args.length) or 60
	
	local datetime = edate..' '..etime..' UTC'
	local namedisp = '[[File:'..icon..'|link=RuneScape:Events Team/'..name..']]  [[RuneScape:Events Team/'..name..'|'..name..']]'
	
	local ret = mw.html.create( 'tr' )
		:tag('td')	:wikitext( namedisp )								:done()
		:tag('td')	:wikitext( lang:formatDate('F j, G:i' , datetime) )	:done()
		:tag('td')	:wikitext( details )								:done()
		
	local isotime = lang:formatDate('c', datetime)
	local smwjson = '{"name":"'..name..'","time":"'..lang:formatDate('c', datetime)..'","length":'..length..'}'
	mw.smw.set({ ['Events JSON']=smwjson })
	
	return ret
end

return p

-- </nowiki>