Skip to content

Commit

Permalink
Added public index file
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Mar 1, 2011
1 parent a5cbd3b commit e98bf75
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!doctype html><html>
<head>
<title>Showmetheshell</title>
<link rel="stylesheet" href="/styles.css" type="text/css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.json.min.js"></script>
<script type="text/javascript" src="shell.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var ws = new WebSocket("ws://127.0.0.1:3000");

var shell = new Shell();
shell.onsend = function(message) {
ws.send(message);
};

ws.onerror = function(e) {
$('#disconnect').html('');
$('#container').html('Error: ' + e);
};

ws.onopen = function() {
$('#disconnect').html('<a href="#">Disconnect</a>');
$('#disconnect > a').click(function() { ws.close(); return false; });

$('#container').html('Connected. Initializing...');

shell.init();
};

ws.onmessage = function(e) {
var data = $.evalJSON(e.data);

if (data.type == 'history') {
for (var i = 0; i < data.history.length; i++) {
shell.updateRow(i + 1, data.history[i]);
}
}
else if (data.type == 'row') {
shell.updateRow(data.row, data.text);
}
};

ws.onclose = function() {
shell.close();
$('#disconnect').html('');
$('#container').html('Disconnected');
};
});
</script>
<link rel="stylesheet" href="styles.css" type="text/css" />

</head>
<body>
<div id="disconnect"></div>
<div id="container">
Connecting...
</div>
</body>
</html>

0 comments on commit e98bf75

Please sign in to comment.