got self-hosted website working.

This commit is contained in:
sm
2015-08-30 02:16:44 -07:00
parent 6bad869501
commit bb5f76cd97
4 changed files with 5741 additions and 13 deletions
+12 -12
View File
@@ -1,5 +1,5 @@
$(document).ready(function(){
$('#starter,#watch').prop('disabled', 'disabled');
$('#starter').prop('disabled', 'disabled');
$("#error").hide();
editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
@@ -26,21 +26,13 @@ $(document).ready(function(){
$('#starter').click(function() {
$('#tabs a[href="#arena"]').tab('show');
var url = "ws://{{ server.hostname }}:8666/ws/";
gorobots.set_spectator(false);
gorobots.set_server(
url,
"{{ game }}"
);
gorobots.set_server(wsurl(), getGameID());
});
$('#watch').click(function() {
$('#tabs a[href="#arena"]').tab('show');
var url = "ws://{{ server.hostname }}:8666/ws/";
gorobots.set_spectator(true);
gorobots.set_server(
url,
"{{ game }}"
);
gorobots.set_server(wsurl(), getGameID());
});
$('#tabs a[href="#code"]').tab('show');
@@ -60,7 +52,7 @@ function loadCode() {
editor.setValue(e);
$("#editor").show();
$("#fetch-area").hide();
$('#starter,#watch').prop('disabled', function(i, v) { return !v; });
$('#starter').prop('disabled', '');
}).fail(function(e){
var msg = "got a useless error message; is the remote server down?";
if (e.statusText != "error") {
@@ -69,3 +61,11 @@ function loadCode() {
$("#error").text(msg).show();
});
}
function wsurl() {
return "ws://" + window.location.host + "/ws/";
}
function getGameID() {
return window.location.search.split("=")[1];
}