Plugin car.theme

car.theme

Provides access to HMI theming

Methods

cancelWatch

Stop watching theme changes
Parameters:
Name Type Description
watchId String The watch ID as returned by car.theme.watchTheme().
Example
car.theme.cancelWatch(watchId);

getActive

Return the current theme
Parameters:
Name Type Argument Description
successCallback Function The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

getList

Return a list of available themes
Parameters:
Name Type Argument Description
successCallback Function The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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: 'titanium', name: 'Titanium' } 
        ]
}

Error Response:
{
        code: -1,
        msg: "An error has occurred"
}

setActive

Change the current theme
Parameters:
Name Type Argument Description
themeId String The ID of the new theme.
successCallback Function <optional>
The function to call on success.
errorCallback Function <optional>
The function to call if there is an error.
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"
}

watchTheme

Watch for theme changes
Parameters:
Name Type Description
callback Function The function to call when a change is detected.
Returns:
An ID for the added watch.
Type
  • String
Example
//define a callback function
function myCallback(theme) {
        console.log("theme id = " + theme.id + "; theme name = " + theme.name);
}

var watchId = car.theme.watchTheme(myCallback);