Wire evaluations
[eval:] or [js:] is used to evaluate expressions using an internal JavaScript engine. You can create evaluations ranging from simple addition and subtraction to executing complex functions through JavaScript.
You will need to use proper entity encoding if you use inline JavaScript. An evaluation statement can contain a combination of wire variables, numbers, and operators. The result of the evaluation will be used by the engine as a string replacement wherever it is placed. Evaluations can be placed on actions, within objects, or even in classes. Anywhere an advanced calculation needs to be defined and used.
An alternative for simple mathematical expressions that don't need the overhead of a full JavaScript environment is the [math:xxx] operator. Example:
Expressions like: <panel height="[js: [object:CONTENT.height] - [object:FOOTER.height]]"... Could be simply replaced with: <panel height="[math: [object:CONTENT.height] - [object:FOOTER.height]]"...Additional JavaScript functions can be placed within a “functions.html” file on the root of your wire. This file must be named “functions.html”. Once populated, you can utilize the enclosed functions within a [js:] tag. These functions display on the Functions tab.
Sample code
<action name="sample"> <rotate degrees="[js:Math.floor(Math.random()*1000)]" time="5" /> <scale width="200" xpos="[js:_x - 100]" ypos="[eval:_y - 100]" time="5" /> </action>
Loading...
There was a problem loading this topic