Commit 221dcb77 authored by leo's avatar leo
Browse files

~bugfixes, overviewscreen

parent 317bf4cc
No preview for this file type
......@@ -8,46 +8,34 @@
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.8/socket.io.min.js"></script>
<script>
var states = {"intro": null, "player_select": null, "final_screen": null, "oponents": null, "overview": null};
for(var state in states){
states[state]= document.getElementById(state);
}
function show_state(state){
for(var el in state_elements){
el.style.display = "none";
}
states[state].style.display = "block";
}
var socket = io.connect("ws://localhost:5000");
socket.on("round", function(data){
data = JSON.parse(data)
var round_points = document.getElementsByClass("round_points");
for(var el in round_points){ el.innerHTML = data["points"]; }
var round_points = document.getElementsByClassName("round_points");
for(var el in round_points){ round_points[el].innerHTML = data["points"]; }
var round_points = document.getElementsByClass("question");
for(var el in round_points){ el.innerHTML = data["question"]; }
var question = document.getElementsByClassName("question");
for(var el in question){ question[el].innerHTML = data["question"]; }
var round_points = document.getElementsByClass("points_left");
for(var el in round_points){ el.innerHTML = data["current_team_points"][0]; }
var points_left = document.getElementsByClassName("points_left");
for(var el in points_left){ points_left[el].innerHTML = data["current_team_points"][0]; }
var round_points = document.getElementsByClass("points_right");
for(var el in round_points){ el.innerHTML = data["current_team_points"][1]; }
var points_right = document.getElementsByClassName("points_right");
for(var el in points_right){ points_right[el].innerHTML = data["current_team_points"][1]; }
var round_points = document.getElementsByClass("team_right");
for(var el in round_points){ el.innerHTML = data["current_teams"][1]; }
var team_right = document.getElementsByClassName("team_right");
for(var el in team_right){ team_right[el].innerHTML = data["current_teams"][1]; }
var round_points = document.getElementsByClass("team_left");
for(var el in round_points){ el.innerHTML = data["current_teams"][0]; }
var team_left = document.getElementsByClassName("team_left");
for(var el in team_left){ team_left[el].innerHTML = data["current_teams"][0]; }
var round_points = document.getElementsByClass("logo_left");
for(var el in round_points){ el.src="../"+ data["current_team_logos"][0]; }
var logo_left = document.getElementsByClassName("logo_left");
for(var el in logo_left){ logo_left[el].src="../"+ data["current_team_logos"][0]; }
var round_points = document.getElementsByClass("logo_right");
for(var el in round_points){ el.src="../"+ data["current_team_logos"][1]; }
var logo_right = document.getElementsByClassName("logo_right");
for(var el in logo_right){ logo_right[el].src="../"+ data["current_team_logos"][1]; }
answers_inner_html = ""
for(answer in data["answers"]){
......@@ -70,12 +58,20 @@
fails_right += "X";
}
document.getElementById("fails_left").innerHTML = fails_left;
document.getElementById("fails_right").innerHTML = fails_right;
var fails_l = document.getElementsByClassName("fails_left");
for(var el in fails_l){ fails_l[el].innerHTML = fails_left }
state = data["state"];
var fails_r = document.getElementsByClassName("fails_right");
for(var el in fails_r){ fails_r[el].innerHTML = fails_right }
show_state(state);
for(var id in states){
var el = states[id];
el.style.display = "none";
}
var state = data["state"];
console.log("Switching to state " + state);
states[state].style.display = "block";
});
......@@ -98,6 +94,10 @@
#oponents{
display: none;
}
#overview{
display: none;
}
h1, h2, h3, h4, h5 .h1, .h2, .h3, .h4, .h5{
font-family: PressStart2P;
......@@ -214,7 +214,7 @@
</div>
<div class="col-10">
<table class="table" class="answers">
<table class="table" id="answers">
</table>
</div>
......@@ -250,13 +250,13 @@
</div>
<div class="col-2 ccc-green text-left">
<div class="fails" class="fails_left"></div>
<h1 class="xxl" class="points_left">-</h1>
<div class="fails fails_left"></div>
<h1 class="xxl points_left">-</h1>
</div>
<div class="col-2 ccc-green text-right">
<div class="fails" class="fails_right"></div>
<h1 class="xxl" class="points_right">-</h1>
<div class="fails fails_right"></div>
<h1 class="xxl points_right">-</h1>
</div>
<div class="col-2 text-right">
......@@ -297,10 +297,11 @@
<div class="container-fluid" id="overview">
<div class="row">
<h2 class="team_left"></h2>
<h2 class="team_left col-5 text-center"></h2>
<div class="col-2"></div>
<h2 class="team_right"></h2>
<h2 class="team_right col-5 text-center"></h2>
</div>
<div class="row">
<div class="col-5 text-center">
<img class="logo_left" width="500">
......@@ -312,16 +313,15 @@
<img class="logo_right" width="500">
</div>
</div>
<div class="row">
<div class="col-5 ccc-green text-left">
<div class="fails" class="fails_left"></div>
<h1 class="xxl" class="points_left">-</h1>
<div class="row mb-2">
<div class="col-5 ccc-green text-center">
<h1 class="xxl points_left">-</h1>
</div>
<div class="col-2">
</div>
<div class="col-5 ccc-green text-right">
<div class="fails" class="fails_right"></div>
<h1 class="xxl" class="points_right">-</h1>
<div class="col-5 ccc-green text-center">
<h1 class="xxl points_right">-</h1>
</div>
</div>
</div>
......@@ -330,4 +330,10 @@
</body>
<script>
var states = {"intro": null, "player_select": null, "final_screen": null, "oponents": null, "overview": null};
for(var state in states){
states[state] = document.getElementById(state);
}
</script>
</html>
\ No newline at end of file
......@@ -28,6 +28,7 @@
<div class="btn-group">
<button class="btn btn-light" type="submit" formaction="/fe_intro">Intro</button>
<button class="btn btn-light" type="submit" formaction="/fe_oponents">Gegner</button>
<button class="btn btn-light" type="submit" formaction="/fe_overview">Übersicht</button>
<button class="btn btn-light" type="submit" formaction="/fe_running">Aktuelle Runde</button>
<button class="btn btn-light" type="submit" formaction="/fe_final">Ende</button>
</div>
......
......@@ -12,7 +12,7 @@ def init_websocket(app):
SOCKET = SocketIO(app)
return SOCKET
CURRENT_FRONTEND_VIEW = "intro_screen"
CURRENT_FRONTEND_VIEW = "intro"
def set_current_view(view):
global CURRENT_FRONTEND_VIEW
CURRENT_FRONTEND_VIEW = view
......@@ -39,7 +39,7 @@ def verify_request_data(model, key, value, log_error=True):
return obj
CLEAN_ROUND = {
"state": "intro_screen",
"state": "intro",
"points": 0,
"current_teams":["", ""],
"current_team_logos": ["../static/teamlogos/0_no_logo_00.png", "../static/teamlogos/0_no_logo_00.png"],
......
......@@ -92,7 +92,7 @@ def remove_team():
@mgmt.route("/fe_intro", methods=["POST"])
def fe_intro():
set_current_view(view="intro_screen")
set_current_view(view="intro")
game = verify_request_data(Game, "name", request.form.get("gamename"), log_error=False)
build_current_round_json(game)
return send_reply()
......@@ -116,4 +116,11 @@ def fe_oponents():
set_current_view(view="oponents")
game = verify_request_data(Game, "name", request.form.get("gamename"), log_error=False)
build_current_round_json(game)
return send_reply()
@mgmt.route("/fe_overview", methods=["POST"])
def fe_overview():
set_current_view(view="overview")
game = verify_request_data(Game, "name", request.form.get("gamename"), log_error=False)
build_current_round_json(game)
return send_reply()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment