Provides access to HMI theming
- Source:
Methods
-
<static> cancelWatch(watchId)
-
Stop watching theme changes
Parameters:
Name Type Description watchId
Number The watch ID returned by car.theme.watchTheme. - Source:
Example
car.theme.cancelWatch(watchId);
-
<static> getActive(successCallback, errorCallback)
-
Return the current theme
Parameters:
Name Type Argument Description successCallback
Function The callback that is called on success. errorCallback
Function <optional>
The callback that is called if there is an error. - Source:
Examples
//define your callback function(s) function successCallback(theme) { console.log("theme id = " + theme.id + "; theme name = " + theme.name); } function errorCallback(error) { console.log(error.code, error.msg); } //call the method car.theme.getActive(successCallback, errorCallback);
REST Request: http://<car-ip>/car/theme/getActive Success Response: { code: 1, data: { id: 'default', name: 'Default' } } Error Response: { code: -1, msg: "An error has occurred" }
-
<static> getList(successCallback, errorCallback)
-
Return a list of available themes
Parameters:
Name Type Argument Description successCallback
Function The callback that is called on success. errorCallback
Function <optional>
The callback that is called if there is an error. - Source:
Examples
//define your callback function(s) function successCallback(themes) { //iterate through all the themes for (var i=0; i<themes.length; i++) { console.log("theme id = " + themes[i].id + "; theme name = " + themes[i].name); } } function errorCallback(error) { console.log(error.code, error.msg); } //call the method car.theme.getList(successCallback, errorCallback);
REST Request: http://<car-ip>/car/theme/getList Success Response: { code: 1, data: [ { id: 'default', name: 'Default' }, { id: 'jeep', name: 'Jeep' } ] } Error Response: { code: -1, msg: "An error has occurred" }
-
<static> setActive(themeId, successCallback, errorCallback)
-
Change the current theme
Parameters:
Name Type Argument Description themeId
String The ID of the new theme. successCallback
Function <optional>
The callback that is called on success. errorCallback
Function <optional>
The callback that is called if there is an error. - Source:
Examples
//define your callback function(s) function successCallback() { console.log("theme has been changed"); } function errorCallback(error) { console.log(error.code, error.msg); } //call the method car.theme.setActive('default', successCallback, errorCallback);
REST Request: http://<car-ip>/car/theme/setActive?themeId=default Success Response: { code: 1 } Error Response: { code: -1, msg: "An error has occurred" }
-
<static> watchTheme(callback) → {Number}
-
Watch for theme changes
Parameters:
Name Type Description callback
Function The function to be called when a change is detected. - Source:
Returns:
An ID for the added watch.- Type
- Number
Example
//define a callback function function myCallback(theme) { console.log("theme id = " + theme.id + "; theme name = " + theme.name); } var watchId = car.theme.watchTheme(myCallback);