B2G/gaia/apps/costcontrol/js/message_handler.js
// When receiving an alarm, differenciate by type and act
When receiving an alarm, differenciate by type and act
When receiving an alarm differenciate by type and act
function _onAlarm(alarm) {
    clearTimeout(closing);
    switch (alarm.data.type) {
      case 'balanceTimeout':
        ConfigManager.requestSettings(function _onSettings(settings) {
          settings.errors['BALANCE_TIMEOUT'] = true;
          ConfigManager.setOption(
            { 'errors': settings.errors, 'waitingForBalance': null },
            function _onBalanceTimeout() {
              debug('Timeout for balance');
              debug('Trying to synchronize!');
              localStorage['sync'] = 'errors#' + Math.random();
              closeIfProceeds();
            }
          );
        });
        break;
      case 'topupTimeout':
        ConfigManager.requestSettings(function _onSettings(settings) {
          settings.errors['TOPUP_TIMEOUT'] = true;
          ConfigManager.setOption(
            { 'errors': settings.errors, 'waitingForTopUp': null },
            function _onBalanceTimeout() {
              debug('Timeout for topup');
              debug('Trying to synchronize!');
              localStorage['sync'] = 'errors#' + Math.random();
              closeIfProceeds();
            }
          );
        });
        break;
      case 'nextReset':
        ConfigManager.requestSettings(function _onSettings(settings) {
          resetAll(function updateNextResetAndClose() {
            updateNextReset(
              settings.trackingPeriod, settings.resetTime,
              closeIfProceeds
            );
          });
        });
        break;
    }
  }
function _onAlarm ( alarm ) { clearTimeout ( closing ) ; switch ( alarm . data . type ) { case 'balanceTimeout' : ConfigManager . requestSettings ( function _onSettings ( settings ) { settings . errors [ 'BALANCE_TIMEOUT' ] = true ; ConfigManager . setOption ( { 'errors' : settings . errors , 'waitingForBalance' : null } , function _onBalanceTimeout ( ) { debug ( 'Timeout for balance' ) ; debug ( 'Trying to synchronize!' ) ; localStorage [ 'sync' ] = 'errors#' + Math . random ( ) ; closeIfProceeds ( ) ; } ) ; } ) ; break ; case 'topupTimeout' : ConfigManager . requestSettings ( function _onSettings ( settings ) { settings . errors [ 'TOPUP_TIMEOUT' ] = true ; ConfigManager . setOption ( { 'errors' : settings . errors , 'waitingForTopUp' : null } , function _onBalanceTimeout ( ) { debug ( 'Timeout for topup' ) ; debug ( 'Trying to synchronize!' ) ; localStorage [ 'sync' ] = 'errors#' + Math . random ( ) ; closeIfProceeds ( ) ; } ) ; } ) ; break ; case 'nextReset' : ConfigManager . requestSettings ( function _onSettings ( settings ) { resetAll ( function updateNextResetAndClose ( ) { updateNextReset ( settings . trackingPeriod , settings . resetTime , closeIfProceeds ) ; } ) ; } ) ; break ; } }
When receiving an alarm, differenciate by type and act
When receiving an alarm differenciate by type and act