updated calculator:

This commit is contained in:
Rushabh Mehta 2014-05-29 18:23:56 +05:30
parent a636f324c4
commit b3b25f501e
2 changed files with 12 additions and 9 deletions

View file

@ -169,22 +169,25 @@ frappe.search.verbs = [
}
},
// pages
// calculator
function(txt) {
var first = txt.substr(0,1);
if(first==parseInt(first) || first==="(" || first==="=") {
if(first==="=") {
txt = txt.substr(1);
}
try {
var val = eval(txt);
} catch(e) {
var val = e.message;
}
frappe.search.options.push({
value: __('Calculate "{0}"', [txt]),
match: txt,
value: $.format('"{0}" = {1}', [txt, val]),
match: val,
onclick: function(match) {
try {
msgprint(eval(match), __('Calculate "{0}"', [match]));
} catch(e) {
msgprint(e.message);
}
msgprint(match, "Result");
}
});
};

View file

@ -45,7 +45,7 @@ frappe.ui.toolbar.Toolbar = Class.extend({
placeholder="' + __("Search or type a command") + '" \
style="padding: 2px 6px; height: 24px; margin-top: 5px; \
margin-left: 10px; background-color: #ddd; \
min-width: 200px; \
min-width: 250px; \
border-radius: 10px;">\
</div>\
</form>\