js:scripts
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
hidden:js:scripts [2022/05/26 10:05] – emozolyak | js:scripts [2024/02/26 14:36] – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | You can use custom javascript to implement nearly any interaction with objects, a canvas or the entire page. | ||
- | General functions that work globally: | ||
- | <code javascript> | ||
- | /** | ||
- | * Get current register value by id | ||
- | * @param regId {int|string} | ||
- | * @returns {boolean|string} | ||
- | */ | ||
- | getRegisterValueById(regId) | ||
- | </ | ||
- | <code javascript> | ||
- | /** | ||
- | * Get current register value by its variable | ||
- | * @param variable {string} | ||
- | * @returns {boolean|string} | ||
- | */ | ||
- | getRegisterValueByVariable(variable) | ||
- | </ | ||
- | Functions for interaction with dashboard (in the case of screens, functions are performed in isolation): | ||
- | <code javascript> | ||
- | /** | ||
- | * Creates canvas overlay | ||
- | * @returns {CanvasRenderingContext2D} | ||
- | */ | ||
- | createCanvas2DContext() | ||
- | </ | ||
- | <code javascript> | ||
- | /** | ||
- | * Sets property to dashboard object. | ||
- | * @param id {int} required. You can find id in ObjectInspector or in object Properties tab (first row) | ||
- | * @param properties {Object} required. An object, contains properties to set {property: value, secondProperty: | ||
- | * Typical list of properties is: width, height, top, left, stroke, fill, hide, globalAlpha and so on | ||
- | * @param settings {Object|false} optional. An object, contains animation settings. | ||
- | * Possible keys are: | ||
- | | ||
- | | ||
- | | ||
- | list: easeInQuad, easeOutQuad, | ||
- | */ | ||
- | setObjProperty(id, | ||
- | </ | ||
- | |||
- | Events observer can be implemented via callback functions. As for now handling available for ' | ||
- | Most handy event '' | ||
- | |||
- | |||
- | Example: | ||
- | |||
- | <code javascript> | ||
- | var minValue = getRegisterValueById(74); | ||
- | var maxValue = getRegisterValueByVariable(' | ||
- | var currentValue = getRegisterValueById(55); | ||
- | |||
- | function getSmoothTemperatureColor(){ | ||
- | var delta = currentValue - minValue; | ||
- | return ' | ||
- | } | ||
- | |||
- | if (minValue && maxValue) | ||
- | setObjProperty(12, | ||
- | | ||
- | App.on(' | ||
- | let needle = data.filter(r => r.regId === 55); | ||
- | if (needle.length === 1) { | ||
- | | ||
- | } | ||
- | setObjProperty(12, | ||
- | if (currentValue >= maxValue) { | ||
- | // do some other stuff | ||
- | } | ||
- | }); | ||
- | |||
- | </ | ||
- | |||
js/scripts.txt · Last modified: 2024/02/26 14:36 by atolstov