PageSourceSearch

https://www.dafshop.com/js/et/currencymanager/et_currencymanager_round.js

js dafshop.com collected 2026-10-05 03:40:04 UTC 6,971 bytes, 175 lines download raw bytes

1if (typeof(Product) != "undefined") {
2    Product.Config.prototype = Object.extend(Product.Config.prototype, {
3        formatPrice:function (price, showSign) {
4            var str = '';
5            price = parseFloat(price);
6            if (showSign) {
7                if (price < 0) {
8                    str += '-';
9                    price = -price;
10                }
11                else {
12                    str += '+';
13                }
14            }
15
16            var roundedPrice = (Math.round(price * 100) / 100).toString();
17
18            if (this.prices && this.prices[roundedPrice]) {
19                str += this.prices[roundedPrice];
20            }
21            else {
22                precision = 2;
23                if (typeof(etCurrencyManagerJsConfig) != "undefined") {
24                    if (typeof(etCurrencyManagerJsConfig.precision) != "undefined") {
25                        precision = etCurrencyManagerJsConfig.precision;
26                    }
27                }
28                if (typeof(optionsPrice) != "undefined") {
29                    if (typeof(optionsPrice.priceFormat) != "undefined") {
30                        precision = optionsPrice.priceFormat.requiredPrecision;
31                    }
32                }
33                if (typeof(etCurrencyManagerJsConfig) != "undefined") {
34                    if (typeof(etCurrencyManagerJsConfig.cutzerodecimal) != "undefined") {
35                        if (etCurrencyManagerJsConfig.cutzerodecimal != 0) {
36                            if (price - Math.round(price) == 0) {
37                                precision = 0;
38                            }
39                        }
40                    }
41                }
42                if (precision > 0) {
43                    str += this.priceTemplate.evaluate({price:price.toFixed(precision)});
44                }
45                else {
46                    price = price.toFixed(0);
47                    if (typeof(etCurrencyManagerJsConfig) != "undefined") {
48                        if (typeof(etCurrencyManagerJsConfig.cutzerodecimal) != "undefined") {
49                            if (etCurrencyManagerJsConfig.cutzerodecimal != 0) {
50                                if (typeof(etCurrencyManagerJsConfig.cutzerodecimal_suffix) != "undefined") {
51                                    if (etCurrencyManagerJsConfig.cutzerodecimal_suffix.length > 0) {
52                                        price = price + "" + etCurrencyManagerJsConfig.cutzerodecimal_suffix;
53                                    }
54                                }
55                            }
56                        }
57                    }
58                    str += this.priceTemplate.evaluate({price:price});
59                }
60            }
61            return str;
62        }
63
64
65    });
66}
67
68
69try {
70
71    originalFormatCurrency = window.formatCurrency;
72
73    window.formatCurrency = function (price, format, showPlus) {
74        //zeroSymbol
75        //JS round fix
76        price = Math.round(price * Math.pow(10, format.precision)) / Math.pow(10, format.precision);
77        if (price - Math.round(price) != 0) {
78            if (Math.abs(price - Math.round(price)) < 0.00000001) {
79                price = 0;
80            }
81        }
82        if (typeof(etCurrencyManagerJsConfig) != "undefined") {
83            if (price == 0) {
84                if (typeof(etCurrencyManagerJsConfig.zerotext) != "undefined") {
85                    return etCurrencyManagerJsConfig.zerotext;
86                }
87            }
88        }
89        //cut zero decimal
90        if (price - Math.round(price) == 0) {
91            if (typeof(etCurrencyManagerJsConfig) != "undefined") {
92                if (typeof(etCurrencyManagerJsConfig.cutzerodecimal) != "undefined") {
93                    if (etCurrencyManagerJsConfig.cutzerodecimal != 0) {
94                        format.precision = 0;
95                        format.requiredPrecision = 0;
96
97                        var for_replace = originalFormatCurrency(price, format, showPlus);
98
99                        if (typeof(etCurrencyManagerJsConfig.cutzerodecimal_suffix) != "undefined") {
100                            if (etCurrencyManagerJsConfig.cutzerodecimal_suffix.length > 0) {
101                                return for_replace.replace(price, price + ""
102                                    + etCurrencyManagerJsConfig.cutzerodecimal_suffix
102);
103                            }
104                        }
105                    }
106                }
107            }
108        }
109
110        return formatCurrencyET(price, format, showPlus);
111        //if(format.precision<0)format.precision=0;
112        //if(format.requiredPrecision<0)format.requiredPrecision=0;
113        /*return originalFormatCurrency(price, format, showPlus);*/
114
115
116    }
117
118
119    function formatCurrencyET(price, format, showPlus) {
120        var precision = isNaN(format.precision = (format.precision)) ? 2 : format.precision;
121        var requiredPrecision = isNaN(format.requiredPrecision = (format.requiredPrecision)) ? 2 : format.requiredPrecision;
122
123        //precision = (precision > requiredPrecision) ? precision : requiredPrecision;
124        //for now we don't need this difference so precision is requiredPrecision
125        precision = requiredPrecision;
126
127        var integerRequired = isNaN(format.integerRequired = Math.abs(format.integerRequired)) ? 1 : format.integerRequired;
128
129        var decimalSymbol = format.decimalSymbol == undefined ? "," : format.decimalSymbol;
130        var groupSymbol = format.groupSymbol == undefined ? "." : format.groupSymbol;
131        var groupLength = format.groupLength == undefined ? 3 : format.groupLength;
132
133        var s = '';
134
135        if (showPlus == undefined || showPlus == true) {
136            s = price < 0 ? "-" : ( showPlus ? "+" : "");
137        } else if (showPlus == false) {
138            s = '';
139        }
140
141        var i = parseInt(price = Math.abs(+price || 0).toFixed(precision)) + "";
142        var pad = (i.length < integerRequired) ? (integerRequired - i.length) : 0;
143        while (pad) {
144            i = '0' + i;
145            pad--;
146        }
147        j = (j = i.length) > groupLength ? j % groupLength : 0;
148        re = new RegExp("(\\d{" + groupLength + "})(?=\\d)", "g");
149
150        /**
151         * replace(/-/, 0) is only for fixing Safari bug which appears
152         * when Math.abs(0).toFixed() executed on "0" number.
153         * Result is "0.-0" :(
154         */
155        if (precision < 0) {
156            precision = 0;
157        }
158        var r = (j ? i.substr(0, j) + groupSymbol : "") + i.substr(j).replace(re, "$1" + groupSymbol) + (precision ? decimalSymbol + Math.abs(price - i).toFixed(precision).replace(/-/, 0).slice(2) : "")
159        var pattern = '';
160        if (format.pattern.indexOf('{sign}') == -1) {
161            pattern = s + format.pattern;
162        } else {
163            pattern = format.pattern.replace('{sign}', s);
164        }
165
166        return pattern.replace('%s', r).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
167    }
168
169    ;
170
171
172}
173catch (e) {
174    //do nothing
175}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.