(function () {
'use strict';
var module = angular.module('fim.base');
module.factory('AssetDetailProvider', function (nxt, $q, IndexedEntityProvider, $timeout) {
  
  function AssetDetailProvider(api, $scope, asset, decimals, account) {
    this.api = api
    this.$scope = $scope;
    this.asset = asset;
    this.decimals = decimals;
    this.account = account;
    this.data = {};
    // api.engine.socket().subscribe('blockPopped', angular.bind(this, this.blockPopped), $scope);
    // api.engine.socket().subscribe('blockPushed', angular.bind(this, this.blockPushed), $scope);
  }
  AssetDetailProvider.prototype = {

    reload: function () {
      var self = this;
      var deferred = $q.defer();
      this.$scope.$evalAsync(function () {
        self.isLoading = true;
        $timeout(function () {  self.getNetworkData(deferred); }, 1, false);        
      });
      return deferred.promise;      
    },

    processData: function (d) {
      var data = this.data;
      data.name = d.name;
      data.description = d.description;
      data.issuerRS = d.issuerRS;
      data.issuerName = d.issuerName;
      data.quantityQNT = d.quantityQNT;
      data.numberOfTrades = d.numberOfTrades;
      data.numberOfTransfers = d.numberOfTransfers;
      data.numberOfAccounts = d.numberOfAccounts;
      data.volumeTodayQNT = d.volumeTodayQNT;
      data.numberOfTradesToday = d.numberOfTradesToday;
      data.volumeTotalQNT = d.volumeTotalQNT;
      data.orderFeePercentage = d.orderFeePercentage;
      data.tradeFeePercentage = d.tradeFeePercentage;
      data.type = '';
      data.lastPriceNQT = d.lastPriceNQT;

      data.lastPriceNXT = nxt.util.calculateOrderPricePerWholeQNT(data.lastPriceNQT, this.decimals);
      data.quantity = nxt.util.convertToQNTf(d.quantityQNT, this.decimals);
      data.volumeToday = nxt.util.convertToQNTf(d.volumeTodayQNT, this.decimals);
      data.volumeTotal = nxt.util.convertToQNTf(d.volumeTotalQNT, this.decimals);
      data.orderFee = nxt.util.convertToQNTf(String(d.orderFeePercentage), 6)||'0';
      data.tradeFee = nxt.util.convertToQNTf(String(d.tradeFeePercentage), 6)||'0'
      data.isPrivate = d.type && d.type == 1;

      var quantityQNT = new BigInteger(String(d.quantityQNT));
      var priceNQT = new BigInteger(String(d.lastPriceNQT));
      var marketcapNQT = quantityQNT.multiply(priceNQT).toString();
      data.marketcapNXT = nxt.util.convertToNXT(marketcapNQT);

      

    },    

    getNetworkData: function (reload_deferred) {
      var deferred = $q.defer(), self = this;
      this.api.engine.socket().getAsset({ asset: this.asset, includeDetails: 'true', includeVolumes: 'true' }).then(
        function (data) {
          self.$scope.$evalAsync(function () {
            self.isLoading = false;
            self.processData(data);
            deferred.resolve();
            if (reload_deferred) {
              reload_deferred.resolve();
            }            
          });
        }, 
        function (data) {
          self.$scope.$evalAsync(function () {
            self.isLoading = false;
            deferred.resolve();
            if (reload_deferred) {
              reload_deferred.resolve();
            }            
          });
        }
      );
      return deferred.promise;
    }   
  };
  return AssetDetailProvider;
});
})();
@@ -1174,24 +1174,52 @@
 rOfTrades = 
+nxt.util.commaFormat(String(
 d.numberOfTr
@@ -1222,16 +1222,18 @@
 OfTrades
+))
 ;%0A      
@@ -1407,16 +1407,44 @@
 Today = 
+nxt.util.commaFormat(String(
 d.number
@@ -1456,16 +1456,18 @@
 desToday
+))
 ;%0A      
@@ -1676,19 +1676,23 @@
 PriceNQT
+%7C%7C'0'
 ;%0A
-%0A
       da
@@ -1802,24 +1802,45 @@
 .quantity = 
+nxt.util.commaFormat(
 nxt.util.con
@@ -1871,32 +1871,33 @@
 , this.decimals)
+)
 ;%0A      data.vol
@@ -1942,24 +1942,29 @@
 lumeTodayQNT
+%7C%7C'0'
 , this.decim
@@ -2033,16 +2033,21 @@
 TotalQNT
+%7C%7C'0'
 , this.d
@@ -2390,16 +2390,21 @@
 PriceNQT
+%7C%7C'0'
 ));%0A    
@@ -2463,24 +2463,24 @@
 toString();%0A
+
       data.m
@@ -2534,17 +2534,8 @@
 T);%0A
-%0A      %0A%0A
     

Format results