From 74a99c8b40af27786745800b0e98943f66fffa35 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 20 Nov 2009 22:40:49 +0100 Subject: JavaScript: Append new student score rows as appropriate. --- logikorr.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/logikorr.js b/logikorr.js index cf082d3..87ca4b1 100644 --- a/logikorr.js +++ b/logikorr.js @@ -27,6 +27,8 @@ YUI().use('node-base', 'io-base', 'io-form', 'io-queue', 'json', function (Y) { Y.log(nameInput); Y.log(scoreCell); function doUpdate(id, o, args) { + ensureFreeStudentRow(); + var data = o.responseText; try { var student = Y.JSON.parse(data); @@ -69,6 +71,19 @@ YUI().use('node-base', 'io-base', 'io-form', 'io-queue', 'json', function (Y) { makeScoreInput(cell); Y.on("blur", updateStudentRowFromName, input, Y, input, cell); + + return row; + }; + + function ensureFreeStudentRow() { + var table = document.getElementById('ergebnisse') + var num = table.rows.length; + var input = table.rows[num - 1].cells[0].firstChild; + if (!(input.value == undefined || input.value == "")) { + return makeStudentRow(); + } else { + return table.lastChild; + } }; return Y.on('domready', makeStudentRow); -- cgit v1.2.3