@@ -55,15 +55,21 @@ function Toasts({ toastMxVIsource, toastCopiedLatex, toastCopiedMathML }) {
5555 < strong className ="me-auto "> Copied to clipboard</ strong >
5656 < button type ="button " className ="btn-close " data-bs-dismiss ="toast "> </ button >
5757 </ div >
58- < div className ="toast-body "> Copied to your clipboard. Here's a free online latex editor: < a className ="text-white " href ="https://latexeditor.lagrida.com/ " target ="_blank "> https://latexeditor.lagrida.com/</ a > </ div >
58+ < div className ="toast-body ">
59+ Copied to your clipboard. Here's a free online latex editor:
60+ < a className ="text-white " href ="https://latexeditor.lagrida.com/ " target ="_blank "> https://latexeditor.lagrida.com/</ a >
61+ </ div >
5962 </ div >
6063
6164 < div id ="liveToast " className ="toast bg-success text-white " role ="alert " ref =${ toastCopiedMathML } >
6265 < div className ="toast-header ">
6366 < strong className ="me-auto "> Copied to clipboard</ strong >
6467 < button type ="button " className ="btn-close " data-bs-dismiss ="toast "> </ button >
6568 </ div >
66- < div className ="toast-body "> Copied to your clipboard. Here's a free online MathML editor: < a className ="text-white " href ="https://codepen.io/bqlou/pen/yOgbmb " target ="_blank "> https://codepen.io/bqlou/pen/yOgbmb</ a > </ div >
69+ < div className ="toast-body ">
70+ Copied to your clipboard. Here's a free online MathML editor:
71+ < a className ="text-white " href ="https://codepen.io/bqlou/pen/yOgbmb " target ="_blank "> https://codepen.io/bqlou/pen/yOgbmb</ a >
72+ </ div >
6773 </ div >
6874 </ div >
6975 ` ;
@@ -318,9 +324,11 @@ function updateGraph(el, freq, mag) {
318324
319325function TransformResults ( props ) {
320326 // console.log(props)
321- const mathMlString = `<math>${ props . chosen == 'vo' ? `<mfrac><mrow><mi>V</mi><mn>o</mn></mrow><mrow><mi>${ props . iinOrVin == "vin" ? "V" : "I" } </mi><mn>i</mn></mrow></mfrac>` : `<msub><mi>I</mi><mn>prb0</mn></msub>` } <mo>=</mo>${
322- props . latex
323- } </math>`;
327+ const mathMlString = `<math>${
328+ props . chosen == "vo"
329+ ? `<mfrac><mrow><mi>V</mi><mn>o</mn></mrow><mrow><mi>${ props . iinOrVin == "vin" ? "V" : "I" } </mi><mn>i</mn></mrow></mfrac>`
330+ : `<msub><mi>I</mi><mn>prb0</mn></msub>`
331+ } <mo>=</mo>${ props . latex } </math>`;
324332 var z = html `
325333 < div key ="c1 " className ="col-12 ">
326334 < div key ="r1 " className ="row ">
@@ -329,18 +337,31 @@ function TransformResults(props) {
329337 </ div >
330338 < div key ="select " className ="col-6 text-end ">
331339 < div className ="form-check form-check-inline ">
332- < input key ="radio " className ="form-check-input " type ="radio " name ="${ `${ props . title } inlineRadioOptions` } " value ="vo " checked =${ props . chosen == 'vo' } onChange =${ ( e ) => props . handlePlotChange ( e ) } />
340+ < input
341+ key ="radio "
342+ className ="form-check-input "
343+ type ="radio "
344+ name ="${ `${ props . title } inlineRadioOptions` } "
345+ value ="vo "
346+ checked =${ props . chosen == "vo" }
347+ onChange =${ ( e ) => props . handlePlotChange ( e ) } />
333348 < label key ="lable " className ="form-check-label "> ${ props . iinOrVin == "vin" ? "Vo/Vi" : "Vo/Ii" } </ label >
334349 </ div >
335- ${ props . iprbList . map ( Y => {
336- return html `
337- < div className ="form-check form-check-inline " key ="iprb ${ Y } ">
338- < input key ="radio " className ="form-check-input " type ="radio " name ="${ `${ props . title } inlineRadioOptions` } " value ="Y ${ Y } " checked =${ props . chosen == `Y${ Y } ` } onChange =${ ( e ) => props . handlePlotChange ( e ) } />
339- < label key ="lable " className ="form-check-label "> Iprb${ Y } </ label >
340- </ div >
341- `
350+ ${ props . iprbList . map ( ( Y ) => {
351+ return html `
352+ < div className ="form-check form-check-inline " key ="iprb ${ Y } ">
353+ < input
354+ key ="radio "
355+ className ="form-check-input "
356+ type ="radio "
357+ name ="${ `${ props . title } inlineRadioOptions` } "
358+ value ="Y ${ Y } "
359+ checked =${ props . chosen == `Y${ Y } ` }
360+ onChange =${ ( e ) => props . handlePlotChange ( e ) } />
361+ < label key ="lable " className ="form-check-label "> Iprb${ Y } </ label >
362+ </ div >
363+ ` ;
342364 } ) }
343-
344365 </ div >
345366 </ div >
346367 < div key ="r2 " className ="row text-center fs-3 py-2 ">
@@ -614,7 +635,7 @@ class Game extends React.Component {
614635 gnd : false ,
615636 solvable : false ,
616637 } ,
617- chosenPlot :'vo'
638+ chosenPlot : "vo" ,
618639 } ;
619640
620641 this . TESTER = null ;
@@ -637,7 +658,6 @@ class Game extends React.Component {
637658
638659 calculateTF ( ) {
639660 const current = this . state . history [ this . state . history . length - 1 ] ;
640- // console.log(this.schematicReady())
641661 if ( ! this . schematicReady ( ) ) {
642662 // console.log('thhhhh')
643663 updateGraph ( this . TESTER , [ ] , [ ] ) ;
@@ -671,7 +691,7 @@ class Game extends React.Component {
671691
672692 for ( var f = fmin ; f < fmax ; f = f * fstep ) {
673693 this . freq . push ( f ) ;
674- this . mag . push ( 20 * Math . log10 ( eval ( res . replace ( re , 2 * Math . PI * f ) ) ) ) ;
694+ this . mag . push ( 20 * Math . log10 ( Math . abs ( eval ( res . replace ( re , 2 * Math . PI * f ) ) ) ) ) ;
675695 }
676696
677697 // console.log("response: ", this.freq, this.mag )
@@ -698,13 +718,13 @@ class Game extends React.Component {
698718
699719 //prevent multiple current probes
700720 var allLetters = Array . from ( a . id ) ;
701- if ( allLetters [ 0 ] == 'Y' ) {
721+ if ( allLetters [ 0 ] == "Y" ) {
702722 for ( const e in this . state . elOnSchematic ) {
703723 allLetters = Array . from ( e ) ;
704- if ( allLetters [ 0 ] == 'Y' ) {
724+ if ( allLetters [ 0 ] == "Y" ) {
705725 this . bsToast . show ( ) ;
706726 return ;
707- }
727+ }
708728 }
709729 }
710730 addToSchematic ( a ) ;
@@ -816,7 +836,7 @@ class Game extends React.Component {
816836 ) ;
817837 } else {
818838 // console.log(iprbList, iprbList.length);
819- if ( iprbList . length == 0 ) this . setState ( { chosenPlot : 'vo' } ) ;
839+ if ( iprbList . length == 0 ) this . setState ( { chosenPlot : "vo" } ) ;
820840 this . setState (
821841 {
822842 history : this . state . history . concat ( [ current ] ) ,
@@ -887,11 +907,10 @@ class Game extends React.Component {
887907 // return;
888908 this . setState (
889909 {
890- chosenPlot : e . target . value
891- } , ( ) => this . redrawSchematic ( current )
910+ chosenPlot : e . target . value ,
911+ } ,
912+ ( ) => this . redrawSchematic ( current )
892913 ) ;
893-
894-
895914 }
896915
897916 handleUnitChange ( e , i ) {
@@ -969,7 +988,6 @@ class Game extends React.Component {
969988 history : this . state . history ,
970989 } ) ;
971990
972-
973991 // this.setState(
974992 // {
975993 // history: this.state.history.concat([current]),
@@ -1048,21 +1066,22 @@ class Game extends React.Component {
10481066 </ div >
10491067 </ div >
10501068 < div key ="bilin " className ="row my-2 py-1 shadow-sm rounded bg-lightgreen ">
1051-
1052- < ${ TransformResults }
1053- name ="World"
1054- key="TransformResultsBilin"
1055- title="Bilinear"
1056- latex=${ this . state . bilinearMathML }
1057- iinOrVin=${ this . state . iinOrVin }
1058- iprbList=${ [ ] }
1059- copiedToast=${ this . copiedToast }
1060- handleRequestBilin=${ ( ) => this . handleRequestBilin ( ) }
1061- copiedToastML=${ this . copiedToastML }
1062- handlePlotChange=${ ( e ) => this . handlePlotChange ( e ) }
1063- chosen=${ this . state . chosenPlot } />
1064- < ${ Comments } key ="comments" />
1065- </ div >
1069+ < ${ TransformResults }
1070+ name ="World"
1071+ key="TransformResultsBilin"
1072+ title="Bilinear"
1073+ latex=${ this . state . bilinearMathML }
1074+ iinOrVin=${ this . state . iinOrVin }
1075+ iprbList=${ [ ] }
1076+ copiedToast=${ this . copiedToast }
1077+ handleRequestBilin=${ ( ) => this . handleRequestBilin ( ) }
1078+ copiedToastML=${ this . copiedToastML }
1079+ handlePlotChange=${ ( e ) => this . handlePlotChange ( e ) }
1080+ chosen=${ this . state . chosenPlot } />
1081+ </ div >
1082+ < div key ="comments " className ="row my-2 py-1 shadow-sm rounded bg-lightgreen ">
1083+ < ${ Comments } key ="comments" />
1084+ </ div >
10661085 </ div >
10671086 </ div >
10681087 ` ;
0 commit comments