change sum function so you can give team points for each question

This commit is contained in:
rofl256 2016-11-19 09:18:11 +01:00
parent 8a00a6be0e
commit 5d82197fa9

View File

@ -108,11 +108,13 @@ $(document).ready(function() {
$("#pointsToTheLeft").click(function() { $("#pointsToTheLeft").click(function() {
var points = parseFloat($(".pointsLeft").text()) + parseFloat($("#SumRes").text()); var points = parseFloat($(".pointsLeft").text()) + parseFloat($("#SumRes").text());
wsSend("setLeftPoints", points); wsSend("setLeftPoints", points);
$("#SumRes").text("0");
}); });
$("#pointsToTheRight").click(function() { $("#pointsToTheRight").click(function() {
var points = parseFloat($(".pointsRight").text()) + parseFloat($("#SumRes").text()); var points = parseFloat($(".pointsRight").text()) + parseFloat($("#SumRes").text());
wsSend("setRightPoints", points); wsSend("setRightPoints", points);
$("#SumRes").text("0");
}); });
$("#newLeftPoints").click(function() { $("#newLeftPoints").click(function() {
@ -263,7 +265,8 @@ function loadQuestionToGui(index) {
} }
} }
} }
recalcSum(); $("#SumRes").text("0");
recalcSum(0);
} }
function setAnswer(index, answer) { function setAnswer(index, answer) {
@ -287,18 +290,11 @@ function setAnz(index, nr) {
audio = new Audio('./sounds/zahlRichtig.mp3'); audio = new Audio('./sounds/zahlRichtig.mp3');
audio.play(); audio.play();
} }
recalcSum(); recalcSum(nr);
} }
function recalcSum() { function recalcSum(s) {
var summe = 0; $("#SumRes").text(parseFloat($("#SumRes").text())+parseFloat(s));
$.each($(".points"), function() {
var val = $(this).text();
if(val != "--" && val != "" && $(this).find("span").length < 1) {
summe+=parseInt(val);
}
});
$("#SumRes").text(summe);
} }
function getAnswerString(str) { function getAnswerString(str) {