Widget:Infobox recipes

 var infoboxRecipes = infoboxRecipes || { initialize : function { console.log( "Initializing recipes" ); $( "th.recipe" ).each( function {     id = $( this ).data( "id" );      console.log( "Initializing recipe " + id );      baseOutputCell = $( "td#recipe" + id + "-output-quantity" );      if ( baseOutputCell.length === 1 ) {        if ( $.isNumeric( baseOutputCell.data( "baseValue" ) ) ) {          desiredOutputCell = $( "td#recipe" + id + "-quantity" );          if ( desiredOutputCell.length === 1 ) {            desiredOutputBox = $( '' );            desiredOutputBox.css( 'width', '3.5em' );            desiredOutputBox.change( id, function( event ) { infoboxRecipes.update( event.data ); } );           desiredOutputCell.append( desiredOutputBox );            desiredOutputCell.parent.show;          }        }      }    } ); },

update : function( id ) { baseOutput = $( "td#recipe" + id + "-output-quantity" ).data( "baseValue" ); desiredOutput = $( "td#recipe" + id + "-quantity input" ).val; if ( $.isNumeric( baseOutput ) && $.isNumeric( desiredOutput ) ) { cycles = Math.ceil( desiredOutput / baseOutput ); $( ".recipe" + id + "-input-quantity" ).each( function {       baseInput = $( this ).data( "baseValue" );        if ( $.isNumeric( baseInput ) ) {          $( this ).html( ( baseInput * cycles ) + " x" );        }      } ); $( "td#recipe" + id + "-output-quantity" ).html( baseOutput * cycles ); } } }

RLQ.push( infoboxRecipes.initialize );