if(!jQuery) { document.write(unescape('%3Cscript src="' + 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js' + '" type="text/javascript"%3E%3C/script%3E')); } /*! * Watts Radiant API Gateway * http://wattsradiant.com/api * * Copyright 2010 Watts Radiant, Inc. * All Rights Reserved. * * Requirements: * jQuery Javascript Library * http://jquery.com * * Date: Wed Dec 13 06:13:16 EST 2017 */ (function($){ $.fn.wrGateway = function(){ // Handle text argument if(typeof arguments[0] === "string"){ switch(arguments[0].toLowerCase()){ default : return this; } } // Extend with options var opts = $.extend({},$.fn.wrGateway.defaults, arguments[0]); // Construct return this.each(function(){ var $this = $(this); var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts; var apiResp; // Setup submit event $this.submit(function(e){ e.stopPropagation(); var $this = $(this); var o = $this.data("options"); o.onSubmit(e); sendData( $this ); return false; }); // Store options for later use $this.data("options", o); }); // Private Method & Properties function sendData($this){ var url = "http://wattsradiant.com/api/do" + generateHash( $this ); $.ajax({ url: url, dataType: "jsonp", success: function(d){ var o = $this.data("options"); apiResp = unescape(d.apiResp) o.success( apiResp ); if( o.transform && o.transform.length != 0 ){ transfromData($this, apiResp); } else { o.onComplete(); } }, error: function(x,s,e) { var o = $this.data("options"); o.error(x,s,e); o.onComplete(); } }); } function transfromData($this, d){ var o = $this.data("options"); $.ajax({ type: "POST", url: o.transform, data: {xml: d}, success: function(d){ var o = $this.data("options"); var onTransform = o.onTransform( d ) || true; if( o.target && o.target.length != 0 && onTransform ){ $( o.target ).html( d ); } o.onComplete(); }, error: function(x,s,e) { var o = $this.data("options"); o.error(x,s,e); o.onComplete(); } }); } function generateHash($this){ var o = $this.data("options"); var params = wrAppData[o.appName].parameters; var strHash = "/269FBE8EF604B59C"; var inputSelector, $input, val, v; for( var p = 0; p < params.length; p++ ){ v = null; inputSelector = "[name=" + params[p] + "]"; $input = $( inputSelector ); val = ( ( $input.is("[type=checkbox],[type=radio]") ) ? $( inputSelector + ":checked" ) : $input.val() ) || ""; if( val.eq && val.length > 0 ){ strHash += "/"; for(var v = 0; v < val.length; v++){ if(v > 0){ strHash += ","; } v = val.eq(v).val() strHash += (v == "") ? "~" : v; } } else if( typeof val != "string" && val.length > 0 ){ strHash += "/"; for(var v = 0; v < val.length; v++){ if(v > 0){ strHash += ","; } v = val[v] strHash += (v == "") ? "~" : v; } } else { v = val; strHash += "/" + ((v.length == 0) ? "~" : v); } } $this.data("hash", strHash); return strHash; } }; // Defaults $.fn.wrGateway.defaults = { target: "", transform: null, success: function(d){}, error: function(x,s,e){}, onSubmit:function(e){}, onComplete:function(){}, onTransform:function(d){} }; })(jQuery); if( !wrAppData ){ var wrAppData = {}; } (wrAppData.ElectricProductCalculator = {} ).parameters = ["heatedArea", "productType", "productVoltage", "productSpacing", "baseSpacing", "floorType", "electricRate", "quoteKits"];