On Tuesday, July 9, 2013 3:39:02 AM UTC-7, TiddoB wrote:
>
> what I want is an text-field where users can put in the level.
> And a button to calculate the upkeep.
>
> Want the formula in the JS file, if possible.
>
> If there are easier ways please tell.
>
There are a number of ways you can accomplish this. One way would be to 
implement a WikiProcessor or WikiMacro that performs the calculation. That 
would support a syntax such as:
{{{#!UpKeep
10
}}}

or 

[[UpKeep(10)]]

where "10" is an arbitrarily chosen value for your "level" variable. If you 
know some Python and can learn the relevant parts of the Trac API, this is 
probably the easiest approach. Here are some starting points:
 * http://trac.edgewall.org/wiki/WikiMacros#DevelopingCustomMacros
 * http://trac-hacks.org/wiki/SumMacro

It can probably be done in JavaScript as well. You might take a look at 
SumFieldsPlugin as an example: http://trac-hacks.org/wiki/SumFieldsPlugin

Finally, some of the code from TracFormsPlugin may be of use to you, but 
that is probably too much effort if you only need to support a single 
formula. I'll let hasienda expand on this if he thinks it would be a 
reasonable approach since he maintains the plugins.
http://trac-hacks.org/wiki/TracFormsPlugin

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to