java to processing

edited May 2017 in JavaScript Mode

how can i convert this java code to processing ive tried a few times but really dont know enough about java or processing thanks in advance for any advice.

<script type="text/javascript"> $(document).ready(function() { function ReturnConversion(Value) { //if(Value.Sym } var MetricPrefixes = { "Symbol": { 'tera' : 'T', 'giga' : 'G', 'mega' : 'M', 'kilo' : 'k', 'mili' : 'm', 'micro' : 'μ', 'nano' : 'n', 'pico' : 'p' }, "Conversion": { 'tera' : 12, 'giga' : 9, 'mega' : 6, 'kilo' : 3, 'mili' : -3, 'micro' : -6, 'nano' : -9, 'pico' : -12 }} var RegExArray = []; var ConversionArray = []; $.each(MetricPrefixes.Symbol,function(K,V) { RegExArray.push(V); ConversionArray[V] = MetricPrefixes.Conversion[K]; }); var RegEx = new RegExp('['+RegExArray.join(',')+']'); $('input[name=Ohms]').keyup(function() { var Symbol = $(this).val().match(RegEx); var Value = $(this).val().replace(RegEx,''); if(Symbol) { var Counter = 0; while(Counter != ConversionArray[Symbol[0]]) { if(ConversionArray[Symbol[0]] > 0) { Value = Value * 10; Counter++; } else { Value = Value / 10; Counter--; var DecimalPlace = ConversionArray[Symbol[0]] - (ConversionArray[Symbol[0]] * 2); } } } $('b').text(Value.toFixed(DecimalPlace ? DecimalPlace : 0)+' Ohms'); }); }); </script> Ohms: <input name="Ohms"/><br/> <b style="font-size:20px;color:green;"></b>

Answers

Sign In or Register to comment.