Template talk:Calculator/feature requests
This is a list of potential feature ideas for this template so they can be discussed on an individual basis and not be lost in the main talk page. Implemented features should removed from this page. This page is meant to collect ideas. Not all of them are necessarily good. Please comment on any you think would be useful.
Using calculators with strings
editMapping feature should maybe allow some normalization. Not sure if users should be able to specify different normalization methods. Perhaps we should first try matching case sensitively, and if that doesn't work, try again all lowercase.
Also maybe should allow maxlength parameter
Have string input be a pseudo-array of values
editOne potential idea that stops short of having a string type but still allows strings, might be as follows:
- Have a new input type, called "string" which acts like a text input.
- If this input has an id of x, then it would make x0 be the unicode code point for the first letter, x1 for the next, and so forth. (Potentially should be 1 based instead). The string is terminated with a NaN. (And similarly in the reverse direction).
- have a function named
count()
, where count(x) will return how many pseudo-array entries you have to go to before hitting a NaN (Not clear if 0 should also be considered a stopping point). - have functional programming style loops like map(variable, expression), that allows special functions inside it curvalue() and curindex(). So you can do something like map(x, curvalue()+32 ) to make a string lowercase. Probably also make sense to have functions like reduce(variable, expression, initial ), and something similar to js Array.toSpliced. Probably many of the js array funcs are applicable as well as some of the String functions.
An example where this might be useful would be for articles like Caesar cipher
Missing formula functions
editSome sort of array_find equivalent
editOpposite of index(). Say you have variables foo1 = 7, foo2 = 9, foo3 = 2. You could do something like select(foo,2,defaultval) and it would return 3 because because foo3 is equal to 2.
Some sort of function call
editIf you have a calculator field foo with formula (a+2)/b
. If you do call(foo,a,3) this is the same as substituting foo except with variable a set to 3 instead of its normal value.
Unclear if this is worth the extra complexity involved.
Allow sorting tables via calculator widgets
editYou can do some sorting with CSS grid and flexbox (or absolute positioning) already. It might be cool to allow sorting a table via calculator. Each row could be associated with a calculator field, and they could be dynamically reordered based on calculator values.
Have a graph control
editMake a <canvas> tag that gets drawn on based on some formula (with one of the variables ranging over some ___domain). Similar to how a graphing calculator can draw a graph based on a formula.
Disable formula for buttons
editAllow buttons to specify a formula where they become disabled if the formula is false.
Arbitrary precision decimal numbers
editSuggested by Mathnerd314159 - Use something like decimal.js to make the numbers be high precision decimals, so people have to worry less about rounding of floats.
Scoping of labels
editGenerally everything inside a <div class="calculator-container"> is scoped to that container. The exception are labels, as they use the for attribute to match with ids globally in the document.
This seems pretty non-ideal, but its unclear what to do for that. Potentially we could automatically change ids of fields to have a random number in them, and change labels to match, however that means they will no longer work as anchor target, and will also have problems with other fields that reference ids like aria-labelledby, aria-describedby. I'm not sure if that is better or worse than the status quo. Bawolff (talk) 13:48, 29 January 2025 (UTC)