<commit_before>var webutil = require('../util/web'),
    rewriter = require('../util/jsonrewriter'),
    Amount = ripple.Amount;

/**
 * Manages the notifications appearing in the top right status box.
 */
var StatusManager = function ()
{
  this.el = null;
  this.queue = [];

  // If true, the next tick is already scheduled, so we do not need to trigger
  // one manually if a new element is added.
  this.tickUpcoming = false;

  this.tickInterval = 4000;
};

StatusManager.prototype.init = function ()
{
  var self = this;
  var app = this.app;

  var $scope = this.$scope = app.$scope.$new();

  // Activate #status panel
  $scope.$apply(function () {
    $scope.toggle_secondary = function () {
      $scope.show_secondary = !$scope.show_secondary;
    };

    $scope.$watch('balances', function () {
      $scope.orderedBalances = [];
      $.each($scope.balances,function(index,balance){
        $scope.orderedBalances.push(balance);
      });
      $scope.orderedBalances.sort(function(a,b){
        return parseFloat(b.total.to_text()) - parseFloat(a.total.to_text());
      });

      $scope.balance_count = Object.keys($scope.balances).length;


    }, true);

    // Low balance indicator
    app.$scope.$watch('account', function(){
      if (app.$scope.account.reserve) {
        var reserve = app.$scope.account.reserve.product_human(2);
        var balance = Amount.from_json(app.$scope.account.Balance);

        if (balance.is_valid()) {
          $scope.lowBalance = balance.compareTo(reserve) <= 0;
        } else {
          $scope.lowBalance = false;
        }
      }
    }, true);<commit_msg>Use ABS in balances order. Fixes #101<commit_after>var webutil = require('../util/web'),
    rewriter = require('../util/jsonrewriter'),
    Amount = ripple.Amount;

/**
 * Manages the notifications appearing in the top right status box.
 */
var StatusManager = function ()
{
  this.el = null;
  this.queue = [];

  // If true, the next tick is already scheduled, so we do not need to trigger
  // one manually if a new element is added.
  this.tickUpcoming = false;

  this.tickInterval = 4000;
};

StatusManager.prototype.init = function ()
{
  var self = this;
  var app = this.app;

  var $scope = this.$scope = app.$scope.$new();

  // Activate #status panel
  $scope.$apply(function () {
    $scope.toggle_secondary = function () {
      $scope.show_secondary = !$scope.show_secondary;
    };

    $scope.$watch('balances', function () {
      $scope.orderedBalances = [];
      $.each($scope.balances,function(index,balance){
        $scope.orderedBalances.push(balance);
      });
      $scope.orderedBalances.sort(function(a,b){
        return parseFloat(Math.abs(b.total.to_text())) - parseFloat(Math.abs(a.total.to_text()));
      });

      $scope.balance_count = Object.keys($scope.balances).length;


    }, true);

    // Low balance indicator
    app.$scope.$watch('account', function(){
      if (app.$scope.account.reserve) {
        var reserve = app.$scope.account.reserve.product_human(2);
        var balance = Amount.from_json(app.$scope.account.Balance);

        if (balance.is_valid()) {
          $scope.lowBalance = balance.compareTo(reserve) <= 0;
        } else {
          $scope.lowBalance = false;
        }
      }
    }, true);
{'fraction_non_alphanumeric': 0.15304878048780488, 'fraction_numerical': 0.004573170731707317, 'mean_word_length': 2.7886836027713624, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '626752', 'n_tokens_mistral': 1032, 'n_tokens_neox': 999, 'n_words': 213}