Permalink
Browse files

nearly got it working well, just need to finish a few more things

  • Loading branch information...
1 parent 0ad6837 commit 8a9cf325a9fabd6deedc277d06642036dac18de7 @matthewfl committed Aug 1, 2011
Showing with 23 additions and 13 deletions.
  1. +4 −3 Bespin/control.js
  2. +6 −7 devel/HostRedirProxy.py
  3. +12 −2 static/live_console.html
  4. +1 −1 test.js
View
@@ -324,11 +324,11 @@ exports.saveCommand = function (args, request) {
fileList.push(loadFile);
};
-//var console_win;
+var console_win;
exports.testCommand = function (args, request) {
// this seems to work with better with popup blockers
- var win = window.open("", "DEMO");
+ var win = window.open("",""); // we want to get a new window that will grab the focus
if(typeof console_win == "undefined" || console_win.closed)
console_win = window.open("http://console.test.jsapp.us:7654", "CONSOLE", "status=0,toolbar=0,location=0,menubar=0,directories=0,width=275,height=500,scrollbars=1");
Ajax.Call({
@@ -338,11 +338,12 @@ exports.testCommand = function (args, request) {
"fileName": loadFile
}, function (p) {
win.location.href=p;
+ win.focus();
try {
setTimeout(function () {
console_win.location.hash=p;
}, 500);
- }catch(e) {alert(e)}
+ }catch(e) {}
});
Ajax.send();
track("test");
View
@@ -31,14 +31,13 @@ def handle(self):
self.__base_handle()
def _connect_to(self, netloc, soc):
- if netloc.find("jsapp.us") != -1 or netloc.find("google-analytics.com") != -1 or netloc.find(".matthewfl.com") != -1:
- host_port = "localhost", 80
+ i = netloc.find(':')
+ if i >= 0:
+ host_port = netloc[:i], int(netloc[i+1:])
else:
- i = netloc.find(':')
- if i >= 0:
- host_port = netloc[:i], int(netloc[i+1:])
- else:
- host_port = netloc, 80
+ host_port = netloc, 80
+ if netloc.find("jsapp.us") != -1 or netloc.find("google-analytics.com") != -1 or netloc.find(".matthewfl.com") != -1:
+ host_port = "localhost", host_port[1]
print "\t" "connect to %s:%d" % host_port
try: soc.connect(host_port)
except socket.error, arg:
View
@@ -3,16 +3,19 @@
<title>Live console</title>
<script src="/socket.io/socket.io.js"></script>
<script>
+var doScroll=true, ScrolledTriggered=false;
+window.onscroll=function (e) { if(ScrolledTriggered) ScrolledTriggered=false; else doScroll=false; };
var hostSet=0;
var socket = io.connect('http://'+location.host);
socket.on('message', function (data) {
-clearInterval(hostSet);
document.body.innerHTML += data;
+if(data.indexOf("Connected to") != -1) clearInterval(hostSet);
+if(doScroll) {window.scrollBy(0, 250); ScrolledTriggered=true;}
});
function setHost () {
host = location.hash.substring(location.hash.indexOf("//")+2);
document.title = "Live console for "+host;
-// even sending this once the connect event fired, worked maybe 10% of the time
+// even sending this once the connect event fired, worked maybe 10% of the time, so idk what is wrong with socket io
clearInterval(hostSet);
hostSet = setInterval(function () {
socket.send(host);
@@ -26,6 +29,13 @@
}
}, 200);
</script>
+ <style>
+ body {
+ width: 95%;
+ overflow: auto;
+ font: monospace;
+ }
+ </style>
</head>
<body>
</body>
View
@@ -114,7 +114,7 @@ io.sockets.on('connection', function (socket) {
LogEmitter.on(host, log_send);
socket.send("Connected to: "+data+"<br>");
});
- socket.send("Connected to console");
+ socket.send("Loading Connection...<br>");
});
server.listen(config.testPort);

0 comments on commit 8a9cf32

Please sign in to comment.