lib/termvana/public/js/nirvana.js in termvana-0.2.0.beta2 vs lib/termvana/public/js/nirvana.js in termvana-0.2.0.beta3

- old
+ new

@@ -1,21 +1,29 @@ (function($) { if (!window.WebSocket && !window.MozWebSocket) { alert("This browser does NOT support websockets and thus termvana fail :("); } if(window.WebSocket) var ws = new WebSocket("ws://"+window.location.host+"/socket"); - else if(window.MozWebSocket) var ws = new MozWebSocket("ws://"+window.location.host+"/socket"); + else if(window.MozWebSocket) var ws = new MozWebSocket("ws://"+window.location.host+"/socket"); + ws.onopen = function(e){ + ws.send(JSON.stringify({full_command: "load_environment"})); + } ws.onmessage = function(e) { var data = e.data; data = JSON.parse(data); if (data.type == ("AUTOCOMPLETE")) { var completions = $.parseJSON(data.replace(/^:AUTOCOMPLETE: /, '')); $.readline.finishCompletion(completions); } else { - console.log("Got message of ", data.message, data); - $.repl.logResult(data.message); + if(data.type == "system"){ + if(data['data'] && data['data']['environment']) + $('#current_working_dir').text(data.data.environment.cwd); + } + else{ + $.repl.logResult(data.message); + } } }; ws.onclose = function() { $.repl.disable(); return $.repl.log("<div class='nirvana_exception'>termvana: websocket closed</div>"); @@ -24,7 +32,7 @@ ws.onerror = function() { return $.repl.log("<div class='nirvana_exception'>termvana: websocket error</div>"); }; $.ws = function() { return ws }; - $.ws.nirvanaComplete = function(val) { ws.send(':AUTOCOMPLETE: '+val); }; + $.ws.nirvanaComplete = function(val) { console.log("No auto complete yet") }; })(jQuery);