diff --git a/src/humulus/static/recipes.js b/src/humulus/static/recipes.js
index c6daad4..c105df7 100644
--- a/src/humulus/static/recipes.js
+++ b/src/humulus/static/recipes.js
@@ -14,6 +14,25 @@
limitations under the License.
*/
+// Calculate percentage and background color for display functions
+function calculatePct(value, low, high) {
+ var pct = Math.round(100 * (value-low )/ (high - low));
+ var color = 'bg-success';
+ if (pct > 85) {
+ color = 'bg-danger';
+ if (pct > 100) {
+ pct = 100;
+ }
+ } else if (pct <=15 ) {
+ color = 'bg-warning';
+ if (pct <= 0) {
+ pct = 5; // We want a little bit of bar showing
+ }
+ }
+
+ return {pct: pct, color: color};
+}
+
// unbinds and re-binds the change event
function rebindChangeEvents() {
$('.ingredient-field').unbind('change');
@@ -90,7 +109,7 @@ function addFerm() {
// Type field
'
-
{{ render_field_with_errors(fermentable.form.type, 'form-control-sm ingredient-field') }}
+
{{ render_field_with_errors(fermentable.form.type, 'ingredient-field custom-select-sm', base_class='custom-select') }}
{{ render_field_with_errors(fermentable.form.amount, 'form-control-sm ingredient-field') }}
{{ render_field_with_errors(fermentable.form.ppg, 'form-control-sm ingredient-field') }}
{{ render_field_with_errors(fermentable.form.color, 'form-control-sm ingredient-field') }}
@@ -77,7 +90,7 @@
-
{{ render_field_with_errors(hop.form.use, 'form-control-sm ingredient-field') }}
+
{{ render_field_with_errors(hop.form.use, 'ingredient-field custom-select-sm', base_class='custom-select') }}
{{ render_field_with_errors(hop.form.alpha, 'form-control-sm ingredient-field') }}
{{ render_field_with_errors(hop.form.duration, 'form-control-sm ingredient-field') }}
{{ render_field_with_errors(hop.form.amount, 'form-control-sm ingredient-field') }}
@@ -103,14 +116,14 @@