Calculator:AD

Template:Information Page

 File:Windows Calculator.png
**Calculators** are tools for determine quantities of ingame items, actions, or money.

Form calculators use a script that enables dynamic loading of templates into parts of a page. A configurable form is used to input parameters into the template.

These form config files are stored in the "**Script error: No such module "String/Templates".**" namespace, and are added to Category:Calculators. There is a Sandbox page for it as well.

The script that is used for this was taken from the RuneScape fandom wiki, as well as some newer features taken from the more up to date non-fandom RS wiki (fandom script used instead due to errors). These are the pages they use for learning about them:

* Form calculators
* Form calculators/Examples
* Form calculators/Tests

Added features not on the fandom wiki's version of the script:

* Toggles (feature taken from non-fandom RS wiki)

Beyond this point is documentation taken from the RS fandom wiki, tweaked as needed:

## Configuration

The JS calculator's configuration section uses **Script error: No such module "String/Templates".** pairs, each separated by a newline. The possible names are:

* **Script error: No such module "String/Templates".** - The name of the calculator used as a title (default 'Calculator'). Optional.
* **Script error: No such module "String/Templates".** - The name of the calculator page of this calculator. If none is provided, the 'view calculator' link will not work.
* **Script error: No such module "String/Templates".** - 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. If none is provided, 'view template' link will not work.
* **Script error: No such module "String/Templates".** - The unique HTML ID of the element that will contain the form. Each configuration block should specify a different form ID.
* **Script error: No such module "String/Templates".** - The unique HTML ID of the element that will contain the parsed template. Template:Yellow
* **Script error: No such module "String/Templates".** - 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.
* **Script error: No such module "String/Templates".** - Defines a parameter to be sent to the template, in the format shown in the next section.

### Parameter format

A **Script error: No such module "String/Templates".** line should be in the following format:

* `Param name` - The name of the parameter as used by the template. Parameter names are case sensitive, and there can be no spaces.
* `Label name` - The label used for the parameter in the form. If blank, `Param name` is used. `Label name` supports using HTML to format the labels - including simple formats like **Script error: No such module "String/Templates".**, **Script error: No such module "String/Templates".** and even **Script error: No such module "String/Templates".**.
	+ However, **normal wikiscript can only be used if the config is contained within a div tag instead of a pre tag**
* `Default value` - The default value used to prefill the form initially.
* `Param type` - The type of the parameter, used for form validation and to control the appearance of the form field. Valid values for `Param type` are:
	+ **Script error: No such module "String/Templates".** *(default)* - The input box can contain any value.
	+ **Script error: No such module "String/Templates".** - 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 **Script error: No such module "String/Templates".** field (see above).
	+ **Script error: No such module "String/Templates".** - The input box must contain a number. A valid range can be specified in `Param range` in the format *min-max*. If either *min* or *max* is omitted or a range is not given, then infinity is assumed.
	+ **Script error: No such module "String/Templates".** - The input box must contain an integer. A valid range can be specified (see above).
	+ **Script error: No such module "String/Templates".** - The input is selected from a comma-separated list of values given in `Param range`.
	+ **Script error: No such module "String/Templates".** - A checkbox, with values sent to the template defined by the `Param range`.
		- The `Param range` has format **Script error: No such module "String/Templates".**, which defines what the form will pass to the template when ticked or not ticked. The default for this is **Script error: No such module "String/Templates".**.
		- The checkbox will be checked by default if the `Default value` is set to **Script error: No such module "String/Templates".** or the same as the **Script error: No such module "String/Templates".** given in the `Param range`.
	+ **Script error: No such module "String/Templates".** - The value specified by `Default value` will be shown but cannot be changed in the form.
	+ **Script error: No such module "String/Templates".** - The value specified by `Default value` will be hidden in the form and cannot be changed. No row is generated for the form at all.
	+ **Script error: No such module "String/Templates".** - A combination of fixed and hidden: The value specified by `Default value` will be hidden in the form and cannot be changed, but unlike **Script error: No such module "String/Templates".**, 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).
* `Param range` - The allowed range of the parameter. The format of this field depends on the `Param type` chosen.
* `Toggles` - The inputs or groups of inputs toggled by this widget. Applies to select, buttonselect, combobox, check, toggleswitch, togglebutton, int and number param types. Toggles are given in the format **Script error: No such module "String/Templates".**. Note that when an option is chosen, all the groups/fields listed for other options (that aren't listed on the selected option) will be hidden.
	+ Default toggles: For checkboxes, toggleswitches and togglebutton the keys are "true" and "false" (values specified in `Param range` cannot be used), if no key is given key is assumed to be "true". For number and int inputs available keys are any numbers or "not0" which is also used for any nonzero input (if no key is specified key is assumed to be "non0").
	+ Value is the name of the option (listed in param range for the input). Multiple options can be assigned them same toggles by separating them with a comma **Script error: No such module "String/Templates".**.
	+ Toggles are the groups or fields toggled by that option, multiple groups should be separated by a comma **Script error: No such module "String/Templates".**. The group or field names should be those specified in their respecitve `param name`.
	+ Multiple toggle sets are separated by semicolons **Script error: No such module "String/Templates".**.
	+ Examples:
		- If a select has **Script error: No such module "String/Templates".** for the range and **Script error: No such module "String/Templates".** for the toggles then when "Option 1" is selected all inputs that belong to "Group1" and "Group2" will be shown while those belonging to "Group3" will be hidden. when "Option 2" is selected all inputs that belong to "Group2" and "Group3" will be shown while those belonging to "Group1" will be hidden.
		- If a button select has **Script error: No such module "String/Templates".** for the range and **Script error: No such module "String/Templates".** for the toggles then when "Button 1" or "Button 2" is selected the other input "Input1" will be displayed while if "Button 3" is selected it will not be.

The configuration section should be contained within a <div> or <pre> tag with the class **Script error: No such module "String/Templates".**, e.g.:

```
<pre class="jcConfig">
  ... configuration ...
</pre>

```

For example configurations, see /Examples.

## License

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

Template:PoliciesTemplate:Calc use

```
 calcpage  = Calculator:Ability damage
 template  = Template:Calculator/Ability_damage
 form      = abilityDmgCalcForm
 calcname  = Ability Damage Calculator
 result    = inner

```

Template:JcForm