X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.js;h=41b3762a36feae20ef9630358e3a3e9dce94bca5;hb=0e04ddd7e3ff23d051838617844698a39f680969;hp=e17294a128fd95773b5bba74826615008a982bc5;hpb=fb63efe1b63573c2ee3535cb2f9e63502dd0e848;p=kivitendo-erp.git diff --git a/js/kivi.js b/js/kivi.js index e17294a12..41b3762a3 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -61,8 +61,16 @@ namespace("kivi", function(ns) { amount = amount.replace(/[\',]/g, "") + // Make sure no code wich is not a math expression ends up in eval(). + if (!amount.match(/^[0-9 ()\-+*/.]*$/)) + return 0; + /* jshint -W061 */ - return eval(amount); + try { + return eval(amount); + } catch (err) { + return 0; + } }; ns.round_amount = function(amount, places) { @@ -235,10 +243,7 @@ namespace("kivi", function(ns) { $(elt).datepicker(); }); - if (ns.PartPicker) - ns.run_once_for('input.part_autocomplete', 'part_picker', function(elt) { - kivi.PartPicker($(elt)); - }); + if (ns.Part) ns.Part.reinit_widgets(); if (ns.ProjectPicker) ns.run_once_for('input.project_autocomplete', 'project_picker', function(elt) { @@ -352,13 +357,13 @@ namespace("kivi", function(ns) { params.dialog || { }, { // Options that must not be changed: close: function(event, ui) { + dialog.dialog('close'); + if (custom_close) custom_close(); if (params.url || params.html) dialog.remove(); - else - dialog.dialog('close'); } }); @@ -438,7 +443,7 @@ namespace("kivi", function(ns) { ns.run = function(function_name, args) { var fn = ns.get_function_by_name(function_name); if (fn) - return fn.apply({}, args); + return fn.apply({}, args || []); console.error('kivi.run("' + function_name + '"): No function by that name found'); return undefined;