var km_fields = []; var unit_fields = []; var dc_fields = []; function str2hz(s){ return 150000*Math.pow(parseFloat(s), -1); } function str2unit(s){ var km2unit = (20/3)*(parseFloat($('#id_clock_in').val())/parseFloat($('#id_clock_divider').val())); var ret = ""; values = s.split(","); for (i=0; i0){ llabel = label.replace("first_height", "last_height"); rlabel = label.replace("first_height", "resolution"); nlabel = label.replace("first_height", "number_of_samples"); value = parseFloat($(label).val())+parseFloat($(rlabel).val())*(parseInt($(nlabel).val())-1); $(llabel).val(value); } if (label.indexOf("resolution")>0){ llabel = label.replace("resolution", "last_height"); flabel = label.replace("resolution", "first_height"); nlabel = label.replace("resolution", "number_of_samples"); value = parseFloat($(flabel).val())+parseFloat($(label).val())*(parseInt($(nlabel).val())-1); $(llabel).val(value); } if (label.indexOf("number_of_samples")>0){ llabel = label.replace("number_of_samples", "last_height"); rlabel = label.replace("number_of_samples", "resolution"); flabel = label.replace("number_of_samples", "first_height"); value = parseFloat($(flabel).val())+parseFloat($(rlabel).val())*(parseInt($(label).val())-1); $(llabel).val(value); } if (label.indexOf("last_height")>0){ flabel = label.replace("last_height", "first_height"); rlabel = label.replace("last_height", "resolution"); nlabel = label.replace("last_height", "number_of_samples"); nvalue = Math.round((parseFloat($(label).val())-parseFloat($(flabel).val()))/parseFloat($(rlabel).val()))+1; $(nlabel).val(nvalue); value = parseFloat($(flabel).val())+parseFloat($(rlabel).val())*(nvalue-1); $(label).val(value); } } $("#id_clock_in").change(function() { $("#id_clock").val(parseFloat($('#id_clock_in').val())/parseFloat($('#id_clock_divider').val())); updateUnits(); }); $("#id_clock_divider").change(function() { $("#id_clock").val(parseFloat($('#id_clock_in').val())/parseFloat($('#id_clock_divider').val())); updateUnits(); });