vfontjr icon

cutter-travel-calculator-refactor

vfontjr | PRO | 07/14/22 12:59:23 PM UTC | 0 ⭐ | 12421 👁️ | Never ⏰ | []
jQuery |

1.45 KB

|

None

|

0 👍

/

0 👎

<script>
jQuery(document).ready(function( $ ){
    
    $(function() {
        $('.circle, .circle2').hide();
 
        $('#field_wg4s2, #field_d6hwp').on('change', function() {
 
            var $field_wg4s2 = parseFloat($("#field_wg4s2").val()).toFixed(3),
                $field_d6hwp = parseFloat($("#field_d6hwp").val()).toFixed(3),
                $converted = ($field_wg4s2 * 3).toFixed(3),
                $converted_2 = (($field_wg4s2 * 3) - (2*($field_d6hwp * 3))).toFixed(3);
                
            if ($field_d6hwp >= 0.33 * $field_wg4s2) {
                $('#error').text('Wall Thickness invalid').show();
                return false;
            }
                
            console.log($field_wg4s2 , $converted);
            console.log($field_d6hwp, $converted_2);
            
            $('.circle').css({
                height: (2 * $converted),
                width: (2 * $converted),
                top: "calc(50% - " + ($converted) + "px)",
                left: "calc(50% - " + ($converted) + "px)"
            });
            
            $('.circle2').css({
                height: (2 * $converted_2),
                width: (2 * $converted_2),
                top: "calc(50% - " + ($converted_2) + "px)",
                left: "calc(50% - " + ($converted_2) + "px)"
            });
            
            $('.circle, .circle2').fadeIn(300);
            $('#error').hide();
        });
    });
});
</script>

Comments