diff --git a/html/js/talk2me.js b/html/js/talk2me.js index 6b07a7e..b5a801c 100755 --- a/html/js/talk2me.js +++ b/html/js/talk2me.js @@ -109,7 +109,7 @@ } if (!msg) { - $.jGrowl("Message not sent - could not encrypt!", { life: 8000, group: "error-encryption" }); + growl("Message not sent - could not encrypt!", "error-encryption"); } else { var request = {"a": "message", "msg": jsonMessageString, "persistent": persistent, "encrypted": usekey}; conn.send(JSON.stringify(request)); @@ -206,6 +206,11 @@ } } + function growl(message, growlGroup) { + console.log(message, growlGroup); + $.jGrowl(message, { life: 3500, group: growlGroup }); + } + function handleMessage(json) { "use strict"; if (isLoggedIn) { @@ -213,7 +218,7 @@ if (jsonObj.a === "message" && jsonObj.t === "typing") { if (showMessage(jsonObj.encrypted, usekey)) { if ($(".from-" + jsonObj.from).size() < 1) { - $.jGrowl(jsonObj.msg, { life: 3500, group: "from-" + jsonObj.from }); + growl(jsonObj.msg, "from-" + jsonObj.from); } } } else if (jsonObj.a === "message" && jsonObj.t === "status-message") { @@ -227,7 +232,7 @@ updateRoomMember(jsonObj.username, jsonObj['currentStatus'], jsonObj.encrypted); } - $.jGrowl(jsonObj.msg, { life: 1500, group: "from-status-" + jsonObj.from }); + growl(jsonObj.msg, "from-status-" + jsonObj.from); } } else if (jsonObj.a === "message" && jsonObj.t === "who") { updateRoomMembers(jsonObj.users); @@ -251,7 +256,7 @@ notif.play(); // Append message to page - appendMessage(jsonObj.msg, jsonObj.encrypted); + appendParsedMessage(jsonObj.msg, jsonObj.encrypted); // Increment favicon if (!windowFocused && jsonObj.t === "message") { @@ -378,6 +383,31 @@ $(".messages").prepend("