Fandom

Old School RuneScape Wiki

Module:Top icons

15,965pages on
this wiki
Add New Page
Discuss0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

local p = {}
 
local sites = {
	wp = { 
		format = '[[wikipedia:%s|%s]]',
		params = { 'wikipedia', 'wp', 'w' },
		abbr = 'W',
		title = 'Wikipedia also has an article on %s.',
		},
	rsc = {
		format = '[[w:c:runescapeclassic:%s|%s]]',
		params = { 'rsc', 'classic', 'c' },
		abbr = 'C',
		title = 'The RuneScape Classic Wiki also has an article on %s.',
		},
	rs = {
		format = '[[runescape:%s|%s]]',
		params = { 'runescape', 'rs', 'rsw', 'rs3' },
		abbr = 'RS',
		title = 'The RuneScape Wiki also has an article on %s.',
		},
	}
 
local order = { 'wp', 'rsc', 'rs' }
 
local allparams = {}
 
function p.main(frame)
	local args = frame:getParent().args
	local pagename = mw.title.getCurrentTitle().fullText
	local vals = {}
	-- create allparams
	for s,t in pairs(sites) do
		for _,v in ipairs(t.params) do
			allparams[v] = s
		end
	end
 
	-- loop named params
	for i,v in pairs(allparams) do
		if args[i] and not vals[v] then
			vals[v] = args[i]
		end
	end
 
	-- loop unnamed params
	local i = 1
	local v
	while args[i] do
		v = allparams[args[i]] 
		if v and not vals[v] then
			vals[v] = pagename
		end
		i = i + 1
	end
 
	local ret = mw.html.create('div')
	ret:addClass('topright topright-icon')
	for _,v in ipairs(order) do
		if vals[v] then
			local span = mw.html.create('span')
			span:wikitext(sites[v].abbr)
				:addClass('rs-header-icon rs-header-icon-'..v)
				:attr('title', string.format(sites[v].title, vals[v]))
			ret:wikitext(string.format(sites[v].format, vals[v], tostring(span)))
		end
	end
 
	return tostring(ret)	
end
 
 
 
return p

Also on Fandom

Random Wiki