Editing Module:Color

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 12: Line 12:
item      = 'help',
item      = 'help',
wp        = 'whisper',
wp        = 'whisper',
common    = 'common',
gray      = 'common',
uncommon  = 'uncommon',
blue      = 'uncommon',
rare      = 'rare',
purple    = 'rare',
stellar  = 'stellar',
gold      = 'stellar',
yellow    = 'stellar',
miracle  = 'miracle',
rainbow  = 'miracle'
}
}


local colors = {
local colors = {
    accent    = 'text-accent',
     buzz      = 'text-buzz',
     buzz      = 'text-buzz',
     highlight  = 'text-highlight',
     highlight  = 'text-highlight',
Line 35: Line 23:
     catch      = 'text-catch',
     catch      = 'text-catch',
     whisper    = 'text-whisper',
     whisper    = 'text-whisper',
    common    = 'text-common',
    uncommon  = 'text-uncommon',
    rare      = 'text-rare',
    stellar    = 'text-stellar',
    miracle    = 'text-miracle',
}
}


Line 75: Line 58:
end
end


if (args.no_bold and lib.isNotEmpty(class)) then
if (args.nobold and lib.isNotEmpty(class)) then
return '<span class="' .. class .. '">' .. text .. '</span>'
return '<span class="' .. class .. '">' .. text .. '</span>'
elseif (args.no_bold and lib.isNotEmpty(span)) then
elseif (args.nobold and lib.isNotEmpty(span)) then
return '<span style="color:' .. span .. '">' .. text .. '</span>'
return '<span style="color:' .. span .. '">' .. text .. '</span>'
elseif lib.isNotEmpty(span) then
elseif lib.isNotEmpty(span) then
Line 105: Line 88:
-- Helper method to search given text for the keys of given table t.
-- Helper method to search given text for the keys of given table t.
-- If a key is found, returns its value; returns nil otherwise.
-- If a key is found, returns its value; returns nil otherwise.
-- Checks longer keys first to avoid matching partial keywords (Uncommon getting detected as Common.)
local function searchTextForKeys(text, t)
local function searchTextForKeys(text, t)
    local keys = {}
for key, val in pairs(t) do
 
result = mw.ustring.find(text, key, 1, true)
    for key in pairs(t) do
        if result ~= nil then return val end
        keys[#keys + 1] = key
    end
 
    table.sort(keys, function(a, b)
        return #a > #b
    end)
 
    for _, key in ipairs(keys) do
        if mw.ustring.find(text, key, 1, true) ~= nil then
            return t[key]
        end
     end
     end
end
end
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Petit Planet Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template
Below are commonly used wikitext from MediaWiki:Edittools. Click on any to insert them in the edit box.
File Pages==Summary====Licensing=={{Fairuse}}{{File|}}
Dynamic Page List¦²«»²{¦}²«»«/»«!----»
Array in DPL¹^2{}^2^2{¹}^2
Parser Functions{{#if:||}}
{{#ifeq:|||}}
{{#expr:}}
{{#switch:||#default=}}
{{#replace:||}}
{{#titleparts:}}
{{#tag:|}}
Markup{{}}|[][[]][[Category:]]#REDIRECT [[]] [[Category:Redirect Pages]]<code></code><includeonly></includeonly><noinclude></noinclude><nowiki></nowiki><!----><br>§
Notices{{Stub|}}{{Stub Dialogue}}{{Upcoming}}{{Under Construction}}{{Placeholder|}}
Magic Words{{!}}{{formatnum:}}{{lc:}}{{uc:}}{{PAGENAME}}{{FULLPAGENAME}}{{ROOTPAGENAME}}{{BASEPAGENAME}}{{SUBPAGENAME}}{{DISPLAYTITLE:|noreplace}}__TOC____NOTOC____EXPECTUNUSEDCATEGORY____HIDDENCAT__
HTML Entities&mdash;&nbsp;&comma;&shy;