Brauhaus.js Playground (Coffeescript)

A simple playground to test out Brauhaus recipe creation and calculation

by danielgtaylor

HTML

<script src="https://rawgithub.com/homebrewing/brauhausjs/master/dist/brauhaus.min.js"></script>
<div id="log"></div>

CSS

body {
    font-family: monospace;
}

CoffeeScript

# Log a message to the result window
log = (message) ->
    $('#log').append "#{message}<br/>"

# Create a new recipe
recipe = new Brauhaus.Recipe
    name: 'Test Recipe'
    batchSize: 20.0
    ibuMethod: 'tinseth'

# Add 4kg of pale extract
recipe.add 'fermentable',
    name: 'Extra pale extract'
    weight: 4.0
    color: 2.5
    yield: 75.0

# Add 1oz of cascade at 60 minutes
recipe.add 'spice',
    name: "Cascade hops"
    weight: Brauhaus.lbOzToKg 0, 1.0
    time: 60
    aa: 4.5
    form: 'pellet'

# Add some liquid yeast
recipe.add 'yeast',
    name: 'Wyeast 3052'
    type: 'ale'
    form: 'liquid'
    attenuation: 74

# Calculate the recipe values!
recipe.calculate()

log "#{recipe.name}"
log '--------------------------'
log "Batch size: #{recipe.batchSize.toFixed 1} liters (#{Math.round(recipe.batchSize / recipe.servingSize)} bottles)"
log "Boil size: #{recipe.boilSize.toFixed 1} liters"
log ""
log "OG: #{recipe.og.toFixed 3} (#{recipe.ogPlato.toFixed 1}&deg; Plato)"
log "FG: #{recipe.fg.toFixed 3} (#{recipe.fgPlato.toFixed 1}&deg; Plato)"
log "Color: #{recipe.color.toFixed 1}&deg; SRM <span style='display: inline-block; width: 12px; height: 12px; background-color: #{Brauhaus.srmToCss(recipe.color)}'></span>"
log "IBU: #{recipe.ibu.toFixed 1}"
log "ABV: #{recipe.abv.toFixed 1}%"
log "Calories: #{Math.round recipe.calories}"
log ""
log "BU/GU: #{recipe.buToGu.toFixed 2}"
log "BV: #{recipe.bv.toFixed 2}"
log ""
log "Cost: about $#{recipe.price.toFixed 2} ($#{(recipe.price / (recipe.batchSize / recipe.servingSize)).toFixed 2} / bottle)"