Chapter 3. WebView Scripting

There are two resources for learning about WebView Scripting:

Pre-Loaded and Sample Scripts

Several WebView scripts are installed with the DataHub archive. These are found in the installed content file location, under Content/Common/Scripts/Cogent. You can view these scripts by opening the Scripts tab in Design mode.

You can use the Script Explorer to browse the scripts:

Scripts whose names start with ex are example scripts. Those that start with wv contain helper functions that enable you to easily leverage advanced capabilities like element animation and slide shows. This interface is read-only, because none of these scripts should be edited.

You can edit an example (ex) script by first copying it to your user content file location, and modifying the copy. This way it will not be replaced by the default script when the DataHub program is updated. However, you should not edit any of the wv scripts like this, as that may lead to unexpected results.

Example Slide Show Script

The exStartSlideShow.ss script starts a slide show that rotates through selected WebView pages in kiosk view every few seconds.

/*
 * This file contains example script that uses the 
 * Application_UserChanged application event to run a 
 * slide show when the <slideshow> user logs in.
 *
 * If you want to customize this function, make a copy 
 * of this file and add your code to the copy.  Do not 
 * edit the original, as your changes will be destroyed
 * when you update the application.
 */

/*
function Application_UserChanged(userName)
{
    // In V10, userName includes the organization 
    // name, e.g., "Local/slideshow"
    if (userName == "slideshow")
    {
        WV.ExecuteCommand("EnterRunMode", true);
        WV.ExecuteCommand("ToggleKioskView", true);
        WV.ExecuteCommand("ToggleScriptDebugWindow", false);
		
        var pages = new List<|string|>();
        pages.Add("Common/Cogent/Circular Gauges");
        pages.Add("Common/Cogent/Trend Charts");
        pages.Add("Common/Cogent/Water Treatment");
		
        wvSlideShow.EmitDebugMessages = false;
        // Start the slide show, advancing every 15 seconds.
        wvSlideShow.Start(pages, 15);
    }
}
*/

You can make a copy of this script to your user content file location, uncomment the function code, and edit the user name, pages, and number of seconds as needed. Here are some additional tips: