Module PointsTable
This Module creates a table that shows the points of teams/players in a point system tournament.
Functions
p.main (frame) | Entry point. |
makeTable (frame, args, entities) | The biggest function in the Module. |
fetchData (args, numCols, ent, frame) | Fetches arguments to easier-to-deal-with data. |
easyParams (args, keyword, delim) | Divides multiple arguments given in the same argument. |
getColSafe (args, index, default) | Safely returns a value. |
getNum (val, default) | Safely returns a number. |
getMedalOrd (frame, pos) | Returns expanded position of a player. |
split (s, delim) | Splits a string by a delim. |
compareEntities (a, b) | Custom sorting function. |
protectedExpansion (frame, title, args) | Safely expands a template. |
expandTemplate (frame, title, args) | Expands a template. |
shallow_copy (t) | Copies a table non-recursively (Shallow Copy) |
Functions
- p.main (frame)
-
Entry point.
Module entry point, creates the responsive wrapper around the htmlTable then returns it.
Parameters:
- frame frame
Returns:
-
mw.html object
- makeTable (frame, args, entities)
-
The biggest function in the Module.
Creates the html Table.
Parameters:
- frame frame
- args table - the template parameters
- entities table
Returns:
-
mw.html object
- fetchData (args, numCols, ent, frame)
-
Fetches arguments to easier-to-deal-with data.
Fetches the data from the Template arguments, requires the number of Columns.
Parameters:
- args table - the template arguments
- numCols number
- ent string - expected 'p' for players or 't' for teams
- frame frame
Returns:
-
a table
- easyParams (args, keyword, delim)
-
Divides multiple arguments given in the same argument.
easyParams divides the arguments that contain multiple parameter numbers (paramX,Y,Z)
And Modifies the given args to include individual parameters (paramX, paramY, paramZ)
Useful to give a better editing experience
expandable to other arguments and delimiters by providing a different "keyword" and "delim".
Parameters:
- args table - the template arguments
- keyword string
- delim string
Returns:
-
a table - the required divided parameters
- getColSafe (args, index, default)
-
Safely returns a value.
Returns a value from "args" if it exists, otherwise returns the default value
similar to Python Dictionary's get().
Parameters:
- args table - the template arguments
- index string
- default string
Returns:
-
a string value
- getNum (val, default)
-
Safely returns a number.
Ensures a value is a number, returns 0 if the value isn't a number
Parameters:
- val string
- default string
Returns:
-
a number value, val converted to number if it's convertable, otherwise returns default
- getMedalOrd (frame, pos)
-
Returns expanded position of a player.
Uses a position of a player in the tournament and returns the medal and ordinal
of that position.
Parameters:
- frame frame
- pos number
Returns:
-
a string value
- split (s, delim)
-
Splits a string by a delim.
Splits a string by a delimiter and returns a table of all resulting words.
Parameters:
- s string
- delim string
Returns:
-
table
- compareEntities (a, b)
-
Custom sorting function.
Custom sorting function to sort data-rows by total points followed by player/team name.
Parameters:
- a object
- b object
Returns:
-
boolean
- protectedExpansion (frame, title, args)
-
Safely expands a template.
Expands a template while making sure a missing template doesn't stop the code execution.
Parameters:
- frame frame
- title string
- args table
Returns:
-
a string value - the expansion if exists, else error message
- expandTemplate (frame, title, args)
-
Expands a template.
Expands a template using a frame and returns the result of the expansion.
Parameters:
- frame frame
- title string
- args table
Returns:
-
a string value - the expanded template
- shallow_copy (t)
-
Copies a table non-recursively (Shallow Copy)
Parameters:
- t table return a copy of the provided table