RuneScape:Calculators/Form calculators

JS calculator is a MediaWiki script that enables dynamic loading of templates into parts of a page. A configurable form is used to input parameters into the template.

Configuration
The JS calculator's configuration section uses  pairs, each separated by a newline. The possible names are:
 * - The name of the template to use on form submittal. If no namespace is provided, then the template namespace will be searched by default. If the template is in the main namespace, you must prepend a colon to the article name. This follows the same convention that's used when transcluding templates into a page.
 * - The unique HTML ID of the element that will contain the form. Each configuration block should specify a different form ID.
 * - The unique HTML ID of the element that will contain the parsed template.
 * - A comma-separated list of namespace IDs to use for autocomplete. This field applies for all article parameter types used in the form. By default, namespace 0 (main) is searched. See the table to the bottom for the valid namespace IDs.
 * - Defines a parameter to be sent to the template, in the format shown in the next section.

Parameter format
A  line should be in the following format:




 * - The name of the parameter as used by the template. Parameter names are case sensitive, and there can be no spaces.
 * - The label used for the parameter in the form. If blank,  is used.   supports using HTML to format the labels - including simple formats like ,   and even.
 * However, normal wikiscript cannot be used - e.g. instead of  you will need to use.
 * - The default value used to prefill the form initially.
 * - The type of the parameter, used for form validation and to control the appearance of the form field. Valid values for  are:
 * (default) - The input box can contain any value.
 * - The input box should contain an article name. Currently, this means that autocomplete will be enabled for the text box. To set the namespaces searched by autocomplete, use the  field (see above).
 * - The input box must contain a number. A valid range can be specified in  in the format min-max. If either min or max is omitted or a range is not given, then infinity is assumed.
 * - The input box must contain an integer. A valid range can be specified (see above).
 * - The input is selected from a comma-separated list of values given in.
 * - A checkbox, with values sent to the template defined by the.
 * The  has format , which defines what the form will pass to the template when ticked or not ticked. The default for this is.
 * The checkbox will be checked by default if the  is set to   or the same as the   given in the.
 * - A special field which attempts to lookup a player's hiscores for values to be passed into other parameters.
 * Currently,  is ignored. The form will automatically try to prefill the form with the last name entered in a   type box.
 * has a format of  where   is the   of any other parameter in the form,   is the integer of the skill to lookup (as defined by the table to the bottom), and   is 0 for rank, 1 for level and 2 for experience (0 for rank and 1 for score in minigames). Multiple parameters can be changed by using   - i.e..
 * - The value specified by  will be shown but cannot be changed in the form.
 * - The value specified by  will be hidden in the form and cannot be changed. No row is generated for the form at all.
 * - A combination of fixed and hidden: The value specified by  will be hidden in the form and cannot be changed, but unlike , a row is added to the form, which is hidden with CSS. This is primarily for inter-script usage (i.e. some other script sets the semihidden value to something so that it is passed to the template when submitted).
 * - The allowed range of the parameter. The format of this field depends on the  chosen.

The configuration section should be contained within a &lt;pre&gt; tag with the class, e.g.: &lt;pre class="jcConfig"&gt; ... configuration ... &lt;/pre&gt;

Expression Calculator
Enter a mathematical expression in the field. Any expression that works with the #expr parser function is valid.

 template = User:Quarenon/Scripts/Calc/Expr form     = exprCalcForm result   = exprCalcResult param    = Expression||2 + 2|string|

Code
&lt;pre class="jcConfig"&gt; template = User:Quarenon/Scripts/Calc/Expr form     = exprCalcForm result   = exprCalcResult param    = Expression||2 + 2|string| &lt;/pre&gt;

GE Value Calculator
Enter an item on the Grand Exchange to check the current price. Optionally, enter a quantity to find the total value of the item.

 template = User:Quarenon/Scripts/Calc/GE form     = geCalcForm result   = geCalcResult suggestns = 112 param    = Item|Item Name||article param    = qty|Quantity||int|1-

Code
&lt;pre class="jcConfig"&gt; template = User:Quarenon/Scripts/Calc/GE form     = geCalcForm result   = geCalcResult suggestns = 112 param    = Item|Item Name||article param    = qty|Quantity|1|int|1- &lt;/pre&gt;

Player Hiscores
View the hiscores of the given player. This uses the RSHighscores extension by TehKittyCat.

 template = User:Quarenon/Scripts/Calc/Hiscores form     = hsCalcForm result   = hsCalcResult param    = Player|Player Name|Quarenon

Code
&lt;pre class="jcConfig"&gt; template = User:Quarenon/Scripts/Calc/Hiscores form     = hsCalcForm result   = hsCalcResult param    = Player|Player Name|Quarenon &lt;/pre&gt;

License
This script is released under the GNU General Public License. The source code is available at MediaWiki:Common.js/calc.js.