Plugin Directory

Changeset 759516


Ignore:
Timestamp:
08/20/2013 08:24:56 PM (13 years ago)
Author:
wingdspur
Message:

Added grain sorghum harvest yield loss calculator

Location:
farm-calculators/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • farm-calculators/trunk/css/calculators.css

    r758858 r759516  
    66  font-size: 18px;
    77}
     8
     9.farmCalculator legend {
     10  font-size: 18px;
     11}
  • farm-calculators/trunk/farm-calculators.php

    r758858 r759516  
    33Plugin Name: Farm Calculators
    44
    5 Plugin URI: http://github.com/wingdspur/farm-calculators
     5Plugin URI: http://wordpress.org/plugins/farm-calculators/
    66
    77Description: Add farm calculators to your website to help users determine various farming and crop related information.
    88
    9 Version: 0.1
     9Version: 0.2
    1010Author: Bryce Johnston
    1111Author URI: http://www.wingdspur.com
     
    2828*******************************************************************************************/
    2929
    30 $fc_version = '0.1';
     30$fc_version = '0.2';
    3131$fc_dirname = plugin_basename(dirname(__FILE__));
    3232
     
    8282}
    8383
     84function farming_calc_crop_population_bs_shortcode() {
     85   extract( shortcode_atts( array(
     86      'class' => 'farmCalculator span3',
     87      ), $atts ) );
     88
     89$class = esc_attr($class);
     90
     91$code = '<div class="'.$class.'">
     92<form>
     93<div class="errors"></div>';
     94$code .='<fieldset>
     95<legend>Crop Population</legend>';
     96$code .='
     97  <label for="stand_count">Stand Count:</label>
     98  <input name="stand_count" id="stand_count" type="number" step="any" class="input-medium" />
     99  <label for="row_length">Length of Row in Feet:</label>
     100  <input name="row_length" id="row_length" type="number" step="any" class="input-medium" />
     101  <label for="row_spacing">Row Spacing in Inches:</label>
     102  <input name="row_spacing" id="row_spacing" type="number" step="any" class="input-medium" /><br />
     103  <button type="submit" class="btn" name="calculateCropPopulation" id="calculateCropPopulation">Calculate</button>
     104</fieldset>';
     105$code .= '<br />
     106  <label>Population (Plants/Acre):</label>
     107  <input name="crop_population" type="text" class="input-medium" readonly="readonly" />
     108</form>';
     109$code .= '
     110</div>';
     111
     112   return $code;
     113}
     114
    84115function farming_calc_crop_population_hoop_shortcode() {
    85116   extract( shortcode_atts( array(
     
    116147}
    117148
     149function farming_calc_crop_population_hoop_bs_shortcode() {
     150   extract( shortcode_atts( array(
     151      'class' => 'farmCalculator span3',
     152      ), $atts ) );
     153
     154$class = esc_attr($class);
     155
     156$code = '<div class="'.$class.'">
     157<form>
     158<div class="errors"></div>';
     159$code .='<fieldset>
     160<legend>Crop Population (Hoop)</legend>';
     161$code .='
     162  <label for="stand_count">Stand Count:</label>
     163  <input name="stand_count" id="stand_count" type="number" step="any" class="input-medium" />
     164  <label for="hoop_size">Hoop Size in Inches:</label>
     165  <input name="hoop_size" id="hoop_size" type="number" step="any" class="input-medium" /><br />
     166  <button type="submit" class="btn" name="calculateCropPopulationHoop" id="calculateCropPopulationHoop">Calculate</button>
     167</fieldset>';
     168$code .= '<br />
     169  <label>Population (Plants/Acre):</label>
     170  <input name="crop_population" type="text" class="input-medium" readonly="readonly" />
     171</form>';
     172$code .= '
     173</div>';
     174
     175   return $code;
     176}
     177
     178function farming_calc_sorghum_harvest_yield_loss_shortcode() {
     179   extract( shortcode_atts( array(
     180      'class' => 'farmCalculator',
     181      ), $atts ) );
     182
     183$class = esc_attr($class);
     184
     185$code = '<div class="'.$class.'">
     186<form>
     187<div class="errors"></div>';
     188$code .='
     189  <h4>Grain Sorghum Harvest Loss</h4>
     190  <p><i>Also recommended to check standing crop for pre-harvest losses.</i></p>
     191  <p>
     192    <label for="kernals_count">Kernals Counted on Ground:</label><br />
     193    <input name="kernals_count" id="kernals_count" type="number" step="any" class="input-medium" />
     194  </p>
     195  <p>
     196    <label for="kernals_area">Area Kernals were Counted (ft<sup>2</sup>):</label><br />
     197    <input name="kernals_area" id="kernals_area" type="number" step="any" class="input-medium" />
     198  </p>
     199  <p>
     200    <button type="submit" class="btn" name="calculateSorghumHarvestYieldLoss" id="calculateSorghumHarvestYieldLoss">Calculate</button>
     201  </p>
     202  <p>
     203    <label>Estimated Yield Loss (bu/ac):</label><br />
     204    <input name="yield_loss" type="text" class="input-medium" readonly="readonly" />
     205  </p>
     206</form>';
     207$code .= '
     208</div>';
     209
     210   return $code;
     211}
     212
     213function farming_calc_sorghum_harvest_yield_loss_bs_shortcode() {
     214   extract( shortcode_atts( array(
     215      'class' => 'farmCalculator',
     216      ), $atts ) );
     217
     218$class = esc_attr($class);
     219
     220$code = '<div class="'.$class.'">
     221<form>
     222<div class="errors"></div>';
     223$code .='<fieldset>
     224<legend>Grain Sorghum Harvest Loss</legend>';
     225$code .='
     226  <label for="kernals_count">Kernals Counted on Ground:</label>
     227  <input name="kernals_count" id="kernals_count" type="number" step="any" class="input-medium" />
     228  <label for="kernals_area">Area Kernals were Counted (ft<sup>2</sup>):</label>
     229  <input name="kernals_area" id="kernals_area" type="number" step="any" class="input-medium" /><br />
     230  <button type="submit" class="btn" name="ccalculateSorghumHarvestYieldLoss" id="calculateSorghumHarvestYieldLoss">Calculate</button>
     231</fieldset>';
     232$code .= '<br />
     233  <label>Estimated Yield Loss (bu/ac):</label>
     234  <input name="yield_loss" type="text" class="input-medium" readonly="readonly" />
     235</form>';
     236$code .= '
     237</div>';
     238
     239   return $code;
     240}
     241
    118242add_shortcode('farming_calc_crop_population', 'farming_calc_crop_population_shortcode');
     243add_shortcode('farming_calc_crop_population_bs', 'farming_calc_crop_population_bs_shortcode');
    119244add_shortcode('farming_calc_crop_population_hoop', 'farming_calc_crop_population_hoop_shortcode');
     245add_shortcode('farming_calc_crop_population_hoop_bs', 'farming_calc_crop_population_hoop_bs_shortcode');
     246add_shortcode('farming_calc_sorghum_harvest_yield_loss', 'farming_calc_sorghum_harvest_yield_loss_shortcode');
     247add_shortcode('farming_calc_sorghum_harvest_yield_loss_bs', 'farming_calc_sorghum_harvest_yield_loss_bs_shortcode');
    120248
    121249?>
  • farm-calculators/trunk/js/calculators.js

    r758858 r759516  
    88  $("#calculateCropPopulationHoop").bind('click submit', function() {
    99    calculateCropPopulationHoop(this.form);
     10    return false;
     11  });
     12
     13  $("#calculateSorghumHarvestYieldLoss").bind('click submit', function() {
     14    calculateSorghumHarvestYieldLoss(this.form);
    1015    return false;
    1116  });
     
    2227  function roundHundred(x) {
    2328    return Math.round(x/100)*100;
     29  }
     30
     31  function roundTenth(x) {
     32    return Math.round(x*10)/10;
     33  }
     34
     35  function roundHundredth(x) {
     36    return Math.round(x*100)/100;
    2437  }
    2538 
     
    6275    form.crop_population.value = roundHundred(population);
    6376  }
     77
     78  function calculateSorghumHarvestYieldLoss(form) {
     79    if (!isValid(form.kernals_count, 0, 1000)) { 
     80      return false;
     81    } else if (!isValid(form.kernals_area, 0, 1000)) { 
     82      return false;
     83    }
     84   
     85    var kernals_count = form.kernals_count.value;
     86    var kernals_area = form.kernals_area.value;
     87
     88    var yield_loss = 0;
     89    yield_loss = kernals_count/kernals_area/18.5;
     90
     91    form.yield_loss.value = roundTenth(yield_loss);
     92
     93  }
    6494 
    6595
  • farm-calculators/trunk/readme.md

    r758858 r759516  
    44Requires at least: 3.5 
    55Tested up to: 3.6 
    6 Stable tag: 0.1 
     6Stable tag: 0.2 
    77Tags: farm, crop, farming, calculator, yield, population, agriculture 
    88License: GPLv3 or later 
     
    2121Shows a calculator for determing crop population based on stand count, row length, and row spacing. 
    2222
     23    [farming_calc_crop_population_bs]
     24Same as above but styled for bootstrap themes. 
     25
    2326    [farming_calc_crop_population_hoop]
    2427Shows a calculator for determing crop population based on stand count and hoop size. 
     28
     29    [farming_calc_crop_population_hoop_bs]
     30Same as above but styled for bootstrap themes. 
     31
     32    [farming_calc_sorghum_harvest_yield_loss]
     33Shows a calculator for determing grain sorghum harvest yield loss based on kernels counted on ground and the size of the area they were counted in. 
     34
     35    [farming_calc_sorghum_harvest_yield_loss_bs]
     36Same as above but styled for bootstrap themes. 
    2537
    2638More shortcodes will follow soon.
     
    4254## Changelog 
    4355
     56### 0.2 
     57* Added grain sorghum harvest yield loss calculator.   
     58* Added bootstrap styled alternative shortcodes.   
     59
    4460### 0.1 
    4561* First public version. 
  • farm-calculators/trunk/readme.txt

    r758858 r759516  
    44Requires at least: 3.5 
    55Tested up to: 3.6 
    6 Stable tag: 0.1 
     6Stable tag: 0.2 
    77Tags: farm, crop, farming, calculator, yield, population, agriculture 
    88License: GPLv3 or later 
     
    2121Shows a calculator for determing crop population based on stand count, row length, and row spacing. 
    2222
     23    [farming_calc_crop_population_bs]
     24Same as above but styled for bootstrap themes. 
     25
    2326    [farming_calc_crop_population_hoop]
    2427Shows a calculator for determing crop population based on stand count and hoop size. 
     28
     29    [farming_calc_crop_population_hoop_bs]
     30Same as above but styled for bootstrap themes. 
     31
     32    [farming_calc_sorghum_harvest_yield_loss]
     33Shows a calculator for determing grain sorghum harvest yield loss based on kernels counted on ground and the size of the area they were counted in. 
     34
     35    [farming_calc_sorghum_harvest_yield_loss_bs]
     36Same as above but styled for bootstrap themes. 
    2537
    2638More shortcodes will follow soon.
     
    4254== Changelog == 
    4355
     56= 0.2 = 
     57* Added grain sorghum harvest yield loss calculator.   
     58* Added bootstrap styled alternative shortcodes.   
     59
    4460= 0.1 = 
    4561* First public version. 
Note: See TracChangeset for help on using the changeset viewer.