(function() { var faye = '<%= ::Terminus::FAYE_MOUNT %>', host = '<%= host %>'; var withPackageManager = function(callback) { if (window.JS && JS.Packages) return callback(); var script = document.createElement('script'), head = document.getElementsByTagName('head')[0]; script.type = 'text/javascript'; script.src = host + '/js.packages.js'; script.onload = script.onreadystatechange = function() { var state = script.readyState; if (!state || state === 'loaded' || state === 'complete') { script.onload = script.onreadystatechange = null; head.removeChild(script); callback(); } }; head.appendChild(script); }; withPackageManager(function() { JS.Packages(function() { this.file(host + faye + '/client.js') .provides('Faye', 'Faye.Client'); this.file(host + '/terminus.js') .requires('Faye.Client') .provides('Terminus'); }); require('Terminus', function() { Terminus.connect(host + faye); }); }); })();