Fallen London Wiki:Calculators
Fallen London Wiki uses a calculator script adapted from Runescape Wiki (GPLv3): MediaWiki:Common.js/calc.js.
Runescape Wiki has its own documentation for the script; yet the adapted version has a number of differences.
The scope of calculator forms:
- Provide a convenient user interface for template and module function evaluations
- Validate inputs
- Cache previous inputs in localStorage, if it is available
- Automatically reevaluate the result on input changes, if configured so
Configuration[edit]
General format[edit]
<pre class="jcConfig">
line 1
line 2
line 3
...
</pre>
<div id="FORM_ID"></div>
<div id="RESULT_ID"></div>
Each line has the form of key = value
.
Supported keys[edit]
name[edit]
The entry is optional; the default value is Calculator
.
name
value is the header-like text shown above the calculator form. Note that wikitext is not evaluated inside ofpre
.
form, result[edit]
Both entries are required.
form
value is a string. The valid characters are: lettersA-Za-z
, digits0-9
, separators_-
. The first symbol must be a letter. The string is the HTML id of the corresponding form (marked asFORM_ID
above); therefore it must be unique in the page in case there are multiple calculators.result
value is a string. The valid characters are: lettersA-Za-z
, digits0-9
, separators_-
. The first symbol must be a letter. The string is the HTML id of the corresponding calculator output (marked asRESULT_ID
above); therefore it must be unique in the page in case there are multiple calculators.
template, module, modulefunc[edit]
One of template
, module
entries is required.
modulefunc
is optional; the default value is main
.
template
value is a wiki page name of the template which is to be evaluated by the form. You may omit theTemplate:
prefix.module
value is a wiki page name of the Lua module containing the function to be evaluated by the form.modulefunc
value is the name of the module function to be evaluated. Only used ifmodule
is specified.
suggestns[edit]
The entry is optional.
suggestns
value is a,
-separated list of wiki namespace names or ids. If the form contains inputs ofarticle
type, only the pages from the specified namespaces will be suggested.
autosubmit[edit]
The entry is optional; the default value is off
.
autosubmit
value is one of the following:off
,option
,on
.off
: autosubmit is disabled and cannot be enabled.option
: a toggle switching autosubmit is shown below the submit button.on
: autosubmit is enabled and cannot be disabled.
When autosubmit is enabled, editing an input triggers form submission and result reevaluation. Avoid enabling it if the result might be computationally expensive.
param[edit]
The entry is expected to be repeated multiple times, each entry is parsed independently.
param
value is a|
-separated list of strings. A variable number of arguments can be specified; missing values will be interpreted as empty. For further details, see the next section.
Supported parameters[edit]
Parameter value format: param|label|default|type|range|toggles|help
param
is the name of the argument passed to the template or to the module function. If it is a numbered argument, specify its number explicitly.label
is the label displayed to the user alongside the input.default
is the default value associated with the input.toggles
is the specification of which other inputs are to be enabled/disabled depending on the value of this input:- Can be applied to parameters of types
select
,buttonselect
,combobox
,check
,toggleswitch
,togglebutton
,int
,number
. - The format of
toggles
is: a;
-separated list of toggle entries; - The format of a toggle entry is:
values=ids
; - The format of
values
is: a,
-separated list of possible values of this input;- If the values are not specified explicitly in
ranges
for the element, usetrue
/false
for inputs of typescheck
,toggleswitch
,togglebutton
. For inputs of typesint
,number
,float
you can also usenot0
for non-zero values.- You can omit the
values=
part entirely for the listed inputs; it will be interpreted astrue
ornot0
.
- You can omit the
- If the values are not specified explicitly in
- The format of
ids
is: a,
-separated list of ids (param
values) of input elements enabled with the specified values. - Only the inputs with ids specified in
toggle
will be affected; if one is specified, it will be disabled with all values for which the corresponding id is not explicitly marked as enabled.
- Can be applied to parameters of types
help
is the HTML text shown (if non-empty) in a tooltip near the input.
The rest of parameters may be interpreted differently depending on type
:
string[edit]
This is the default input type. Shows a textbox.
range
is ignored.
article[edit]
Shows a textbox; auto-completion shows suggestions based on the suggestns
value.
Only existing page names are considered valid.
range
is ignored.
int[edit]
Shows a textbox with +/- buttons. Only integer numbers are considered valid.
range
specifies the valid value range in the format: min-max
.
- Negative values are allowed:
-3--1
is a range from-3
to-1
. - If
min
ormax
are omitted, they are assumed to be negative/positive infinities.
Optionally, you may use the min-max;step;bstep
format:
- Valid values must be multiples of
step
value. Default:1
forint
,0.01
fornumber
,float
. bstep
is the step of +/- buttons.
number, float[edit]
Those types are equivalent. Shows a textbox with +/- buttons. Only real numbers are considered valid.
range
is the same as for int
.
check, toggleswitch, togglebutton[edit]
The types are essentially equivalent and differ only in visual representation:
check
is a checkbox.toggleswitch
is a toggle.togglebutton
is a button that can be toggled on and off.
range
has the form ENABLED,DISABLED
if there are no ;
characters in the string; otherwise, ENABLED;DISABLED
(,
may be used both in ENABLED and DISABLED in this case).
select, buttonselect, combobox[edit]
The types are essentially equivalent and differ only in visual representation:
select
is a drop-down list.buttonselect
is a group of buttons aligned in a horizontal row.combobox
is a textbox with auto-completion; only the predefined values are valid.
range
is a ,
-separated list of recognised values if there are no ;
characters in the string; otherwise, a ;
-separated list (,
may be used in individual entries in this case).
fixed[edit]
Like string
, but cannot be edited.
range
is ignored.
[edit]
Like string
, but cannot be edited or seen.
range
is ignored.
group[edit]
The specified inputs are grouped. These inputs must be below the group entry.
Groups may be specified in toggles
.
range
is a ,
-separated list of input ids.
Examples[edit]
See the page source for configuration.
Different parameters[edit]
<pre class="jcConfig">
name = Different parameters test
template = T
form = parameters1
result = result1
suggestns = 0
param = 1|String parameter|T
param = 2|Int parameter (2-4)|3|int|2-4
param = 3|Float parameter (-3.4 - -0.9)|-1.1|number|-3.4--0.9
param = 4|Acticle parameter||article
param = selects|Selects||group|5,6,7
param = 5|Select parameter|item 1|select|item 1,item 2,item 3
param = 6|Buttonselect parameter|-1|buttonselect|-1,-2,-3
param = 7|Combobox parameter||combobox|aaa,aab,aba,abb,baa,bab,bba,bbb
param = toggles|Toggles||group|8,9,Style
param = 8|Check parameter||check|check1,check0
param = 9|Togglebutton parameter||togglebutton|togglebutton1,togglebutton0
param = Style|Style as values?||toggleswitch|Val,Var||If enabled, the arguments will not be grey and in brackets
</pre>
<div id="parameters1">Loading...</div>
<div id="result1"></div>
yields
name = Different parameters test template = T form = parameters1 result = result1 suggestns = 0 param = 1|String parameter|T param = 2|Int parameter (2-4)|3|int|2-4 param = 3|Float parameter (-3.4 - -0.9)|-1.1|number|-3.4--0.9 param = 4|Acticle parameter||article param = selects|Selects||group|5,6,7 param = 5|Select parameter|item 1|select|item 1,item 2,item 3 param = 6|Buttonselect parameter|-1|buttonselect|-1,-2,-3 param = 7|Combobox parameter||combobox|aaa,aab,aba,abb,baa,bab,bba,bbb param = toggles|Toggles||group|8,9,Style param = 8|Check parameter||check|check1,check0 param = 9|Togglebutton parameter||togglebutton|togglebutton1,togglebutton0 param = Style|Style as values?||toggleswitch|Val,Var||If enabled, the arguments will not be grey and in brackets
Toggled inputs[edit]
name = Toggled inputs test template = T form = parameters2 result = result2 param = 1||T|hidden param = tog|Parameters|0|buttonselect|0,1,2|1=2;2=2,3 param = 2|Parameter 1| param = 3|Parameter 2|
Modules & optional autosubmit[edit]
name = Module & optional autosubmit test module = String modulefunc = len form = parameters3 result = result3 autosubmit = option param = 1|String|
Autosubmit[edit]
name = Autosubmit test template = T form = parameters4 result = result4 autosubmit = on param = 1|String|
Calculators existing on the wiki[edit]
- Broad difficulty
- Narrow difficulty
- Logistic Scaling
- Template:Calculator/BestInSlot (such as in Bizarre, Dreaded, Respectable (Guide))
- Combined Equipment Stats Calculator
- Outfit Planner – Weighted Combination Challenges
- Election debate rewards (RETIRED)
- Noman's Friend/NomansFriendCalculators
- The Sunken Embassy (Guide)
- User:PSGarak/Sandbox/Warplan