vtxyzzy

Shortcode for Planetary Weight Calculation

Mar 18th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. // A shortcode function to insert javascript for the
  2. // Planetary Weight Calculation.
  3. function insert_weight_script_func() {
  4.    return <<<EOTEXT
  5. <script type="text/javascript">
  6.    function clearWeights(frm) {
  7.       frm.mercuryWeight.value = ' ';
  8.       frm.venusWeight.value = ' ';
  9.       frm.moonWeight.value = ' ';
  10.       frm.marsWeight.value = ' ';
  11.       frm.jupiterWeight.value = ' ';
  12.       frm.saturnWeight.value = ' ';
  13.       frm.uranusWeight.value = ' ';
  14.       frm.neptuneWeight.value = ' ';
  15.       frm.plutoWeight.value = ' ';
  16.    }
  17.  
  18.    function calcWeights(frm) {
  19.       var weightOnEarth = parseFloat(frm.earthWeight.value);
  20.       frm.mercuryWeight.value = Math.round(weightOnEarth * 0.378 * 100)/100;
  21.       frm.venusWeight.value = Math.round(weightOnEarth * 0.907 * 100)/100;
  22.       frm.moonWeight.value = Math.round(weightOnEarth * 0.166 * 100)/100;
  23.       frm.marsWeight.value = Math.round(weightOnEarth * 0.377 * 100)/100;
  24.       frm.jupiterWeight.value = Math.round(weightOnEarth * 2.364 * 100)/100;
  25.       frm.saturnWeight.value = Math.round(weightOnEarth * 1.064 * 100)/100;
  26.       frm.uranusWeight.value = Math.round(weightOnEarth * 0.889 * 100)/100;
  27.       frm.neptuneWeight.value = Math.round(weightOnEarth * 1.125 * 100)/100;
  28.       frm.plutoWeight.value = Math.round(weightOnEarth * 0.067 * 100)/100;
  29.    }
  30. </script>
  31. EOTEXT;
  32. }
  33. add_shortcode('insert-weight-script','insert_weight_script_func');
Add Comment
Please, Sign In to add comment