~rpadovani/ubuntu-calculator-app/localStorage20141220

« back to all changes in this revision

Viewing changes to app/engine/formula.js

Fix displaying engine

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
function returnFormulaToDisplay(engineFormulaToDisplay) {
97
97
    var engineToVisualMap = {
98
98
        '-': '−',
99
 
        '/': '÷',
100
 
        '*': '×',
101
 
        'pi': 'π',
102
 
        '.': decimalPoint,
 
99
        '\\/': '÷',
 
100
        '\\*': '×',
 
101
        '\\.': decimalPoint,
103
102
        'NaN': i18n.tr("NaN"),
104
103
        'Infinity': '∞'
105
104
    }
106
105
 
107
106
    if (engineFormulaToDisplay !== undefined) {
108
107
        for (var engineElement in engineToVisualMap) {
109
 
            // FIXME: need to add 'g' flag, but "new RegExp(engineElement, 'g');"
110
 
            // is not working for me
111
 
            engineFormulaToDisplay = engineFormulaToDisplay.replace(
112
 
                engineElement, engineToVisualMap[engineElement]);
 
108
            var regExp = new RegExp(engineElement, 'g');
 
109
            engineFormulaToDisplay = engineFormulaToDisplay.replace(regExp, engineToVisualMap[engineElement]);
113
110
        }
114
 
    }
115
 
    else {
 
111
    } else {
116
112
        engineFormulaToDisplay = '';
117
113
    }
118
114