diff --git a/owe.js b/owe.js index 9d2712f..e335b24 100644 --- a/owe.js +++ b/owe.js @@ -31,11 +31,14 @@ function loadSentences(alertIfNew = false, increaseUnread = true) { // color var spans = document.querySelector(".sentences").getElementsByTagName("span"); - // we expect this to be from the user who's turn it is now - var histurnspan = spans[spans.length - config_data.users.length]; - //console.log(histurnspan.getAttribute("style")); - document.getElementById("wordinput").setAttribute("style", histurnspan.getAttribute("style")); + if (spans.length >= config_data.users.length) { + var histurnspan = spans[spans.length - config_data.users.length]; + //console.log(histurnspan.getAttribute("style")); + document.getElementById("wordinput").setAttribute("style", histurnspan.getAttribute("style")); + } else { + console.error('Not enough spans available for users.'); + } initializeLoginArea(); }); });