• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

jElectronics Javascript electronics calculations library

Status
Not open for further replies.

Hackpenguin

New Member
heres my javascript library that contains a lot of functions and objects that can be used for electronic calculations.
heres a list of some of the stuff it can do
  • Ohms law
  • Resistor Color code(4-band and 5-band resistors)
  • Series and Parallel array of resistance,capacitance and inductance
  • Reactance and resonance
  • Voltage Dividers
  • LED Resistor Calculator
In version 1.1 I added some methods to the jElectronics Object.
Source Code:
Code:
/*
jElectronics library v1.1 by Justin Roeder
Does electronic engineering calculations.

Website http://jelectronics.delphijustin.biz

*/
var doctitle="";//title of the page before CreateHTMLCalculator was called
var LEDAmps=0;//Global variable for the Total LED Current
var registers= {x:jElectronics(),y:jElectronics(),R1:jElectronics(),R2:jElectronics()};//Registers for the HTML Calculator
var colors=new Array("Black","Brown","Red","Orange","Yellow","Green","Blue","Violet","Gray","White","Silver","Gold");//Resistor Color Code Array
function jElectronics(){//Object constructor function
return {Vf:0,Component:"Resistor",Volts:0,Amps:0,Ohms:0,Watts:0,Farads:0,Henries:0,Hertz:0,Rating:{Volts: 0,Amps:0,Ohms:0,Watts:0},
ResistorColor:{Four:{Band1:0,Band2:0,Band3:0,Str:function(){
return colors[this.Band1]+' '+colors[this.Band2]+' '+colors[this.Band3];
}},Five:{Band1:0,Band2:0,Band3:0,Band4:0,Str:function(){
return colors[this.Band1]+' '+colors[this.Band2]+' '+colors[this.Band3]+' '+colors[this.Band4];
}}},
UpdateResistorColor:function(){ObjectToResistorColor(this);},//Updates the resistor color code
UpdateReactance:function(){Reactance(this);},//Update the object with Reactance.
UpdateOhmsLaw:function(){OhmsLaw(this);},//Update the object with ohms law
UpdateResonant:function(){Resonant(this);},//Update the object with Resonance
SeriesOhms:function(a){this.Ohms=Series(a,'RESISTOR');},//Series resistance from a array of resistances
SeriesFarads:function(a){this.Farads=Series(a,'CAPACITOR');},//Series Capacitance from a array of capacitances
SeriesHenries:function(a){this.Henries=Series(a,'INDUCTOR');},//Series Inductance from a array of inductances
ParallelOhms:function(a){this.Ohms=Parallel(a,'RESISTOR');},//Parallel Resistance from a array of resistances
ParallelFarads:function(a){this.Farads=Parallel(a,'CAPACITOR');},//Parallel Capacitance from a array of capacitances
ParallelHenries:function(a){this.Henries=Parallel(a,'INDUCTOR');}//Parallel Inductance from a array of inductances
};
}
function ResistorMultiplier(c){//Library function,do not use
if(c==10){return 0.01;}
if(c==11){return 0.1;}
return Math.pow(10,c);
}
function OhmsLaw(obj){//does an ohms law update on the object returned from jElectronics() function
if(obj.Volts==0){obj.Volts=obj.Ohms*obj.Amps;}
if(obj.Amps==0){obj.Amps=obj.Volts/obj.Ohms;}
if(obj.Ohms==0){obj.Ohms=obj.Volts/obj.Amps;}
obj.Watts=obj.Volts*obj.Amps;
}
function Resonant(obj){//calculates resonances of a object
if(obj.Hertz==0){obj.Hertz=1/(2*Math.PI*Math.sqrt(obj.Farads*obj.Henries));}
if(obj.Henries==0){obj.Henries=1/(Math.pow(4*Math.PI,2)*Math.pow(obj.Hertz,2)*obj.Farads);}
if(obj.Farads==0){obj.Farads=1/(Math.pow(4*Math.PI,2)*Math.pow(obj.Hertz,2)*obj.Henries);}
}
function Series(x,ctype){//Series calculation of a array of values
var y=0;
for(z=0;z<x.length;z++){
switch(ctype.toUpperCase()){
case "CAPACITOR":y+= 1/(MetricPrefixToNumber(x[z]));break;
case "INDUCTOR":
case "RESISTOR":y+=MetricPrefixToNumber(x[z]);
}
}
if(ctype.toUpperCase()=="CAPACITOR"){return 1/y;}
return y;
}
function Parallel(x,ctype){//Calculates the parallel of an array of values
var y=0;
for(z=0;z<x.length;z++){
switch(ctype.toUpperCase()){
case "RESISTOR":
case "INDUCTOR":y+= 1/MetricPrefixToNumber(x[z]);break;
case "CAPACITOR":y+=MetricPrefixToNumber(x[z]);
}
}
if(ctype.toUpperCase()!="CAPACITOR"){return 1/y;}
return y;
}
function Reactance(obj){//Does reactance on the object,if Component is set to capacitor it will do capacitive reactance,if inductor then inductive reactanc,set to something else does nothing
if(obj.Component.toUpperCase()=="CAPACITOR"){
if(obj.Ohms==0){obj.Ohms=1/(2*Math.PI*obj.Hertz*obj.Farads);}
if(obj.Hertz==0){obj.Hertz=1/(2*Math.PI*obj.Ohms*obj.Farads);}
if(obj.Farads==0){obj.Farads=1/(2*Math.PI*obj.Ohms*obj.Hertz);}
} else {
if(obj.Component.toUpperCase()=="INDUCTOR"){
if(obj.Ohms==0){obj.Ohms=2*Math.PI*obj.Hertz*obj.Henries;}
if(obj.Hertz==0){obj.Hertz=obj.Ohms/(2*Math.PI*obj.Henries);}
if(obj.Henries==0){obj.Henries=obj.Ohms/(2*Math.PI*obj.Hertz);}
} else {return "?Invalid Component Type";}}
}
function LEDCalc(LED,PSU){//Calculates the LED Current from an object returned from jElectronics()
LED.Component="LED";
LED.Volts=PSU.Volts-LED.Vf;
OhmsLaw(LED);
}
function ObjectToResistorColor(obj){//Gets the Resistor Color Code from obj.Ohms
for(a=1;a<10;a++){
for(b=0;b<10;b++){
for(c=0;c<12;c++){
if(((a*10)+b)*ResistorMultiplier(c)==obj.Ohms){obj.ResistorColor.Four={Band1: a,Band2:b,Band3:c,Str:function(){
return colors[this.Band1]+' '+colors[this.Band2]+' '+colors[this.Band3];
}};break;}
}}}
for(a=1;a<10;a++){
for(b=0;b<10;b++){
for(c=0;c<10;c++){
for(d=0;d<12;d++){
if(((a*100)+(b*10)+c)*ResistorMultiplier(d)==obj.Ohms){obj.ResistorColor.Five={Band1:a,Band2:b,Band3:c,Band4:d,Str:function(){
return colors[this.Band1]+' '+colors[this.Band2]+' '+colors[this.Band3]+' '+colors[this.Band4];
}};break;}
}}}}
}
function UpdateWattage(obj,typ){//Updates the wattage,this is usually used by other functions in this library,the typ parameter is returned from jseDefineTypes function
if(typ.Volts&&typ.Amps){obj.Watts=obj.Volts*obj.Amps;}
if(typ.Amps&&typ.Ohms){obj.Watts=(obj.Amps*obj.Amps)*obj.Ohms;}
if(typ.Volts&&typ.Ohms){obj.Watts=(obj.Volts*obj.Volts)/obj.Ohms;}
}
function jseDefine(strFlags){//Defines which variables are to be used in the function by given string of flags.
var Flags=strFlags.toUpperCase();
return {Volts: (Flags.indexOf("V")>-1),Amps:(Flags.indexOf("A")>-1),Ohms: (Flags.indexOf("R")>-1)};
}
function VoltageDivide(R1,R2,VinObj){
/*
R1 is the resistor 1 object
R2 is the resistor 2 object
Voltage Out on the R2.Volts
*/
if(R2.Volts==0){R2.Volts=VinObj.Volts*(R2.Ohms/(R1.Ohms+R2.Ohms));}
if(VinObj.Volts==0){VinObj.Volts=(R2.Volts*((R1.Ohms+R2.Ohms)/R2.Ohms));}
if(R1.Ohms==0){R1.Ohms=-R2.Ohms+((R2.Ohms*VinObj.Volts)/R2.Volts);}
if(R2.Ohms==0){R2.Ohms=-((R2.Volts*R1.Ohms)/(R2.Volts-VinObj.Volts));}
R1.Volts=VinObj.Volts-R2.Volts;
var tmp=jElectronics();
tmp.Volts=VinObj.Volts;
tmp.Ohms=R1.Ohms;
OhmsLaw(tmp);
R1.Amps=tmp.Amps;
tmp.Ohms=R2.Ohms;
tmp.Amps=0;
OhmsLaw(tmp);
R2.Amps=tmp.Amps;
var RT=jElectronics();
RT.Ohms=R1.Ohms+R2.Ohms;
RT.Volts=VinObj.Volts;
OhmsLaw(RT);
return RT;
}
function UpdateResistorColor(obj,bands){
switch(bands){
case 4: obj.Ohms=(((obj.ResistorColor.Four.Band1*10)+Number(obj.ResistorColor.Four.Band2))*ResistorMultiplier(obj.ResistorColor.Four.Band3));
break;
case 5: obj.Ohms=((obj.ResistorColor.Five.Band1*100)+(obj.ResistorColor.Five.Band2*10)+Number(obj.ResistorColor.Five.Band3))*ResistorMultiplier(obj.ResistorColor.Five.Band4-1);
break;
}
ObjectToResistorColor(obj);
}
function UpdateResistorC(form,mode){//used for the html calculator
registers.x.ResistorColor.Four.Band1=form.c0.value;registers.x.ResistorColor.Five.Band1=form.c0.value;
registers.x.ResistorColor.Four.Band2=form.c1.value;registers.x.ResistorColor.Five.Band2=form.c1.value;
registers.x.ResistorColor.Four.Band3=form.c2.value;registers.x.ResistorColor.Five.Band3=form.c2.value;
registers.x.ResistorColor.Five.Band4=form.c3.value;
switch(mode){
case 1:
if(form.c0.value+form.c1.value+form.c2.value!=Math.abs(form.c0.value+form.c1.value+form.c2.value)){alert("The first 3 colors must be used");break;}
if(form.c3.value==-1){UpdateResistorColor(registers.x,4);}else{UpdateResistorColor(registers.x,5);}
form.r.value=NumberToMetricPrefix(registers.x.Ohms);
break;
case 0:registers.x.Ohms=MetricPrefixToNumber(form.r.value);
ObjectToResistorColor(registers.x);
document.getElementById("jeCalc").innerHTML+=form.r.value+' 4-band:'+colors[registers.x.ResistorColor.Four.Band1]+" "+colors[registers.x.ResistorColor.Four.Band2]+" "+colors[registers.x.ResistorColor.Four.Band3]+'<br>';
document.getElementById("jeCalc").innerHTML+=form.r.value+' 5-band:'+colors[registers.x.ResistorColor.Five.Band1]+" "+colors[registers.x.ResistorColor.Five.Band2]+" "+colors[registers.x.ResistorColor.Five.Band3]+" "+colors[registers.x.ResistorColor.Five.Band4]+'<br>';
}
}
function NumberToMetricPrefix(x){//Takes a number and formats it into a metric prefix string
if(x>=Math.pow(10,6)){return Number(x/Math.pow(10,6))+" M";}
if(x>=1000){return Number(x/1000)+" K";}
if(x>=1||x==0){return x+" ";};
if(x>=0.001){return Number(x/0.001)+" m";}
if(x>=Math.pow(10,-6)){return Number(x/Math.pow(10,-6))+" u";}
if(x>=Math.pow(10,-9)){return Number(x/Math.poe(10,-3))+" n";}
return Number(x/Math.pow(10,-12))+" p";
}
function MetricPrefixToNumber(sx){//Takes a metric prefix string and converts it to a number,make sure theres a space between the number and the metric prefix(example "1k" should be "1 k")
switch(sx.charAt(sx.length-1)){
case "k":
case "K":return parseFloat(sx)*1000;
case "M":return parseFloat(sx)*1000000;
case "m":return parseFloat(sx)*0.001;
case "U":
case "u":return parseFloat(sx)*Math.pow(10,-6);
case "n":
case "N":return parseFloat(sx)*Math.pow(10,-9);
case "p":
case "P":return parseFloat(sx)*Math.pow(10,-12);
}
if(!isNaN(parseFloat(sx))){return parseFloat(sx); } else {return 0;}
}
function SetComponentValue(obj,sx){
var x=MetricPrefixToNumber(sx);
switch(obj.Component.toUpperCase()){
case "RESISTOR":obj.Ohms=x;break;
case "CAPACITOR":obj.Farads=x;break;
case "INDUCTOR":obj.Henries=x;break;
}
}
function GetComponentValue(obj){
switch(obj.Component.toUpperCase()){
case "CAPACITOR":return {Value:parseFloat(NumberToMetricPrefix(obj.Farads)),Units:NumberToMetricPrefix(obj.Farads).slice(-1)+"Farads", ActualValue: obj.Farads};
case "RESISTOR":return {Value: parseFloat(NumberToMetricPrefix(obj.Ohms)),Units:NumberToMetricPrefix(obj.Ohms).slice(-1)+"Ohms",ActualValue: obj.Ohms};
case "INDUCTOR":return {Value: parseFloat(NumberToMetricPrefix(obj.Henries)),Units:NumberToMetricPrefix(obj.Henries).slice(-1)+"Henries",ActualValue: obj.Henries};
}
}
function SP(form){
if(form.design.value=="s"){form.x.value=NumberToMetricPrefix(Series(form.x.value.split(","),form.component.value));} else
{form.x.value=Number(Parallel(form.x.value.split(","),form.component.value));}
/*
registers.x.Component=form.component.value;
registers.y.Component=form.component.value;
SetComponentValue(registers.x,form.x.value);
if(form.design.value=="s"){Series(registers.x,registers.y,form.bLast.checked);} else {
Parallel(registers.x,registers.y,form.bLast.checked);}
form.y.value=GetComponentValue(registers.y).Value+" "+GetComponentValue(registers.y).Units;
form.xa.value += GetComponentValue(registers.x).Value+" "+GetComponentValue(registers.x).Units+" "+form.design.value+'\r';
form.bLast.checked=false;
*/
}
function HTMLReactance(form,mode){
registers.x.Component=form.component.value;
registers.x.Ohms=MetricPrefixToNumber(form.ohms.value);
registers.x.Farads=MetricPrefixToNumber(form.farads.value);
registers.x.Henries=MetricPrefixToNumber(form.henries.value);
registers.x.Hertz=MetricPrefixToNumber(form.hertz.value);
registers.x.Volts=MetricPrefixToNumber(form.volts.value);
registers.x.Amps=MetricPrefixToNumber(form.amps.value);
if(mode==1){OhmsLaw(registers.x);}
if(mode==0){Reactance(registers.x);}
if(mode==2){Resonant(registers.x);}
form.hertz.value=NumberToMetricPrefix(registers.x.Hertz);
form.ohms.value=NumberToMetricPrefix(registers.x.Ohms);
form.farads.value=NumberToMetricPrefix(registers.x.Farads);
form.henries.value=NumberToMetricPrefix(registers.x.Henries);
form.volts.value=NumberToMetricPrefix(registers.x.Volts);
form.amps.value=NumberToMetricPrefix(registers.x.Amps);
}

