' + time
+ + '
';
+
+ }
+ } else {
+ if (uid != gMyName) {
+ li = '' + uid + ' ' + time +
+ '
';
+ }
+ else {
+ li = ' ' + time
+ + '
';
+
+ }
}
li += ' ';
}
else {
- if(!fsEnabled) {
+ if (!fsEnabled) {
if (uid != gMyName) {
li = ' ' + uid + ' '
- + time + "" + autolinker.link(message) + '';
+ + time + '' + autolinker.link(message) + ' ';
}
else {
- li = ' ' + time + "" + autolinker.link(message) + '';
+ li = ' ' + time + '' + autolinker.link(message) + '';
}
}
else {
if (uid != gMyName) {
- li = ' ' + uid + ' '
- + time + '' + autolinker.link(message) + '';
+ li = ' ' + uid + ' '
+ + time + '' + autolinker.link(message) + '';
}
else {
- li = ' ' + time + '' + autolinker.link(message) + '';
+ li = ' ' + time + '' + autolinker.link(message) + '';
}
}
}
@@ -743,7 +780,7 @@ function processData(uid, channel, msgTimestamp,
scrollToBottom();
}
- const notifyTimestamp = parseInt(msgTimestamp/1000/60); //one notify per minute
+ const notifyTimestamp = parseInt(msgTimestamp / 1000 / 60); //one notify per minute
if (uid != gMyName && isFull && gIdNotifyTs[get_uniq(uid, channel)] < notifyTimestamp) {
if (gWillNotify && gCanNotify) {
if (true == isImage) {
@@ -811,7 +848,7 @@ gWebWorker.onmessage = function (e) {
msgtype & MSGISIMAGE ? true : false,
msgtype & MSGISMULTIPART ? true : false,
msgtype & MSGISFIRST ? true : false,
- msgtype & MSGISLAST ? true : false,
+ msgtype & MSGISLAST ? true : false,
fsEnabled);
if (ret < 0) {
console.log("Process data failed: " + ret);
@@ -844,20 +881,20 @@ gWebWorker.onmessage = function (e) {
}
break;
case "forwardsecrecy":
- {
- let uid = e.data[1];
- let channel = e.data[2];
- //let myuid = e.data[3];
- //let mychan = e.data[4];
- const prevBdKey = e.data[5];
-
- let ret = processForwardSecrecy(uid, channel, prevBdKey);
- //console.log("Got forward secrecy!")
- if (ret < 0) {
- console.log("Process close failed: " + ret);
- }
+ {
+ let uid = e.data[1];
+ let channel = e.data[2];
+ //let myuid = e.data[3];
+ //let mychan = e.data[4];
+ const prevBdKey = e.data[5];
+
+ let ret = processForwardSecrecy(uid, channel, prevBdKey);
+ //console.log("Got forward secrecy!")
+ if (ret < 0) {
+ console.log("Process close failed: " + ret);
}
- break;
+ }
+ break;
case "forwardsecrecyoff":
{
let uid = e.data[1];
@@ -960,12 +997,12 @@ function scrollToBottom() {
function sendData(cmd, uid, channel, data, msgtype) {
if (gInitOk) {
- const msgDate = parseInt(Date.now()/1000) * 1000; //in seconds
+ const msgDate = parseInt(Date.now() / 1000) * 1000; //in seconds
let mHash;
let arr = [cmd, data, uid, channel, gIsTokenChannel, msgtype, msgDate.valueOf()];
- if(!(msgtype & MSGISPRESENCE) && gSipKeyIsOk) {
+ if (!(msgtype & MSGISPRESENCE) && gSipKeyIsOk) {
mHash = hashMessage(uid, msgtype & MSGISFULL ? msgDate.valueOf() + data + '\n' : msgDate.valueOf() + data);
msgHashHandle(uid, channel, msgDate.valueOf(), mHash);
}
@@ -991,17 +1028,26 @@ function updateAfterSend(message, isFull, isImage) {
$('#messages').append(li);
}
+ if(!date)
+ time = checkTime(gMyName, gMyChannel, time, isFull);
+
if (!isImage) {
if (!gForwardSecrecy) {
li = ' ' + time + "" + autolinker.link(message) + '';
}
else {
- li = ' ' + time + '' + autolinker.link(message) + '';
+ li = ' ' + time + '' + autolinker.link(message) + '';
}
}
else {
+ if (!gForwardSecrecy) {
li = ' ' + time
+ '
';
+ }
+ else {
+ li = ' ' + time
+ + '
';
+ }
}
@@ -1036,7 +1082,7 @@ function sendMessage(message, isFull, isPresence, isPresenceAck = false) {
const MULTIPART_SLICE = 768; //B
async function sendDataurl(dataUrl, uid, channel) {
- let msgtype = MSGISFULL|MSGISIMAGE;
+ let msgtype = MSGISFULL | MSGISIMAGE;
if (dataUrl.length > MULTIPART_SLICE) {
msgtype |= MSGISMULTIPART;
@@ -1134,14 +1180,14 @@ function getLocalAddrPortInput() {
function getLocalBdKey() {
const bdKey = window.localStorage.getItem('gPrevBdKey');
- if(bdKey) {
+ if (bdKey) {
gPrevBdKey = bdKey;
//console.log("Loading key from local storage!");
}
}
function setLocalBdKey(bdKey) {
- if(bdKey) {
+ if (bdKey) {
window.localStorage.setItem('gPrevBdKey', bdKey);
//console.log("Saving keys to local storage!");
}