Module:Sandbox/Mr. Stradivarius/sandbox3/doc
![]() | This is a documentation subpage for Module:Sandbox/Mr. Stradivarius/sandbox3. It may contain usage information, categories and other content that is not part of the original module page. |
Helper functions
- makeCheckSelfFunction( libraryName, varName, selfObjDesc, uniqueMethod )
Makes a simple function that raises an error if the dot syntax is used with object methods instead of the colon syntax. The uniqueMethod variable should be the name of a method unique to the class. Because this function needs to work with inheritance, it is not 100% reliable; for example, it will mistake objects made from daughter classes (such as qualityScale objects) for objects made from parent classes (such as assessmentScale objects). However, it should work in most cases.
- checkString( s )
Checks to see if a given variable is a non-blank string. Returns the string if true, and returns false if not.
- checkObject( obj )
- Checks to see if a given variable is an object of some kind. It checks that the variable is a table and that the table contains a function named "new". If the variable passes the tests, the object is returned; if not, false is returned.
- addStringToArray( array, s )
Adds a string to an array. Returns nil on an attempt to add a non-string value, and returns an error on an attempt to add a string to a non-table value. Checks that the string is not the empty string, and if the array is not present, the function creates it.
Class definitions
banner class
The main class for WikiProject banners. Defines the wikitext for the banner box, specifies the project name, the main image, and other things relevant to the banner as a whole.
Initiated with: banner:new()
Methods:
- banner:setImage( s )
Sets the main image for the banner. Input type: string
- banner:getImage()
Gets the main image for the banner.
- banner:addCategory( s )
Adds one category to the banner object. Input type: string (no double brackets and no "Category:" text)
- banner:addCategories( t )
Adds multiple categories to the banner object. Input type: array of strings
- banner:getCategories()
Gets an array containing the category names for the banner object.
- banner:exportCategories()
Returns a string containing all the banner's categories ready for output on a wiki page.
- banner:addRow( rowObject )
Adds a row object to the banner. Input type: Row object.
- banner:addRows( t )
Adds an array of row objects to the banner object. Input type: array of row objects.
- banner:export()
Exports the banner to wikitext ready for display on wiki pages.
row class
The row class defines one row to add to the banner object. Rows can be things like task forces, notes, assessments, etc.
Initiated with:
- row:new()
Methods:
- row:addCategory( s )
Adds a category to the row object. Input type: string (no double brackets and no "Category:" text)
- row:addCategories( t )
Adds multiple categories to the row object. Input type: array of strings
- row:getCategories()
Gets an array containing the category names for the row object.
- row:export()
Exports the row object to wikitext to be passed to the banner object's export method.
assessmentScale class
The assessmentScale class provides the infrastructure for quality scales and importance scales.
Initiated with:
- assessmentScale:new()
Methods:
- assessmentScale:setParamName( s )
Sets the name of the parameter that accepts trigger values from assessmentGrade objects. For example, if an article was rated as |class=start, the parameter name would be "class". Input type: string
- assessmentScale:getParamName()
Gets the parameter name.
- assessmentScale:setCategoryFamily( s )
Sets the name of the category family. For example, for a quality scale with categories such as and the category family name would be "tulips articles". Input type: string
- assessmentScale:getCategoryFamily()
Gets the category family name.
- assessmentScale:addGrade( assessmentGradeObject )
Adds an assessmentGrade object to the assessment scale (usually this will be a qualityGrade or an importanceGrade object). The assessmentGrade objects added to an assessmentScale object determine the grades on its assessment scale. If the assessmentGrade object is already present in the assessment scale, an error will be raised. Input type: assessmentGrade object
- assessmentScale:addGrades( t )
Adds an array of multiple assessmentGrade objects to the assessmentScale object. Input type: array of assessmentGrade objects
- assessmentScale:removeGrade( s )
Removes one grade from the assessment scale. Input type: string
- assessmentScale:removeGrades( t )
Removes multiple grades from the assessment scale. Input type: array of strings
- assessmentScale:getGrades()
Returns the table containing the assessmentGrade objects.
- assessmentScale:getGrade( s )
Returns the specified grade object if it is set in the assessment scale.
- assessmentScale:editGrade( gradeName, method, ... )
Edits the assessment grade object named "gradeName", using the assessment grade object's method "method". The third and subsequent arguments are passed as arguments to "method". This is a convenience function, to avoid having to remove a whole assessment grade object from the assessment scale, edit it, and then add it again. gradeName input type: string method input type: string
- assessmentScale:checkForDuplicateTriggers()
Checks for duplicate triggers in the grade objects added to the assessment scale. If any are found, displays an error.
qualityScale class
This class defines a quality scale.
Initiated with:
- qualityScale:new()
Methods:
- qualityScale:setFaGrade()
Sets an FA (Featured Article) grade with the default settings. The grade name is set to "fa", there is one trigger of "fa", the color is "#6699ff", and the icon is "Featured article star.svg".
- qualityScale:setAGrade()
Sets an A grade with the default settings. The grade name is set to "a", there is one trigger of "a", the color is "#66ffff", and the icon is "Symbol a class.svg.svg".
- qualityScale:setGaGrade()
Sets a GA (Good Article) grade with the default settings. The grade name is set to "ga", there is one trigger of "ga", the color is "#66ff66", and the icon is "Symbol support vote.svg".
- qualityScale:setBGrade()
Sets a B grade with the default settings. The grade name is set to "b", there is one trigger of "b", and the color is "#b2ff66".
- qualityScale:setCGrade()
Sets a C grade with the default settings. The grade name is set to "c", there is one trigger of "c", and the color is "#ffff66".
- qualityScale:setStartGrade()
Sets a Start grade with the default settings. The grade name is set to "start", there is one trigger of "start", and the color is "#ffaa66".
- qualityScale:setStubGrade()
Sets a Stub grade with the default settings. The grade name is set to "stub", there is one trigger of "stub", and the color is "#ff6666".
- qualityScale:setFlGrade()
Sets an FL (Featured List) grade with the default settings. The grade name is set to "fl", there is one trigger of "fl", the color is "#6699ff", and the icon is "Featured article star.svg".
- qualityScale:setListGrade()
Sets a List grade with the default settings. The grade name is set to "list", there is one trigger of "list", and the color is "#aa88ff".
- qualityScale:setNaGrade()
Sets a NA (not applicable) grade with the default settings. The grade name is set to "na", there are two triggers of "na" and "n/a", and the color is "#f5f5f5".
- qualityScale:setCategoryGrade()
Sets a Category grade with the default settings. The grade name is set to "category", there are three triggers of "category", "cat" and "categ", and the color is "#ffdb58".
- qualityScale:setDisambigGrade()
Sets a Disambig (disambiguation) grade with the default settings. The grade name is set to "disambig", there are four triggers of "disambiguation", "disambig", "disamb" and "dab", and the color is "#00fa9a".
- qualityScale:setFileGrade()
Sets a File grade with the default settings. The grade name is set to "file", there are three triggers of "file", "img" and "image", and the color is "#ddccff".
- qualityScale:setPortalGrade()
Sets a Portal grade with the default settings. The grade name is set to "portal", there is one trigger of "portal", and the color is "#cc8899".
- qualityScale:setProjectGrade()
Sets a Project grade with the default settings. The grade name is set to "project", there are three triggers of "project", "proj" and "prj", and the color is "#c0c090".
- qualityScale:setTemplateGrade()
Sets a Template grade with the default settings. The grade name is set to "template", there are five triggers of "template", "temp", "tpl", "tmp" and "templ", and the color is "#fbceb1".
- qualityScale:setRedirectGrade()
Sets a Redirect grade with the default settings. The grade name is set to "redirect", there are three triggers of "redirect", "red" and "redir", and the color is "#c0c0c0".
- qualityScale:setFmGrade()
Sets an FM (Featured Media) grade with the default settings. The grade name is set to "fm", there is one trigger of "fm", the color is "#6699ff", and the icon is "Featured article star.svg".
- qualityScale:setStandardQualityScale()
Sets the standard quality scale, with grades of FA, A, GA, B, C, Start, Stub, FL, List and NA. All the grades have the default values.
- qualityScale:setExtendedQualityScale()
Sets the extended quality scale, with the grades in the standard quality scale plus grades of Category, Disambig, File, Portal, Project, and Template. All the grades have the default values.
importanceScale class
The importanceScale class defines an importance scale. It is populated with importanceGrade objects.
Initiated with:
- importanceScale:new()
Methods:
- importanceScale:setTopGrade()
Sets a Top importance grade with the default settings. The grade name is set to "top", there is one trigger of "top", and the color is "#ff00ff".
- importanceScale:setHighGrade()
Sets a High importance grade with the default settings. The grade name is set to "high", there is one trigger of "high", and the color is "#ff88ff".
- importanceScale:setMidGrade()
Sets a Mid importance grade with the default settings. The grade name is set to "mid", there is one trigger of "mid", and the color is "#ffbbff".
- importanceScale:setLowGrade()
Sets a Low importance grade with the default settings. The grade name is set to "low", there is one trigger of "low", and the color is "#ffddff".
- importanceScale:setBottomGrade()
Sets a Bottom importance grade with the default settings. The grade name is set to "bottom", there is one trigger of "bottom", and the color is "#ffeeff".
- importanceScale:setNoGrade()
Sets a No importance grade with the default settings. The grade name is set to "no", there is one trigger of "no", and the color is "#ffffff".
- importanceScale:setNaGrade()
Sets a NA importance grade with the default settings. The grade name is set to "na", there are two triggers of "na" and "n/a", and the color is "#f5f5f5".
- importanceScale:setCoreGrade()
Sets a Core importance grade with the default settings. The grade name is set to "core", there is one trigger of "core", and the color is "#ff00ff".
- importanceScale:setStandardImportanceScale()
Sets the standard importance scale of Top, High, Mid, Low, and NA, with the default settings.
assessmentGrade class
The assessmentGrade class defines one grade on an assessment scale (e.g. an FA-class grade on a quality scale, or a top-importance grade on an importance scale).
Initiated with:
- assessmentGrade:new()
Methods:
- assessmentGrade:setGradeName( s )
Sets the name of the assessment grade. For example, for a C-class quality grade, the grade name would be "c". Input type: string
- assessmentGrade:getGradeName()
Gets the name of the assessment grade.
- assessmentGrade:addTrigger( s )
Adds a trigger for the assessment grade. For example, if you want the grade to be triggered by the code "|class=foo", then the trigger would be "foo". Input type: string
- assessmentGrade:addTriggers( t )
Adds multiple triggers for the assessment grade. Input type: array of strings
- assessmentGrade:getTriggers()
Gets the array of triggers for the assessment grade.
- assessmentGrade:setCategory( s )
Sets the category used by the assessment grade. This should only be used if the category does not follow the default naming system. Normally categories are set by assessmentScale objects or banner objects.
- assessmentGrade:getCategory()
Gets the category for the assessment grade, if one was set with assessmentGrade:setCategory.
- assessmentGrade:setColor( s )
Sets the color used for icon boxes etc. used by the assessment grade. Input type: string (should be a valid css color value, e.g. '#gg99ff')
- assessmentGrade:getColor()
Gets the assessment grade color.
- assessmentGrade:setIcon( s )
Sets the icon for the assessment grade, e.g. the featured article star for featured articles. This is optional - not every assessmentGrade object needs an icon. If specified, it should be a valid file name, without the "File:" prefix. Input type: string
- assessmentGrade:getIcon()
Gets the icon file name.
qualityGrade class
The quality grade class defines quality grades on a quality scale. It inherits methods from the assessmentGrade class.
Methods:
All methods from the assessmentGrade class
importanceGrade class
The importance grade class defines importance grades on an importance scale. It inherits methods from the assessmentGrade class.
Methods:
All methods from the assessmentGrade class