function SetCalculatorMode(mode){
var s="";
LEDAmps=0;
registers.x=jElectronics();registers.y=jElectronics();registers.R1=jElectronics();registers.R2=jElectronics();
switch(mode){
case 0:
document.title='Menu - '+oldtitle;
document.getElementById("jeCalc").innerHTML='<input type="button" value="OhmsLaw" onclick="SetCalculatorMode(1)">'+
'<input type="button" value="Resistor Color Code" onclick="SetCalculatorMode(2)">'+
'<input type="button" value="Reactance" onclick="SetCalculatorMode(3)">'+
'<input type="button" value="Parallel/Series Combination" onclick="SetCalculatorMode(4)">'+
'<input type="button" value="Voltage Divider" onclick="SetCalculatorMode(5)">'+
'<input type="button" value="LED Resistor" onclick="SetCalculatorMode(6)">';break;
case 1:
document.title="Ohm's Law - "+oldtitle;
document.getElementById("jeCalc").innerHTML='<input type="text" name="volts" value="0">Volts<br>'+
'<input type="text" value="0" name="amps">Amps<br>'+
'<input type="text" value="0" name="ohms">Ohms<br>'+
'<input type="text" name="watts" readonly>Watts<br>'+
'<input type="button" value="Calculate" onclick="HTMLOhmsLaw(this.form)">';break;
case 2: document.title="Resistor Color Code - "+oldtitle;
document.getElementById("jeCalc").innerHTML='Resistor Value:<input type="text" name="r"><input type="button" value="Color From Resistance" onclick="UpdateResistorC(this.form,0)"><br>';
for(x=0;x<4;x++){
s+='<select name="c'+x+'">';
for(y=0;y<12;y++){
s+='<option value="'+y+'">'+colors[y]+'</option>';
}
s+='<option value="-1" selected>Not Used</option></select>';
}
document.getElementById("jeCalc").innerHTML+=s+'<input type="button" value="Resistance From Color" onclick="UpdateResistorC(this.form,1)"><p>';
break;
case 3: document.title="Reactance - "+oldtitle;
document.getElementById("jeCalc").innerHTML='Mode:<select name="component"><option value="capacitor" selected>Capacitive Reactance</option><option value="inductor">Inductive Reactance</option></select><br>'+
'Capacitance:<input type="text" name="farads" value="0"><br>'+
'Inductance:<input type="text" name="henries" value="0"><br><input type="button" value="Resonance" onclick="HTMLReactance(this.form,2)">'+
'Frequency:<input type="text" name="hertz" value="0"><br>'+
'Reactance:<input type="text" name="ohms" value="0"><input type="button" value="Calculate" onclick="HTMLReactance(this.form,0)"><br>'+
'AC Volts:<input type="text" name="volts" value="0"><br>'+
'Current:<input type="text" name="amps" value="0"><input type="button" value="Calulate with ohms law" onclick="HTMLReactance(this.form,1)">';
break;
case 4:
document.title="Series/Parallel Calculator - "+oldtitle;
document.getElementById("jeCalc").innerHTML='Component Values(Seperated by commas):<input type="text" name="x"><br>'+
'Type of component:<select name="component"><option value="resistor" selected>Resistor</option><option value="capacitor">Capacitor</option><option value="inductor">Inductor</option></select>'+
'Design:<select name="design"><option value="p">Parallel</option><option value="s" selected>Series</option><input type="button" value="Calculate" onclick="SP(this.form)"><br>';break;
case 5:
document.title="Voltage Divider - "+oldtitle;
document.getElementById("jeCalc").innerHTML='Voltage In:<input type="text" name="vin" value="0"><br>'+
'Voltage Out(voltage accross R2):<input type="text" name="vout" value="0"><br>'+
'R1 Resistance:<input type="text" name="r1" value="0"><br>'+
'R2 Resistance:<input type="text" name="r2" value="0"><br>'+
'R1 Voltage:<input type="text" name="r1v" value="0" readonly><br>'+
'Total Current:<input type="text" name="at" readonly>Max.Power:<input type="text" name="watts" readonly><br>'+
'<input type="button" value="Calculate" onclick="VD(this.form)"><br>'+
'<img src="http://subdiesel.files.wordpress.com/2011/06/voltagedivider1.png?w=500" width="256px" height="256px">';break;
case 6:document.title="LED Resistor - "+oldtitle;
document.getElementById("jeCalc").innerHTML='Current limiting resistor:<input type="text" name="r"><br>'+
'Voltage In:<input type="text" name="vin"><br>'+
'Forward Voltage Drop:<input type="text" name="vf"><br>'+
'Max. Current(in mA):<input type="number" name="amps" value="20"><input type="button" value="Add LED" onclick="AddLED(this.form)"><input type="button" value="Reset" onclick="SetCalculatorMode(6)"><br>'+
'<textarea name="list"></textarea>Total Current:<input type="text" name="it" readonly>';break;
default:alert("Feature not released yet!");return false;
}
document.getElementById("jeCalc").innerHTML+='<input type="button" value="Menu" onclick="SetCalculatorMode(0)">';
return true;
}
function AddLED(form){
registers.y.Volts=MetricPrefixToNumber(form.vin.value);
registers.x.Vf=MetricPrefixToNumber(form.vf.value);
registers.x.Amps=0.001*form.amps.value;
registers.x.Ohms=MetricPrefixToNumber(form.r.value);
LEDCalc(registers.x,registers.y);
form.vin.value=NumberToMetricPrefix(registers.y.Volts);
form.vf.value=NumberToMetricPrefix(registers.x.Vf);
form.amps.value=registers.x.Amps/0.001;
form.r.value=NumberToMetricPrefix(registers.x.Ohms);
LEDAmps+=registers.x.Amps;
form.it.value=NumberToMetricPrefix(LEDAmps);
form.list.value+='Vf:'+registers.x.Vf+',Ohms:'+NumberToMetricPrefix(registers.x.Ohms)+',If:'+Number(registers.x.Amps/0.001)+'\r';
}
function HTMLOhmsLaw(form){
if(parseFloat(form.volts.value)+parseFloat(form.amps.value)==0||parseFloat(form.ohms.value)+parseFloat(form.amps.value)==0||parseFloat(form.volts.value)+parseFloat(form.ohms.value)==0){
alert("There can only be one variable set to zero");
return false;
}
if(MetricPrefixToNumber(form.volts.value)*MetricPrefixToNumber(form.amps.value)*MetricPrefixToNumber(form.ohms.value)!=0){
alert("The variable your solving for must be set to zero first.");
return false;
}
var ol=jElectronics();
ol.Volts=MetricPrefixToNumber(form.volts.value);
ol.Ohms=MetricPrefixToNumber(form.ohms.value);
ol.Amps=MetricPrefixToNumber(form.amps.value);
OhmsLaw(ol);
form.volts.value=NumberToMetricPrefix(ol.Volts);
form.amps.value=NumberToMetricPrefix(ol.Amps);
form.ohms.value=NumberToMetricPrefix(ol.Ohms);
form.watts.value=NumberToMetricPrefix(ol.Watts);
}
function CreateHTMLCalculator(){//Call this up if you just want a easy already setup calculator with mode equal 0
oldtitle=document.title;
document.writeln('<form id="jeCalc" action="javascript:;">Loading...</form>');
document.writeln('<div id="jeStatus"></div>');
setTimeout("SetCalculatorMode(0)",5000);
}
function VD(form){
registers.R1.Volts=MetricPrefixToNumber(form.r1v.value);
registers.R1.Ohms=MetricPrefixToNumber(form.r1.value);
registers.R2.Ohms=MetricPrefixToNumber(form.r2.value);
registers.R2.Volts=MetricPrefixToNumber(form.vout.value);
registers.x.Volts=MetricPrefixToNumber(form.vin.value);
registers.y=VoltageDivide(registers.R1,registers.R2,registers.x);
form.at.value=NumberToMetricPrefix(registers.y.Amps);
form.watts.value=NumberToMetricPrefix(registers.y.Watts);
form.r1v.value=NumberToMetricPrefix(registers.R1.Volts);
form.r1.value=NumberToMetricPrefix(registers.R1.Ohms);
form.r2.value=NumberToMetricPrefix(registers.R2.Ohms);
form.vout.value=NumberToMetricPrefix(registers.R2.Volts);
form.vin.value=NumberToMetricPrefix(registers.x.Volts);
}
function isSafeOperating(obj){
/*
checks component objects rating to see if its at a safe operating level
Is Safe returns 0
otherwise the Return value is a combination of the following values
Too much voltage 1
Too much current 2
Too much wattage 4
Too low resistance 8

To check for an overload you can do a bitwise AND against it.
example:
if(isSafeOperating(obj)&4>0){document.writeln("Too much wattage");}
*/
var Overloads=0;
if(obj.Rating.Volts>0){if(Math.abs(obj.Volts)>obj.Rating.Volts){Overloads=1;}}
if(obj.Rating.Amps>0){if(Math.abs(obj.Amps)>obj.Rating.Volts){Overloads +=2;}}
if(obj.Rating.Watts>0){if(Math.abs(obj.Watts)>obj.Rating.Watts){Overloads+=4;}}
if(obj.Rating.Ohms>0){if(Math.abs(obj.Ohms)<obj.Rating.Ohms){Overloads+=8;}}
return Overloads;
}
Wanna try it out visit http://jelectronics.delphijustin.biz
 
Last edited:

Colin

Active Member
There are lots of little things you have to fix up with the calculators. m means nothing Max Power means nothing. 0 in the box should disappear when the value is inserted and lots more improvements.
 

DerStrom8

Super Moderator
Most Helpful Member
Please reformat your code. It is a mess as it sits.
 

Hackpenguin

New Member
I made some changes like support for BBCodes in forums, fixed spelling error of the powers command in MetricPrefixToNumber Function. To specify a metric prefix you must put a space in between the number and metric prefix for example 1k should be entered in as "1 k" instead of "1k". if you enter 1k in without a space you will get undefined calculations. I think the ohms law is better than what ETO has for theirs, i tried entering a metric prefix with a number on ETO and it refused calculate it. If you view the updated source code you will see how to add it into your forum. You may also want to check out this link here to see the documentation on how to use the library or you could just call CreateHTMLCalculator() function in javascript to display the HTML Calculator. Also the voltage dividers max power is calculating the power of 2 resistors in series, If you prefer ohms law done with just the lowest resistance please let me know so i can change it

API Documentation http://delphijustin.tk/jeAPI.html
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top