Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
nearly got it working well, just need to finish a few more things
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfl committed Aug 1, 2011
1 parent 0ad6837 commit 8a9cf32
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
7 changes: 4 additions & 3 deletions Bespin/control.js
Expand Up @@ -324,11 +324,11 @@ exports.saveCommand = function (args, request) {
fileList.push(loadFile); fileList.push(loadFile);
}; };


//var console_win; var console_win;


exports.testCommand = function (args, request) { exports.testCommand = function (args, request) {
// this seems to work with better with popup blockers // 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) 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"); 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({ Ajax.Call({
Expand All @@ -338,11 +338,12 @@ exports.testCommand = function (args, request) {
"fileName": loadFile "fileName": loadFile
}, function (p) { }, function (p) {
win.location.href=p; win.location.href=p;
win.focus();
try { try {
setTimeout(function () { setTimeout(function () {
console_win.location.hash=p; console_win.location.hash=p;
}, 500); }, 500);
}catch(e) {alert(e)} }catch(e) {}
}); });
Ajax.send(); Ajax.send();
track("test"); track("test");
Expand Down
13 changes: 6 additions & 7 deletions devel/HostRedirProxy.py
Expand Up @@ -31,14 +31,13 @@ def handle(self):
self.__base_handle() self.__base_handle()


def _connect_to(self, netloc, soc): 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: i = netloc.find(':')
host_port = "localhost", 80 if i >= 0:
host_port = netloc[:i], int(netloc[i+1:])
else: else:
i = netloc.find(':') host_port = netloc, 80
if i >= 0: if netloc.find("jsapp.us") != -1 or netloc.find("google-analytics.com") != -1 or netloc.find(".matthewfl.com") != -1:
host_port = netloc[:i], int(netloc[i+1:]) host_port = "localhost", host_port[1]
else:
host_port = netloc, 80
print "\t" "connect to %s:%d" % host_port print "\t" "connect to %s:%d" % host_port
try: soc.connect(host_port) try: soc.connect(host_port)
except socket.error, arg: except socket.error, arg:
Expand Down
14 changes: 12 additions & 2 deletions static/live_console.html
Expand Up @@ -3,16 +3,19 @@
<title>Live console</title> <title>Live console</title>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script> <script>
var doScroll=true, ScrolledTriggered=false;
window.onscroll=function (e) { if(ScrolledTriggered) ScrolledTriggered=false; else doScroll=false; };
var hostSet=0; var hostSet=0;
var socket = io.connect('http://'+location.host); var socket = io.connect('http://'+location.host);
socket.on('message', function (data) { socket.on('message', function (data) {
clearInterval(hostSet);
document.body.innerHTML += data; document.body.innerHTML += data;
if(data.indexOf("Connected to") != -1) clearInterval(hostSet);
if(doScroll) {window.scrollBy(0, 250); ScrolledTriggered=true;}
}); });
function setHost () { function setHost () {
host = location.hash.substring(location.hash.indexOf("//")+2); host = location.hash.substring(location.hash.indexOf("//")+2);
document.title = "Live console for "+host; 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); clearInterval(hostSet);
hostSet = setInterval(function () { hostSet = setInterval(function () {
socket.send(host); socket.send(host);
Expand All @@ -26,6 +29,13 @@
} }
}, 200); }, 200);
</script> </script>
<style>
body {
width: 95%;
overflow: auto;
font: monospace;
}
</style>
</head> </head>
<body> <body>
</body> </body>
Expand Down
2 changes: 1 addition & 1 deletion test.js
Expand Up @@ -114,7 +114,7 @@ io.sockets.on('connection', function (socket) {
LogEmitter.on(host, log_send); LogEmitter.on(host, log_send);
socket.send("Connected to: "+data+"<br>"); socket.send("Connected to: "+data+"<br>");
}); });
socket.send("Connected to console"); socket.send("Loading Connection...<br>");
}); });


server.listen(config.testPort); server.listen(config.testPort);
Expand Down

0 comments on commit 8a9cf32

Please sign in to comment.