Subversion Repositories SmartDukaan

Rev

Rev 32301 | Rev 32567 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32301 Rev 32308
Line 66... Line 66...
66
        data: params,
66
        data: params,
67
        // dataType:'json',
67
        // dataType:'json',
68
        type: httpType,
68
        type: httpType,
69
        success: function (response) {
69
        success: function (response) {
70
            callback_function(response);
70
            callback_function(response);
71
            $('.currency').each(function (index, ele) {
-
 
72
                if (!isNaN(parseInt($(ele).html()))) {
-
 
73
                    $(ele).html(numberToComma($(ele).html()));
-
 
74
                }
-
 
75
            });
71
            formatCurrency();
76
        }
72
        }
77
    });
73
    });
78
}
74
}
79
 
75
 
80
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
76
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
Line 84... Line 80...
84
function doPostAjaxRequestWithParamsHandler(urlString, params,
80
function doPostAjaxRequestWithParamsHandler(urlString, params,
85
                                            callback_function) {
81
                                            callback_function) {
86
    doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
82
    doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
87
}
83
}
88
 
84
 
-
 
85
function formatCurrency() {
-
 
86
    $('.rcurrency').each(function (index, ele) {
-
 
87
        if (!isNaN(parseInt($(ele).html()))) {
-
 
88
            $(ele).html(numberToComma($(ele).html(), true));
-
 
89
        }
-
 
90
    });
-
 
91
    $('.currency').each(function (index, ele) {
-
 
92
        if (!isNaN(parseInt($(ele).html()))) {
-
 
93
            $(ele).html(numberToComma($(ele).html()));
-
 
94
        }
-
 
95
    });
-
 
96
 
-
 
97
}
-
 
98
 
89
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
99
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
90
                                      callback_function) {
100
                                      callback_function) {
91
    $.ajax({
101
    $.ajax({
92
        url: urlString,
102
        url: urlString,
93
        async: true,
103
        async: true,
Line 97... Line 107...
97
        contentType: 'application/json',
107
        contentType: 'application/json',
98
        type: httpType,
108
        type: httpType,
99
        success: function (response) {
109
        success: function (response) {
100
            // console.log("response"+JSON.stringify(data));
110
            // console.log("response"+JSON.stringify(data));
101
            callback_function(response);
111
            callback_function(response);
102
            $('.currency').each(function (index, ele) {
-
 
103
                if (!isNaN(parseInt($(ele).html()))) {
-
 
104
                    $(ele).html(numberToComma($(ele).html()));
-
 
105
                }
-
 
106
            });
112
            formatCurrency();
107
        }
113
        }
108
    });
114
    });
109
}
115
}
110
 
116
 
111
function doPostAjaxRequestWithJsonHandler(urlString, json, callback_function) {
117
function doPostAjaxRequestWithJsonHandler(urlString, json, callback_function) {
Line 122... Line 128...
122
        async: true,
128
        async: true,
123
        cache: false,
129
        cache: false,
124
        type: httpType,
130
        type: httpType,
125
        success: function (response) {
131
        success: function (response) {
126
            callback_function(response);
132
            callback_function(response);
127
            $('.currency').each(function (index, ele) {
-
 
128
                if (!isNaN(parseInt($(ele).html()))) {
-
 
129
                    $(ele).html(numberToComma($(ele).html()));
-
 
130
                }
-
 
131
            });
133
            formatCurrency();
132
        }
134
        }
133
    });
135
    });
134
}
136
}
135
 
137
 
136
function doGetAjaxRequestHandler(urlString, callback_function) {
138
function doGetAjaxRequestHandler(urlString, callback_function) {
Line 424... Line 426...
424
        }
426
        }
425
    });
427
    });
426
 
428
 
427
}
429
}
428
 
430
 
429
function numberToComma(x) {
431
function numberToComma(x, rounded) {
430
    if (isNaN(x)) {
432
    if (isNaN(x)) {
431
        x = x.replaceAll(",", '');
433
        x = x.replaceAll(",", '');
432
    }
434
    }
433
    x = parseFloat(x);
435
    x = parseFloat(x);
-
 
436
    if (typeof rounded != "undefined" && rounded) {
-
 
437
        x = Math.round(x);
-
 
438
    } else {
434
    x = Math.round(x * 100) / 100;
439
        x = Math.round(x * 100) / 100;
-
 
440
    }
435
    x = x.toString();
441
    x = x.toString();
436
    x = x.split('.');
442
    x = x.split('.');
437
    var x1 = x[0];
443
    var x1 = x[0];
438
    var x2 = x.length > 1 && x[1] != '0' ? '.' + x[1] : '';
444
    var x2 = x.length > 1 && x[1] != '0' ? '.' + x[1] : '';
439
    var lastThree = x1.substring(x1.length - 3);
445
    var lastThree = x1.substring(x1.length - 3);