gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-backoffice] branch master updated: Parse amounts.


From: gnunet
Subject: [GNUnet-SVN] [taler-backoffice] branch master updated: Parse amounts.
Date: Tue, 05 Jun 2018 18:23:51 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository backoffice.

The following commit(s) were added to refs/heads/master by this push:
     new a092f8b  Parse amounts.
a092f8b is described below

commit a092f8b05572625c4485090da885e2ac41c0c398
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Jun 5 18:23:22 2018 +0200

    Parse amounts.
    
    String-amounts also get parsed.
---
 js/backoffice.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/js/backoffice.js b/js/backoffice.js
index 205a3bd..8ce913c 100644
--- a/js/backoffice.js
+++ b/js/backoffice.js
@@ -39,6 +39,15 @@ var LAST = 0;
  * it wrong.
  */
 function amount_to_string(amount){
+  if (typeof amount === 'string' || amount instanceof String)
+  {
+    var split = amount.match(/([A-Z]+):([0-9]+)\.?([0-9]+)?/);
+    if (!split)
+      return "Bad amount given: " + amount;
+    if (split[3])
+      return `${split[2]}.${split[3]} ${split[1]}`;
+    return `${split[2]}.00 ${split[1]}`;
+  }
   var number = Number(amount.value) +
               (Number(amount.fraction)/FRACTION);
   return `${number.toFixed(2)} ${amount.currency}`;
@@ -387,7 +396,7 @@ function fill_table(scroll, data, execution_time, 
wtid_marker){
       ${entry.order_id}</a>`;
     td_summary.className = "summary";
     td_summary.innerHTML = entry.summary;
-    td_amount.innerHTML = entry.amount;
+    td_amount.innerHTML = amount_to_string(entry.amount);
     td_date.innerHTML = parse_date
       (entry.timestamp || execution_time);
     row.appendChild(td_order_id);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]