Documentation for this module may be created at Module:Chat options/doc
-- <pre>
local p = {}
local hasc = require('Module:Paramtest').has_content
function p.main(frame)
local args = frame:getParent().args
local items = {}
local i = 1
while hasc(args[i]) do
local item = mw.text.trim(args[i])
local key
local tooltip
if item:lower() == 'accept' then
key = '✓'
tooltip = '[Accept Quest]'
elseif item:lower() == 'any' or item == '#' or item == '~' then
key = '~'
tooltip = '[Any option]'
else -- Match first case-insensitive, alphanumeric character
key = item:match('^[A-Za-z0-9]')
if key then
tooltip = mw.text.trim(mw.ustring.sub(item, 2))
end
end
table.insert(items, { key, tooltip })
i = i + 1
end
return p._main(items)
end
function p._main(items)
local element = mw.html.create('span')
element:addClass('chat-options')
:wikitext('(<i title="Chat options">[[File:Quick chat button.png|alt=Chat|link=]]</i> ')
local k,t,kspan
local keys = {}
for i,v in ipairs(items) do
k = mw.text.trim(v[1])
t = mw.text.trim(v[2])
kspan = mw.html.create('span')
kspan:wikitext(k)
if hasc(t) then
kspan :addClass('chat-options-underline')
:attr('title', t)
end
table.insert(keys, tostring(kspan))
end
element:wikitext(table.concat(keys, '•')):wikitext(')')
return tostring(element)
end
return p