Using the Classic SiteKiosk Object Model in SiteKiosk Windows Chrome Browser

The SiteKiosk Object Model for use in the Chrome Browser engine of SiteKiosk is still work in progress and does not offer all the features the classic SiteKiosk Object Model for the IE based engine offers. That is why the documentation is only available on request from our support department. To make life a little easier during the transition phase the SiteKiosk Object Model for Chrome offers a way to run the classic SiteKiosk Object Model in a wrapper. Note that this undocumented method comes as-is, it will not enable you to use the full range of the classic SiteKiosk Object Model, e.g. you cannot use code related to controlling the browser window as this specifically refers to the IE based browser and event based code will most likely be problematic.

A simple example looks like this:

var myReturnValue = _siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "return SiteKiosk.Version.VersionString;");

The callHostFunction method requires two strings. The first string must always be system.windows.skLegacy.executeScript, the second string is the one we use to execute the classic SiteKiosk Object Model code. This can be a single line of code as it is in this example, where we query the version of SiteKiosk installed on the system. The return value is optional, depending on the executed code there may be no return value.

The second string can also have multiple lines, e.g. like in this example that combines the version of SiteKiosk with the build date:

var scriptText = `
	var SKBuildDate = SiteKiosk.Version.BuildDateTime;
	var SKVersionString = SiteKiosk.Version.VersionString;
	return SKVersionString + " " + SKBuildDate;
`;
var myReturnValue = _siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", scriptText);

Finally we want to look at a complete html example that uses methods of the SiteKiosk Multimedia object of the classic object model to manipulate the sound volume of the computer.

<!DOCTYPE html>
<html>
<head>
    <title></title>
	<script>
    //method to initialize the SK Chrome Object Model
    (new Function(_siteKiosk.getSiteKioskObjectModelCode()))();
</script>
</head>
    <body>  
		<input id="id_test0" type="button" value="Volume Up" /><br />
		<input id="id_test1" type="button" value="Volume Down" /><br />
		<input id="id_test2" type="button" value="Volume 50%" /><br />
    </body>
    <script type="text/javascript">
        siteKiosk.ready(function (){
            document.getElementById("id_test0").onclick = function () {
				_siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "SiteKiosk.Multimedia.IncreaseVolume(0.1);");
            };
			document.getElementById("id_test1").onclick = function () {
				_siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "SiteKiosk.Multimedia.DecreaseVolume(0.1);");
            };
			document.getElementById("id_test2").onclick = function () {
				_siteKiosk.objectModel.callHostFunction("system.windows.skLegacy.executeScript", "SiteKiosk.Multimedia.Volume=0.5;");
            };
        }());
    </script>
</html>

You can copy and paste the example to notepad (or another text editor), save it as an html file, e.g. objectmodeltest.html, in the ..\SiteKiosk\html folder. You can then set it as the start page for the Chrome browser of SiteKiosk to see the classic SiteKiosk Object Model at work in the SiteKiosk Chrome browser.