Advertisement
vfontjr

cutter-travel-calculator-refactor

Jul 14th, 2022
2,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.45 KB | None | 0 0
  1. <script>
  2. jQuery(document).ready(function( $ ){
  3.    
  4.     $(function() {
  5.         $('.circle, .circle2').hide();
  6.  
  7.         $('#field_wg4s2, #field_d6hwp').on('change', function() {
  8.  
  9.             var $field_wg4s2 = parseFloat($("#field_wg4s2").val()).toFixed(3),
  10.                 $field_d6hwp = parseFloat($("#field_d6hwp").val()).toFixed(3),
  11.                 $converted = ($field_wg4s2 * 3).toFixed(3),
  12.                 $converted_2 = (($field_wg4s2 * 3) - (2*($field_d6hwp * 3))).toFixed(3);
  13.                
  14.             if ($field_d6hwp >= 0.33 * $field_wg4s2) {
  15.                 $('#error').text('Wall Thickness invalid').show();
  16.                 return false;
  17.             }
  18.                
  19.             console.log($field_wg4s2 , $converted);
  20.             console.log($field_d6hwp, $converted_2);
  21.            
  22.             $('.circle').css({
  23.                 height: (2 * $converted),
  24.                 width: (2 * $converted),
  25.                 top: "calc(50% - " + ($converted) + "px)",
  26.                 left: "calc(50% - " + ($converted) + "px)"
  27.             });
  28.            
  29.             $('.circle2').css({
  30.                 height: (2 * $converted_2),
  31.                 width: (2 * $converted_2),
  32.                 top: "calc(50% - " + ($converted_2) + "px)",
  33.                 left: "calc(50% - " + ($converted_2) + "px)"
  34.             });
  35.            
  36.             $('.circle, .circle2').fadeIn(300);
  37.             $('#error').hide();
  38.         });
  39.     });
  40. });
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement