From 98a64632fdc5636cf2a59457e703b73b00254595 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 23 Aug 2010 09:22:15 +0000 Subject: [PATCH] Fixed maxprec formatting. --- includes/current_user.inc | 3 ++- js/utils.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/current_user.inc b/includes/current_user.inc index 3f950567..7763ae67 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -251,6 +251,7 @@ function qty_format($number, $stock_id=null, &$dec) { $dec = get_qty_dec($stock_id); return number_format2($number, $dec); } + // and get_qty_dec function get_qty_dec($stock_id=null) { @@ -267,7 +268,7 @@ function get_qty_dec($stock_id=null) // Maximum precision format. Strips trailing unsignificant digits. // function maxprec_format($number) { - return number_format2($number, null); + return number_format2($number, 'max'); } function exrate_format($number) { diff --git a/js/utils.js b/js/utils.js index 1f1aa521..9b1b1ac4 100644 --- a/js/utils.js +++ b/js/utils.js @@ -105,7 +105,7 @@ JsHttpRequest._request = function(trigger, form, tout, retry) { // seek element by id if there is no elemnt with given name objElement = document.getElementsByName(id)[0] || document.getElementById(id); if(cmd=='as') { - eval("objElement.setAttribute('"+property+"',"+data+");"); + eval("objElement.setAttribute('"+property+"','"+data+"');"); } else if(cmd=='up') { // if(!objElement) alert('No element "'+id+'"'); if(objElement) { @@ -229,7 +229,8 @@ function price_format(post, num, dec, label, color) { num = num.substring(0,num.length-(4*i+3))+user.ts+ num.substring(num.length-(4*i+3)); num = ((sign)?'':'-') + num; - if(dec!=0) num = num + user.ds + cents; + if(dec!=0 && (!max || cents!=0)) + num = num + user.ds + cents; if(label) el.innerHTML = num; else -- 2.30.2