Weight Calculators
Weight Calculators
Calculate the weight of basic steel shapes.
.fwsWidget .help-block {
position: relative;
top: 0;
}
(function($){
var rectWidget = {},
ringWidget = {};
// Widget object
function Widget(options){
$.extend(this,options);
this.el = this.el || {};
this.calculate = this.calculate || function(){return '';};
return this;
}
Widget.prototype = {
steelDensity : .2836,
errorClass : 'has-error',
helpBlock : '.help-block',
// Make error message
errorMessage : function(msg){
return '
'+msg+'';
},
// Display validation error message
showMessage : function($el, text){
$el.after(this.errorMessage(text)).parent().addClass(this.errorClass);
},
// Remove validation error message
removeMessage : function($el){
$el.parent().removeClass(this.errorClass).find(this.helpBlock).remove();
},
// Validate entered numbers
validateInput : function($el){
var n = $el.val();
// Must be a non-negative decimal number
if(n.length > 0 && !isNaN(parseFloat(n)) && isFinite(n) && n >= 0){
this.removeMessage($el);
}
else if (n.length !== 0) {
this.showMessage($el,'Please enter decimal numbers');
}
return this;
}
};
// Define rectangle widget
rectWidget = new Widget({
el : {
$rQuantity : $('#rectQuantity'),
$rWidth : $('#rectWidth'),
$rLength : $('#rectLength'),
$rThickness : $('#rectThickness'),
$rlb : $('#rectPounds')
},
calculate : function(){
var lb = (this.el.$rQuantity.val() * this.el.$rWidth.val() * this.el.$rLength.val() * this.el.$rThickness.val() * this.steelDensity).toFixed(4);
lb = (isNaN(lb) || lb < 0) ? '' : lb;
this.el.$rlb.val(lb);
}
});
// Bind rectangle widget
$('#calcRectWeight .form-control').on('change', function(){
rectWidget.validateInput($(this)).calculate();
});
// Define ring widget
ringWidget = new Widget({
el : {
$odQuantity : $('#odQuantity'),
$odOutside : $('#odOutside'),
$odInside : $('#odInside'),
$odThickness : $('#odThickness'),
$odlb : $('#odPounds')
},
calculate : function(){
var od = Math.pow(this.el.$odOutside.val() / 2, 2) * Math.PI,
id = Math.pow(this.el.$odInside.val() / 2, 2) * Math.PI,
lb = (this.el.$odQuantity.val() * (od - id) * this.el.$odThickness.val() * this.steelDensity).toFixed(4);
lb = (isNaN(lb) || lb < 0) ? '' : lb;
this.el.$odlb.val(lb);
}
});
// Bind ring widget
$('#calcODWeight .form-control').on('change', function(){
ringWidget.validateInput($(this)).calculate();
});
})(jQuery);
The information presented here is intended for quick reference only.
Contact Us
We would love to speak with you.