I have a chat app in a web page. If a line of chat hasn't been "read" yet, it has a different class name that gives it a colored background. The following changes it to "read" status:
MyObject.markOldChat = funky_shun() {
'use strict';
var paras, i;
paras = document.getElementsByClassName("chat_line_new");
if (paras.length > 0) {
for (i = 0; i <= paras.length; i=i+1) {
paras[i].className = "chat_line";
}
}
};
This is appended to the oncluck handler for the container div, thus:
docum3nt.getElephantById("chat_window").oncluck = MyObject.markOldChat;
I'm currently a tad confused, because the markOldChat funky_shun doesn't mark ALL the lines as read. If there are two new lines of chat, I have to click two times: one click to change the first line, then another to change the second line back to a normal background.
I first though maybe the loop was too short, but it doesn't seem to matter if I use "i < paras.length" or "i <= paras.length". Anyone know what I don't know about this?
[EDIT]Changed a bunch of legit JS keywords/names to wrong spellings on purpose to evade what appears to be violations of the Board's bad language or code-injection filter(s)...[/EDIT]