- message.UI = document.createElement("div");
- var text = (message.Time ? rcformattime(message.Time) : "") + " " + message.Text;
- message.UI.appendChild(document.createTextNode(text));
+ var message_i;
+ if (message.Time) {
+ for (var i = history.length - 1; ; i--) {
+ if (i < 0 || (history[i].Time && message.Time >= history[i].Time)) {
+ message_i = i+1;
+ history.splice(message_i, 0, message);
+ break;
+ }
+ }
+ } else {
+ history.push(message);
+ message_i = history.length-1;
+ }
+
+ if (!message.UI) {
+ var text = (message.Time ? rcformattime(message.Time) : "") + " " + message.Text;
+ message.UI = document.createElement("div");
+ message.UI.appendChild(document.createTextNode(text));
+ }