Skip to Content

battery()

Initialize user battery detection functions.

JavaScript July 2, 2019

Usage

This function runs automatically, so it is not called manually. Is this incorrect?

Source File

Located in /assets/js/nebula.js on line 559.

JavaScript
nebula.battery = function(){
    nebula.user.client.device.battery = false;

    if ( 'getBattery' in navigator ){ //Chrome only
        navigator.getBattery().then(function(battery){
            nebula.batteryData(battery);
            jQuery(battery).on('chargingchange levelchange', function(){
                nebula.batteryData(battery);
            });
        });
    }
};

Override

To override or disable this JavaScript function, simply redeclare it with the exact same function name.

JavaScript
nebula.battery = function(){
    //Write your own code here, leave it blank, or return false.
}