From 6bad86730e9f5bec186e6312451d5c9bbf7118ae Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Thu, 27 Aug 2015 21:43:09 -0700 Subject: [PATCH] List available games on front page --- ui/index.html | 5 ++++- ui/js/botui.js | 56 +++++++------------------------------------------- 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/ui/index.html b/ui/index.html index 64a1481..1187843 100644 --- a/ui/index.html +++ b/ui/index.html @@ -19,7 +19,10 @@ -
+
+ +
diff --git a/ui/js/botui.js b/ui/js/botui.js index 46c914a..12eff9f 100644 --- a/ui/js/botui.js +++ b/ui/js/botui.js @@ -3,58 +3,16 @@ $(function(){ if($("#error > div").text() != "") { $("#error").show(); } - loadServers(); loadGames(); }); -function loadServers() { - $.get("/ui/servers", function(data) { - $("#server-list").append(data); - $(".start").click(function(e) { - $("#error").hide(); - data = { - 'server': $(this).attr("value"), - } - $.post( - "/api/v1/game/add/", - JSON.stringify(data), - function(data) { - if (data.ok) { - loadGames(); - } else { - $("#error").text(data.error); - $("#error").show(); - } - } - ); - - }); - }); -} - function loadGames() { - $.get("/ui/games", function(data) { - $("#game-list").empty(); - $("#game-list").append(data); - $(".stop").click(function(e) { - $("#error").hide(); - data = { - 'name': $(this).attr("server"), - 'game_id': $(this).attr("value"), - } - $.post( - "/api/v1/game/stop/", - JSON.stringify(data), - function(data) { - if (data.ok) { - loadGames(); - } else { - $("#error").text(data.error); - $("#error").show(); - } - } - ); - - }); + $.get("/api/v0/game/list/", function(data) { + $("#games").empty(); + for (var key in data) { + var name = data[key]["id"]; + var s = "
  • join " + name + "
  • "; + $("#games").append(s); + } }); }