o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1378730139.9192572: @value"²{I" class:ETI"ProcessedAsset;FI"logical_path;TI"$web_console/console_sessions.js;FI" pathname;TI"h/Users/genadi/Development/web-console-rails3/app/assets/javascripts/web_console/console_sessions.js;FI"content_type;TI"application/javascript;TI" mtime;TI"2013-09-09T12:24:50+03:00;TI" length;TièI" digest;TI"%feff22122a93f978178c73f1f444f314;FI" source;TI"è var AJAXTransport = (function(WebConsole) { var inherits = WebConsole.inherits; var EventEmitter = WebConsole.EventEmitter; // Use an IE friendly implementation of XMLHttpRequest. XHR = (function() { try { return XMLHttpRequest; } catch (e) { return function() { return new ActiveXObject('Microsoft.XMLHTTP'); }; } }).call(this); var AJAXTransport = function(options) { EventEmitter.call(this); options || (options = {}); this.url = (typeof options.url === 'string') ? { input: options.url, pendingOutput: options.url, configuration: options.url } : options.url; this.pendingInput = ''; this.on('input', this.sendInput); this.on('configuration', this.sendConfiguration); this.once('initialization', function(cols, rows) { this.emit('configuration', cols, rows); this.pollForPendingOutput(); }); }; inherits(AJAXTransport, EventEmitter); // Shorthand for creating XHR requests. AJAXTransport.prototype.createRequest = function(method, url, options) { options || (options = {}); var request = new XHR(); request.open(method, url); if (typeof options.form === 'object') { var content = [], form = options.form; for (var key in form) { var value = form[key]; content.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); } var formMimeType = 'application/x-www-form-urlencoded; charset=utf-8'; request.setRequestHeader('Content-Type', formMimeType); request.data = content.join('&'); } return request; }; AJAXTransport.prototype.pollForPendingOutput = function() { var request = this.createRequest('GET', this.url.pendingOutput); var self = this; request.onreadystatechange = function() { if (request.readyState === 4) { if (request.status === 200) { self.emit('pendingOutput', request.responseText); self.pollForPendingOutput(); } else { self.emit('disconnect', request); } } }; request.send(null); }; // Send the input to the server. // // Each key press is encoded to an intermediate format, before it is sent to // the server. // // WebConsole#keysPressed is an alias for WebConsole#sendInput. AJAXTransport.prototype.sendInput = function(input) { input || (input = ''); if (this.disconnected) return; if (this.sendingInput) return this.pendingInput += input; // Indicate that we are starting to send input. this.sendingInput = true; var request = this.createRequest('PUT', this.url.input, { form: { input: this.pendingInput + input } }); // Clear the pending input. this.pendingInput = ''; var self = this; request.onreadystatechange = function() { if (request.readyState === 4) { self.sendingInput = false; if (self.pendingInput) self.sendInput(); } }; request.send(request.data); }; // Send the terminal configuration to the server. // // Right now by configuration, we understand the terminal widht and terminal // height. // // WebConsole#resized is an alias for WebConsole#sendconfiguration. AJAXTransport.prototype.sendConfiguration = function(cols, rows) { if (this.disconnected) return; var request = this.createRequest('PUT', this.url.configuration, { form: { width: cols, height: rows } }); // Just send the configuration and don't care about any output. request.send(request.data); }; return AJAXTransport; }).call(this, WebConsole); window.addEventListener('load', function() { var geometry = calculateFitScreenGeometry(); config.terminal.cols = geometry[0]; config.terminal.rows = geometry[1]; var terminal = window.terminal = new WebConsole.Terminal(config.terminal); terminal.on('data', function(data) { transport.emit('input', data); }); var transport = new AJAXTransport(config.transport); transport.on('pendingOutput', function(response) { var json = JSON.parse(response); if (json.output) terminal.write(json.output); }); transport.on('disconnect', function() { terminal.destroy(); }); transport.emit('initialization', terminal.cols, terminal.rows); // Utilities // --------- function calculateFitScreenGeometry() { // Currently, resizing term.js is broken. E.g. opening vi causes it to go // back to 80x24 and fail with off-by-one error. Other stuff, like chip8 // are rendered incorrectly and so on. // // To work around it, create a temporary terminal, just so we can get the // best dimensions for the screen. var temporary = new WebConsole.Terminal; try { return temporary.fitScreen(); } finally { temporary.destroy(); } } }); ;TI"dependency_digest;TI"%026c3784a3a43cb3706f191711d2b690;FI"required_paths;T[ I"S/Users/genadi/Development/web-console-rails3/vendor/assets/javascripts/term.js;FI"W/Users/genadi/Development/web-console-rails3/lib/assets/javascripts/web_console.js;FI"W/Users/genadi/Development/web-console-rails3/lib/assets/javascripts/web-console.js;FI"h/Users/genadi/Development/web-console-rails3/app/assets/javascripts/web_console/console_sessions.js;FI"dependency_paths;T[ {I" path;TI"h/Users/genadi/Development/web-console-rails3/app/assets/javascripts/web_console/console_sessions.js;FI" mtime;TI"2013-09-09T12:24:50+03:00;TI" digest;TI"%b8ecb52911052dcde48bf9a396378c4a;F{I" path;TI"W/Users/genadi/Development/web-console-rails3/lib/assets/javascripts/web-console.js;FI" mtime;TI"2013-09-09T11:33:26+03:00;TI" digest;TI"%30f295e7e74e7a17fcd461908bb96035;F{I" path;TI"W/Users/genadi/Development/web-console-rails3/lib/assets/javascripts/web_console.js;FI" mtime;TI"2013-09-09T12:24:50+03:00;TI" digest;TI"%7b61af1694b088c921df8ea87cbb2f2b;F{I" path;TI"S/Users/genadi/Development/web-console-rails3/vendor/assets/javascripts/term.js;FI" mtime;TI"2013-09-09T12:24:50+03:00;TI" digest;TI"%14a3837a5654151931ffb8938a7b00ec;FI" _version;TI"%6776f581a4329e299531e1d52aa59832;F