diff --git a/web/duell.html b/web/duell.html index 8ceb97b..0b702cc 100644 --- a/web/duell.html +++ b/web/duell.html @@ -32,11 +32,15 @@
Fragenliste: diff --git a/web/js/main.js b/web/js/main.js index 38bddbd..e49e990 100644 --- a/web/js/main.js +++ b/web/js/main.js @@ -23,6 +23,16 @@ $(document).ready(function() { wsSend("toggleBlackScreen", ""); }); + $("#modeFinal").change(function() { + var status = $('#modeFinal').is(':checked'); + wsSend("toggleFinalMode", status); + }); + + $("#player2").change(function() { + var player = $('#player2').is(':checked'); + wsSend("setPlayer2ForFinalMode", player); + }); + $("#startJeopardybtn").click(function() { $("#startJeopardybtn").attr("disabled", "disabled"); wsSend("startJeopardy", ""); @@ -130,9 +140,18 @@ $(document).ready(function() { }); +function setFinalMode(status){ + isFinalMode = status; +} + +function setPlayer2(value){ + player2 = value; +} + function setRunde(value){ runde = value; } + function showQuestionsAsPrint() { var ges = ' Familienduell Fragen
'+(i+1)+'. '+
- ''+
- ''+
- '');
- if(display) {
- oneLine.find(".answer").text("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");
+ if (!isFinalMode) {
+ var oneLine = $('' +
+ ' ');
+ } else {
+ var oneLine = $('' + (i + 1) + '. ' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' ');
+ }
+ if(display && !player2) {
+ if (isFinalMode) {
+ oneLine.find(".answer").text("_ _ _ _ _ _ _ _ _ _");
+ } else {
+ oneLine.find(".answer").text("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");
+ }
oneLine.find(".points").text("--");
- } else {
+ if (isFinalMode){
+ oneLine.find(".points_player2").text("--");
+ oneLine.find(".answer_player2").text("_ _ _ _ _ _ _ _ _ _");
+ }
+ } else if (!display) {
oneLine.find(".answer").html(''+getAnswerString(fragen[index]["antworten"][i]["antwort"])+'');
oneLine.find(".points").html(''+fragen[index]["antworten"][i]["anz"]+'');
(function() {
@@ -283,13 +340,27 @@ function loadQuestionToGui(index) {
}
}
}
- $("#SumRes").text("0");
- recalcSum(0);
+ if (!isFinalMode) {
+ $("#SumRes").text("0");
+ }
+ if (isFinalMode){
+ if (!player2) {
+ $('#SumRes_player1').html("0");
+ $('#SumRes_player2').html("0");
+ }
+ }
+ if (!player2) {
+ recalcSum(0);
+ }
}
function setAnswer(index, answer) {
+ var answer_select = ".answer";
+ if (player2){
+ answer_select = '.answer_player2';
+ }
answer = getAnswerString(answer);
- var el = $($("#answers").find(".answer")[index]);
+ var el = $($("#answers").find(answer_select)[index]);
el.empty();
if(sounds && (display || serverSound)) {
audio = new Audio('./sounds/textRichtig.mp3');
@@ -302,7 +373,11 @@ function setAnswer(index, answer) {
}
function setAnz(index, nr) {
- var el = $($("#answers").find(".points")[index]);
+ var points_select = ".points";
+ if (player2){
+ points_select = '.points_player2';
+ }
+ var el = $($("#answers").find(points_select)[index]);
el.text(nr);
if(sounds && (display || serverSound)) {
audio = new Audio('./sounds/zahlRichtig.mp3');
@@ -312,7 +387,15 @@ function setAnz(index, nr) {
}
function recalcSum(s) {
- $("#SumRes").text(parseFloat($("#SumRes").text())+parseFloat(s));
+ var sum_selector = '#SumRes';
+ if (isFinalMode) {
+ if (player2) {
+ sum_selector = '#SumRes_player2';
+ } else {
+ sum_selector = '#SumRes_player1';
+ }
+ }
+ $(sum_selector).text(parseFloat($(sum_selector).text())+parseFloat(s));
}
function getAnswerString(str) {
@@ -321,7 +404,11 @@ function getAnswerString(str) {
str+="_";
}
anz = str.length;
- while(str.length < 40) {
+ var maxLength = 40;
+ if (isFinalMode){
+ maxLength = 20;
+ }
+ while(str.length < maxLength) {
str+= " _";
}
return str;
diff --git a/web/js/websocket.js b/web/js/websocket.js
index e749067..822e999 100644
--- a/web/js/websocket.js
+++ b/web/js/websocket.js
@@ -15,6 +15,9 @@ var ws;
var display = true;
var audio = null;
var serverSound = false;
+var isFinalMode = false;
+var player2 = false;
+var runde = 1;
$(document).ready(function() {
$("#displayBtn").click(function() {
@@ -161,7 +164,16 @@ var connectWs = function() {
if(display) {
$("#blackScreen").toggle();
}
+ } else if (key == "toggleFinalMode"){
+ setFinalMode(value);
}
+ else if (key == "setPlayer2ForFinalMode"){
+ setPlayer2(value);
+ }
+ else if (key == "setRunde"){
+ console.log('Set Runde to ' + value);
+ setRunde(value);
+ }
}
}
diff --git a/web/sounds/failfinal.mp3 b/web/sounds/failfinal.mp3
new file mode 100755
index 0000000..6d81893
Binary files /dev/null and b/web/sounds/failfinal.mp3 differ
|