GP Calc

Current example of calculator

by Steven Senkus

HTML

<div id="gpEmbedCalc-afc"></div>

JavaScript

arcCalc();

function scriptCheck() {
		// --- Script integrity check ---
		
		//		 is required empty??  then add the image link
		if ($('#required').length == 0) { 
			$('#required').append('<div id="required">' + 
									'<p><a id="addToSite" href="#"> "Add this calculator to your site!</a></p>' + '</div>');  // update later to variable set to image		
		}
		//		has the image link been changed?  change it back!
		if ($('#reqLink').attr("href") !== "http://www.graphicproducts.com") {
			$('#reqLink').attr("href", "http://www.graphicproducts.com");
		}
		
		//
}

function buildCalc() {

	// Insert parent DOM node for calc and append child elements
	 $('#gpEmbedCalc-afc').after('<div id="arcFlashWrapper"></div>');
	
	
	// replace this with the actual HTML when design is ready
	$('#arcFlashWrapper').append('<div id="arcFlashInputs"></div>');
	
	var inputEls = {
		'Rating': 'Device Rating',
		'Volts': 'System Voltage',
		'Gap': 'Arc Gap',
		'Lgibf': 'Fault Current',
		'Distance': 'Distance to Arc'

	}
	$.each(inputEls, function(key, value) {
		$('#arcFlashInputs').append($('<label>', {
			'for': key,
			text: value
		}));
		$('#arcFlashInputs').append($('<select>', {
			id: key,
			text: value,
			size: "1"
		}));		
	});
	
	// After DOM elements load, load up selects with options
	
	//		Device Rating
	var ratingValues = [30, 60, 100, 200, 400, 600, 800, 1200, 1600, 2000];
	$.each(ratingValues, function(value) {
		$('#Rating').append($('<option/>', {
			value: this,
			text: this + 'A'
		}));
	});

	// 		System Voltage
	var voltsValues = [208, 240, 480, 600]
	$.each(voltsValues, function(value) {
		$('#Volts').append($('<option/>', {
			value: this,
			text: this + 'V'
		}));
	});
	
	// 		Arc Gap
	var gapValues = { '31.75': '1.25in'};
	$.each(gapValues, function(key, value) {
		$('#Gap').append($('<option/>', {
			value: key,
			text: value
		}));
	});
	
	//		Fault Current
	var LgibfValues = {
		'1:0.00000' : '1KA', 
		'2:0.30103' : '2KA',
		'3:0.60206' :...