2016-08-05 11:39:31 +00:00
|
|
|
/**
|
|
|
|
* Created by Norbi on 2016-08-05.
|
|
|
|
*/
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2016-08-17 10:48:31 +00:00
|
|
|
conversationChanged();
|
|
|
|
});
|
|
|
|
|
|
|
|
function conversationChanged() {
|
2016-08-05 11:39:31 +00:00
|
|
|
var cmsgs = document.getElementById("channelmessages");
|
2016-08-09 10:12:46 +00:00
|
|
|
if (cmsgs != null && cmsgs.childElementCount > 0) {
|
2016-08-17 10:48:31 +00:00
|
|
|
var nodes = cmsgs.getElementsByClassName("chmessage");
|
2016-08-10 12:05:30 +00:00
|
|
|
for (var x = 0; x < nodes.length; x++) {
|
|
|
|
var item = nodes[x];
|
2016-08-17 10:48:31 +00:00
|
|
|
handlereceivedmessage(item);
|
2016-08-10 12:05:30 +00:00
|
|
|
}
|
2016-08-09 10:12:46 +00:00
|
|
|
}
|
2016-08-17 10:48:31 +00:00
|
|
|
if (document.getElementById("convidp").innerText == "-1") {
|
|
|
|
document.getElementById("msginput").style.display = "none";
|
|
|
|
stopPoll();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById("msginput").style.display = "block";
|
|
|
|
startPoll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeConversation(convid) {
|
|
|
|
var convidp = document.getElementById("convidp");
|
|
|
|
if (convidp.innerText == convid + "")
|
|
|
|
return;
|
2016-08-17 12:31:29 +00:00
|
|
|
if (!canswitchconversations)
|
|
|
|
return;
|
2016-08-18 10:08:37 +00:00
|
|
|
console.log("Can't switch conversations now");
|
2016-08-17 12:31:29 +00:00
|
|
|
canswitchconversations = false;
|
|
|
|
stopPoll();
|
|
|
|
var chmsgse = document.getElementById("channelmessages");
|
|
|
|
var chmsgs = chmsgse.getElementsByClassName("chmessage");
|
2016-08-18 10:08:37 +00:00
|
|
|
while (chmsgs.length > 0)
|
|
|
|
chmsgse.removeChild(chmsgs[0]);
|
2016-08-17 10:48:31 +00:00
|
|
|
convidp.innerText = convid;
|
|
|
|
conversationChanged();
|
|
|
|
}
|
2016-08-18 20:35:23 +00:00
|
|
|
|