You can write the script in the Source code window. You can use any function or expression from JavaScript – the editor automatically highlights your syntax and conducts an error check.
Functions
You can declare your own functions using JavaScript function syntax. As you can see, when you open View Script, there are some already created functions:
function init() {
}
This function is called upon opening the view. You can put initialization code here.
function destroy() {
}
This function is called when a user closes the view or navigates to a different view. Usually, you don’t have to fill this function in.
function periodic() {
}
This function is called every time the view is refreshed. The refresh period (e.g. the period this function is called) can be specified in view parameter – refresh
In periodic() function, you will probably write most (or all) of your code.