Editing
Module:InfoboxUtils
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--- Functions for use in infobox modules. -- @require Module:Categorization -- @require Module:Player link -- @require Module:Utils -- <nowiki> local categorization = require('Module:Categorization') local player_link = require('Module:Player link') local utils = require('Module:Utils') local categorize = categorization.categorize_in_namespaces(0, 'Catalog', 'Community') local p = {} --- Create an error message. -- Formerly, this used [[w:c:dev:Global Lua Modules/User error]]. -- Now it uses the built-in error function and there is no reason to use this. function p.error_message(...) return error(...) end p.player_link = player_link.make_player_link --- Format a number. -- @param {number} number Number to format. -- @param {number} max_round Magnitude for rounding. -- @param {string} category Category to add, optional. -- @param {number} category_min If present, category is added only when number is less than this value. -- @param {string} filter_flag Flag to add when less than minimum (for [[Special:AbuseFilter/5]]). -- @return {string} Formatted number. function p.format_number( number, max_round, category, category_min, filter_flag) number = utils.parse_number(number, true) -- Guaranteed to return a number or error if max_round then -- Round the number. local power = 10^(#tostring(number) - 1) power = power > max_round and max_round or power number = math.ceil(number/power) * power end local formatted_number = utils.format_number(number) if category then if category_min then if number < category_min then if filter_flag then filter_flag = tostring(mw.html.create("span") :wikitext("FLAG::" .. filter_flag) :css("display", "none") ) end return formatted_number .. categorize(category) .. (filter_flag or '') else return formatted_number end else return formatted_number .. categorize(category) end else return formatted_number end end return p
Summary:
Please note that all contributions to Shut Down may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
NUSA Wiki Archive:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:InfoboxUtils/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Tools
What links here
Related changes
Special pages
Page information