Module:Utility: Difference between revisions
From IdleOn MMO Wiki
Kiokurashi (talk | contribs) mNo edit summary |
Kiokurashi (talk | contribs) mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
local util = {} | local util = {} | ||
-- Strings | -- Strings | ||
-- Format with tooltip text, then text to show on page. | |||
util.tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" data-simple-tooltip="%s">%s</span>]] | util.tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" data-simple-tooltip="%s">%s</span>]] | ||
Line 11: | Line 12: | ||
local t = {} | local t = {} | ||
for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do | for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do | ||
table.insert(t, trimwhitespaces(str)) | table.insert(t, util.trimwhitespaces(str)) | ||
end | end | ||
return t | return t | ||
end | end | ||
function trimwhitespaces(s) | function util.trimwhitespaces(s) | ||
return s:match( "^%s*(.-)%s*$" ) | return s:match( "^%s*(.-)%s*$" ) | ||
end | end | ||
return util | return util |
Latest revision as of 18:26, 28 March 2024
Documentation for this module may be created at Module:Utility/doc
local util = {}
-- Strings
-- Format with tooltip text, then text to show on page.
util.tooltipstruct = [[<span class="simple-tooltip simple-tooltip-inline tooltipstered" data-simple-tooltip="%s">%s</span>]]
-- Functions
function util.explode(list, delimiter)
if delimiter == nil then
delimiter = "%s"
end
local t = {}
for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do
table.insert(t, util.trimwhitespaces(str))
end
return t
end
function util.trimwhitespaces(s)
return s:match( "^%s*(.-)%s*$" )
end
return util