(function() { var faye = '<%= ::Terminus::FAYE_MOUNT %>', host = '<%= host %>'; var html = document.getElementsByTagName('html')[0], source = '\n' + html.innerHTML + '\n\n'; JSCLASS_PATH = host + '/js.class/'; 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 + '/loader.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') .setup(function() { Faye.Client.prototype.MAX_DELAY = 0 }); this.file(host + '/syn.js') .provides('Syn'); this.file(host + '/terminus.js') .requires('Faye.Client', 'document.evaluate', 'Syn') .provides('Terminus'); }); JS.require('Terminus', function() { Terminus.originalSource = source; Terminus.connect(host + faye); }); }); })();