WIP
This commit is contained in:
@@ -2,8 +2,42 @@ define([
|
|||||||
'jquery',
|
'jquery',
|
||||||
'/bower_components/chainpad-crypto/crypto.js',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
'/common/curve.js',
|
'/common/curve.js',
|
||||||
|
'/common/common-hash.js',
|
||||||
|
|
||||||
'/bower_components/marked/marked.min.js',
|
'/bower_components/marked/marked.min.js',
|
||||||
], function ($, Crypto, Curve, Marked) {
|
'/common/common-realtime.js',
|
||||||
|
|
||||||
|
// displayAvatar
|
||||||
|
// whenRealtimeSyncs
|
||||||
|
// getRealtime -> removeFromFriendList
|
||||||
|
/* UI
|
||||||
|
Messages
|
||||||
|
confirm
|
||||||
|
fixHTML
|
||||||
|
displayAvatar
|
||||||
|
clearOwnedChannel
|
||||||
|
alert
|
||||||
|
|
||||||
|
|
||||||
|
pushMsg
|
||||||
|
removeFromFriendList
|
||||||
|
|
||||||
|
onDirectMessage
|
||||||
|
getNetwork
|
||||||
|
getProxy
|
||||||
|
pushMsg
|
||||||
|
|
||||||
|
Init
|
||||||
|
getNetwork
|
||||||
|
getProxy
|
||||||
|
onDirectMessage
|
||||||
|
removeFromFriendList
|
||||||
|
notify
|
||||||
|
onMessage
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
], function ($, Crypto, Curve, Hash, Marked, Realtime) {
|
||||||
var Msg = {
|
var Msg = {
|
||||||
inputs: [],
|
inputs: [],
|
||||||
};
|
};
|
||||||
@@ -28,11 +62,10 @@ define([
|
|||||||
return Marked(content);
|
return Marked(content);
|
||||||
};
|
};
|
||||||
|
|
||||||
var createData = Msg.createData = function (common, hash) {
|
var createData = Msg.createData = function (proxy, hash) {
|
||||||
var proxy = common.getProxy();
|
|
||||||
return {
|
return {
|
||||||
channel: hash || common.createChannelId(),
|
channel: hash || Hash.createChannelId(),
|
||||||
displayName: proxy[common.displayNameKey],
|
displayName: proxy['cryptpad.username'],
|
||||||
profile: proxy.profile && proxy.profile.view,
|
profile: proxy.profile && proxy.profile.view,
|
||||||
edPublic: proxy.edPublic,
|
edPublic: proxy.edPublic,
|
||||||
curvePublic: proxy.curvePublic,
|
curvePublic: proxy.curvePublic,
|
||||||
@@ -40,39 +73,39 @@ define([
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var getFriend = function (common, pubkey) {
|
var getFriend = function (proxy, pubkey) {
|
||||||
var proxy = common.getProxy();
|
|
||||||
if (pubkey === proxy.curvePublic) {
|
if (pubkey === proxy.curvePublic) {
|
||||||
var data = createData(common);
|
var data = createData(proxy);
|
||||||
delete data.channel;
|
delete data.channel;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
return proxy.friends ? proxy.friends[pubkey] : undefined;
|
return proxy.friends ? proxy.friends[pubkey] : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
var removeFromFriendList = Msg.removeFromFriendList = function (common, curvePublic, cb) {
|
var removeFromFriendList = function (proxy, realtime, curvePublic, cb) {
|
||||||
var proxy = common.getProxy();
|
if (!proxy.friends) { return; }
|
||||||
if (!proxy.friends) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var friends = proxy.friends;
|
var friends = proxy.friends;
|
||||||
delete friends[curvePublic];
|
delete friends[curvePublic];
|
||||||
common.whenRealtimeSyncs(common.getRealtime(), cb);
|
Realtime.whenRealtimeSyncs(realtime, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO set this up as an observable data structure
|
var getFriendList = Msg.getFriendList = function (proxy) {
|
||||||
var getFriendList = Msg.getFriendList = function (common) {
|
|
||||||
var proxy = common.getProxy();
|
|
||||||
if (!proxy.friends) { proxy.friends = {}; }
|
if (!proxy.friends) { proxy.friends = {}; }
|
||||||
return proxy.friends;
|
return proxy.friends;
|
||||||
};
|
};
|
||||||
|
|
||||||
Msg.getFriendChannelsList = function (common) {
|
var eachFriend = function (friends, cb) {
|
||||||
var friends = getFriendList(common);
|
Object.keys(friends).forEach(function (id) {
|
||||||
|
if (id === 'me') { return; }
|
||||||
|
cb(friends[id], id, friends);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Msg.getFriendChannelsList = function (proxy) {
|
||||||
var list = [];
|
var list = [];
|
||||||
Object.keys(friends).forEach(function (key) {
|
eachFriend(proxy, function (friend) {
|
||||||
if (key === "me") { return; }
|
list.push(friend.channel);
|
||||||
list.push(friends[key].channel);
|
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
};
|
};
|
||||||
@@ -85,9 +118,182 @@ define([
|
|||||||
|
|
||||||
var UI = Msg.UI = {};
|
var UI = Msg.UI = {};
|
||||||
|
|
||||||
// TODO extract into UI method
|
UI.init = function (common, $listContainer, $msgContainer) {
|
||||||
var createChatBox = function (common, $container, curvePublic, ui) {
|
var ui = {
|
||||||
var data = getFriend(common, curvePublic);
|
containers: {
|
||||||
|
friendList: $listContainer,
|
||||||
|
messages: $msgContainer,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.addToFriendList = function (data, display, remove) {
|
||||||
|
var $block = ui.containers.friendBlock;
|
||||||
|
|
||||||
|
var $friend = $('<div>', {'class': 'friend avatar'}).appendTo($block);
|
||||||
|
$friend.data('key', data.curvePublic);
|
||||||
|
var $rightCol = $('<span>', {'class': 'right-col'});
|
||||||
|
$('<span>', {'class': 'name'}).text(data.displayName).appendTo($rightCol);
|
||||||
|
var $remove = $('<span>', {'class': 'remove fa fa-user-times'}).appendTo($rightCol);
|
||||||
|
$remove.attr('title', common.Messages.contacts_remove);
|
||||||
|
$friend.dblclick(function () {
|
||||||
|
if (data.profile) {
|
||||||
|
window.open('/profile/#' + data.profile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$friend.click(function () {
|
||||||
|
display(data.curvePublic);
|
||||||
|
});
|
||||||
|
$remove.click(function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
common.confirm(common.Messages._getKey('contacts_confirmRemove', [
|
||||||
|
common.fixHTML(data.displayName)
|
||||||
|
]), function (yes) {
|
||||||
|
if (!yes) { return; }
|
||||||
|
remove(data.curvePublic);
|
||||||
|
}, null, true);
|
||||||
|
});
|
||||||
|
if (data.avatar && avatars[data.avatar]) {
|
||||||
|
$friend.append(avatars[data.avatar]);
|
||||||
|
$friend.append($rightCol);
|
||||||
|
} else {
|
||||||
|
common.displayAvatar($friend, data.avatar, data.displayName, function ($img) {
|
||||||
|
if (data.avatar && $img) {
|
||||||
|
avatars[data.avatar] = $img[0].outerHTML;
|
||||||
|
}
|
||||||
|
$friend.append($rightCol);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('<span>', {'class': 'status'}).appendTo($friend);
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.createFriendList = function (friends, display, remove) {
|
||||||
|
var $block = ui.containers.friendBlock = $('<div>');
|
||||||
|
eachFriend(friends, function (friend) {
|
||||||
|
ui.addToFriendList(friend, display, remove);
|
||||||
|
});
|
||||||
|
$block.appendTo($listContainer);
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.notify = function (curvePublic) {
|
||||||
|
var $friend = $listContainer.find('.friend').filter(function (idx, el) {
|
||||||
|
return $(el).data('key') === curvePublic;
|
||||||
|
});
|
||||||
|
$friend.addClass('notify');
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.unnotify = function (curvePublic) {
|
||||||
|
var $friend = $listContainer.find('.friend').filter(function (idx, el) {
|
||||||
|
return $(el).data('key') === curvePublic;
|
||||||
|
});
|
||||||
|
$friend.removeClass('notify');
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.update = function (curvePublic, types) {
|
||||||
|
var proxy = common.getProxy();
|
||||||
|
var data = getFriend(proxy, curvePublic);
|
||||||
|
var chan = channels[data.channel];
|
||||||
|
if (!chan.ready) {
|
||||||
|
chan.updateOnReady = (chan.updateOnReady || []).concat(types);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $friend = $listContainer.find('.friend').filter(function (idx, el) {
|
||||||
|
return $(el).data('key') === curvePublic;
|
||||||
|
});
|
||||||
|
if (types.indexOf('displayName') >= 0) {
|
||||||
|
$friend.find('.name').text(data.displayName);
|
||||||
|
}
|
||||||
|
if (types.indexOf('avatar') >= 0) {
|
||||||
|
$friend.find('.default').remove();
|
||||||
|
$friend.find('media-tag').remove();
|
||||||
|
if (data.avatar && avatars[data.avatar]) {
|
||||||
|
$friend.prepend(avatars[data.avatar]);
|
||||||
|
} else {
|
||||||
|
common.displayAvatar($friend, data.avatar, data.displayName, function ($img) {
|
||||||
|
if (data.avatar && $img) {
|
||||||
|
avatars[data.avatar] = $img[0].outerHTML;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.updateStatus = function (curvePublic, online) {
|
||||||
|
ui.getFriend(curvePublic).find('.status')
|
||||||
|
.attr('class', 'status ' + (online? 'online' : 'offline'));
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.getChannel = function (curvePublic) {
|
||||||
|
var $chat = $msgContainer.find('.chat').filter(function (idx, el) {
|
||||||
|
return $(el).data('key') === curvePublic;
|
||||||
|
});
|
||||||
|
return $chat.length? $chat: null;
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.hideInfo = function () {
|
||||||
|
$msgContainer.find('.info').hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.showInfo = function () {
|
||||||
|
$msgContainer.find('.info').show();
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.createChat = function (curvePublic) {
|
||||||
|
return $('<div>', {'class':'chat'})
|
||||||
|
.data('key', curvePublic).appendTo($msgContainer);
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.hideChat = function () {
|
||||||
|
$msgContainer.find('.chat').hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.getFriend = function (curvePublic) {
|
||||||
|
return $listContainer.find('.friend').filter(function (idx, el) {
|
||||||
|
return $(el).data('key') === curvePublic;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.remove = function (curvePublic) {
|
||||||
|
var $friend = ui.getFriend(curvePublic);
|
||||||
|
var $chat = ui.getChannel(curvePublic);
|
||||||
|
$friend.remove();
|
||||||
|
$chat.remove();
|
||||||
|
ui.showInfo();
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.createMessage = function (msg, name) {
|
||||||
|
var $msg = $('<div>', {'class': 'message'})
|
||||||
|
.attr('title', msg.time ? new Date(msg.time).toLocaleString(): '?');
|
||||||
|
|
||||||
|
if (name) {
|
||||||
|
$('<div>', {'class':'sender'}).text(name).appendTo($msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('<div>', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg);
|
||||||
|
return $msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.setEditable = function (bool) {
|
||||||
|
bool = !bool;
|
||||||
|
var input = ui.input;
|
||||||
|
if (!input) { return; }
|
||||||
|
|
||||||
|
if (bool) {
|
||||||
|
input.setAttribute('disabled', bool);
|
||||||
|
} else {
|
||||||
|
input.removeAttribute('disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (common.Messages) {
|
||||||
|
// set placeholder
|
||||||
|
var placeholder = bool?
|
||||||
|
common.Messages.disconnected:
|
||||||
|
common.Messages.contacts_typeHere;
|
||||||
|
input.setAttribute('placeholder', placeholder);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ui.createChatBox = function (proxy, $container, curvePublic) {
|
||||||
|
var data = getFriend(proxy, curvePublic);
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
var channel = channels[data.channel];
|
var channel = channels[data.channel];
|
||||||
@@ -207,181 +413,6 @@ define([
|
|||||||
$avatar.append($rightCol);
|
$avatar.append($rightCol);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
UI.init = function (common, $listContainer, $msgContainer) {
|
|
||||||
var ui = {
|
|
||||||
containers: {
|
|
||||||
friendList: $listContainer,
|
|
||||||
messages: $msgContainer,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.addToFriendList = function (data, display, remove) {
|
|
||||||
var $block = ui.containers.friendBlock;
|
|
||||||
|
|
||||||
var $friend = $('<div>', {'class': 'friend avatar'}).appendTo($block);
|
|
||||||
$friend.data('key', data.curvePublic);
|
|
||||||
var $rightCol = $('<span>', {'class': 'right-col'});
|
|
||||||
$('<span>', {'class': 'name'}).text(data.displayName).appendTo($rightCol);
|
|
||||||
var $remove = $('<span>', {'class': 'remove fa fa-user-times'}).appendTo($rightCol);
|
|
||||||
$remove.attr('title', common.Messages.contacts_remove);
|
|
||||||
$friend.dblclick(function () {
|
|
||||||
if (data.profile) {
|
|
||||||
window.open('/profile/#' + data.profile);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$friend.click(function () {
|
|
||||||
display(data.curvePublic);
|
|
||||||
});
|
|
||||||
$remove.click(function (e) {
|
|
||||||
e.stopPropagation();
|
|
||||||
common.confirm(common.Messages._getKey('contacts_confirmRemove', [
|
|
||||||
common.fixHTML(data.displayName)
|
|
||||||
]), function (yes) {
|
|
||||||
if (!yes) { return; }
|
|
||||||
remove(data.curvePublic);
|
|
||||||
}, null, true);
|
|
||||||
});
|
|
||||||
if (data.avatar && avatars[data.avatar]) {
|
|
||||||
$friend.append(avatars[data.avatar]);
|
|
||||||
$friend.append($rightCol);
|
|
||||||
} else {
|
|
||||||
common.displayAvatar($friend, data.avatar, data.displayName, function ($img) {
|
|
||||||
if (data.avatar && $img) {
|
|
||||||
avatars[data.avatar] = $img[0].outerHTML;
|
|
||||||
}
|
|
||||||
$friend.append($rightCol);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$('<span>', {'class': 'status'}).appendTo($friend);
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.createFriendList = function (friends, display, remove) {
|
|
||||||
var $block = ui.containers.friendBlock = $('<div>');
|
|
||||||
Object.keys(friends).forEach(function (f) {
|
|
||||||
if (f === 'me') { return; }
|
|
||||||
ui.addToFriendList(friends[f], display, remove);
|
|
||||||
});
|
|
||||||
$block.appendTo($listContainer);
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.notify = function (curvePublic) {
|
|
||||||
var $friend = $listContainer.find('.friend').filter(function (idx, el) {
|
|
||||||
return $(el).data('key') === curvePublic;
|
|
||||||
});
|
|
||||||
$friend.addClass('notify');
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.unnotify = function (curvePublic) {
|
|
||||||
var $friend = $listContainer.find('.friend').filter(function (idx, el) {
|
|
||||||
return $(el).data('key') === curvePublic;
|
|
||||||
});
|
|
||||||
$friend.removeClass('notify');
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.update = function (curvePublic, types) {
|
|
||||||
var data = getFriend(common, curvePublic);
|
|
||||||
var chan = channels[data.channel];
|
|
||||||
if (!chan.ready) {
|
|
||||||
chan.updateOnReady = (chan.updateOnReady || []).concat(types);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var $friend = $listContainer.find('.friend').filter(function (idx, el) {
|
|
||||||
return $(el).data('key') === curvePublic;
|
|
||||||
});
|
|
||||||
if (types.indexOf('displayName') >= 0) {
|
|
||||||
$friend.find('.name').text(data.displayName);
|
|
||||||
}
|
|
||||||
if (types.indexOf('avatar') >= 0) {
|
|
||||||
$friend.find('.default').remove();
|
|
||||||
$friend.find('media-tag').remove();
|
|
||||||
if (data.avatar && avatars[data.avatar]) {
|
|
||||||
$friend.prepend(avatars[data.avatar]);
|
|
||||||
} else {
|
|
||||||
common.displayAvatar($friend, data.avatar, data.displayName, function ($img) {
|
|
||||||
if (data.avatar && $img) {
|
|
||||||
avatars[data.avatar] = $img[0].outerHTML;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.updateStatus = function (curvePublic, online) {
|
|
||||||
ui.getFriend(curvePublic).find('.status')
|
|
||||||
.attr('class', 'status ' + online? 'online' : 'offline');
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.getChannel = function (curvePublic) {
|
|
||||||
var $chat = $msgContainer.find('.chat').filter(function (idx, el) {
|
|
||||||
return $(el).data('key') === curvePublic;
|
|
||||||
});
|
|
||||||
return $chat.length? $chat: null;
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.hideInfo = function () {
|
|
||||||
$msgContainer.find('.info').hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.showInfo = function () {
|
|
||||||
$msgContainer.find('.info').show();
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.createChat = function (curvePublic) {
|
|
||||||
return $('<div>', {'class':'chat'})
|
|
||||||
.data('key', curvePublic).appendTo($msgContainer);
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.hideChat = function () {
|
|
||||||
$msgContainer.find('.chat').hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.getFriend = function (curvePublic) {
|
|
||||||
return $listContainer.find('.friend').filter(function (idx, el) {
|
|
||||||
return $(el).data('key') === curvePublic;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.remove = function (curvePublic) {
|
|
||||||
var $friend = ui.getFriend(curvePublic);
|
|
||||||
var $chat = ui.getChannel(curvePublic);
|
|
||||||
$friend.remove();
|
|
||||||
$chat.remove();
|
|
||||||
ui.showInfo();
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.createMessage = function (msg, name) {
|
|
||||||
var $msg = $('<div>', {'class': 'message'})
|
|
||||||
.attr('title', msg.time ? new Date(msg.time).toLocaleString(): '?');
|
|
||||||
|
|
||||||
if (name) {
|
|
||||||
$('<div>', {'class':'sender'}).text(name).appendTo($msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('<div>', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg);
|
|
||||||
return $msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
ui.setEditable = function (bool) {
|
|
||||||
bool = !bool;
|
|
||||||
var input = ui.input;
|
|
||||||
if (!input) { return; }
|
|
||||||
|
|
||||||
if (bool) {
|
|
||||||
input.setAttribute('disabled', bool);
|
|
||||||
} else {
|
|
||||||
input.removeAttribute('disabled');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (common.Messages) {
|
|
||||||
// set placeholder
|
|
||||||
var placeholder = bool?
|
|
||||||
common.Messages.disconnected:
|
|
||||||
common.Messages.contacts_typeHere;
|
|
||||||
input.setAttribute('placeholder', placeholder);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return ui;
|
return ui;
|
||||||
@@ -393,7 +424,8 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var pushMsg = function (common, channel, cryptMsg) {
|
// TODO remove dependency on common
|
||||||
|
var pushMsg = function (realtime, proxy, common, channel, cryptMsg) {
|
||||||
var msg = channel.encryptor.decrypt(cryptMsg);
|
var msg = channel.encryptor.decrypt(cryptMsg);
|
||||||
|
|
||||||
var sig = cryptMsg.slice(0, 64);
|
var sig = cryptMsg.slice(0, 64);
|
||||||
@@ -413,12 +445,10 @@ define([
|
|||||||
channel.messages.push(res);
|
channel.messages.push(res);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var proxy;
|
|
||||||
if (parsedMsg[0] === Types.update) {
|
if (parsedMsg[0] === Types.update) {
|
||||||
proxy = common.getProxy();
|
if (parsedMsg[1] === proxy.curvePublic) { return; }
|
||||||
if (parsedMsg[1] === common.getProxy().curvePublic) { return; }
|
|
||||||
var newdata = parsedMsg[3];
|
var newdata = parsedMsg[3];
|
||||||
var data = getFriend(common, parsedMsg[1]);
|
var data = getFriend(proxy, parsedMsg[1]);
|
||||||
var types = [];
|
var types = [];
|
||||||
Object.keys(newdata).forEach(function (k) {
|
Object.keys(newdata).forEach(function (k) {
|
||||||
if (data[k] !== newdata[k]) {
|
if (data[k] !== newdata[k]) {
|
||||||
@@ -430,11 +460,7 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsedMsg[0] === Types.unfriend) {
|
if (parsedMsg[0] === Types.unfriend) {
|
||||||
proxy = common.getProxy();
|
removeFromFriendList(proxy, realtime, channel.friendEd, function () {
|
||||||
|
|
||||||
// FIXME pushMsg shouldn't need access to common
|
|
||||||
// implement this as a callback or use some other API
|
|
||||||
removeFromFriendList(common, channel.friendEd, function () {
|
|
||||||
channel.wc.leave(Types.unfriend);
|
channel.wc.leave(Types.unfriend);
|
||||||
channel.removeUI();
|
channel.removeUI();
|
||||||
});
|
});
|
||||||
@@ -444,10 +470,10 @@ define([
|
|||||||
|
|
||||||
/* Broadcast a display name, profile, or avatar change to all contacts
|
/* Broadcast a display name, profile, or avatar change to all contacts
|
||||||
*/
|
*/
|
||||||
var updateMyData = function (common) {
|
var updateMyData = function (proxy) {
|
||||||
var friends = getFriendList(common);
|
var friends = getFriendList(proxy);
|
||||||
var mySyncData = friends.me;
|
var mySyncData = friends.me;
|
||||||
var myData = createData(common);
|
var myData = createData(proxy);
|
||||||
if (!mySyncData || mySyncData.displayName !== myData.displayName
|
if (!mySyncData || mySyncData.displayName !== myData.displayName
|
||||||
|| mySyncData.profile !== myData.profile
|
|| mySyncData.profile !== myData.profile
|
||||||
|| mySyncData.avatar !== myData.avatar) {
|
|| mySyncData.avatar !== myData.avatar) {
|
||||||
@@ -467,20 +493,20 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onChannelReady = function (common, chanId) {
|
var onChannelReady = function (proxy, chanId) {
|
||||||
if (ready.indexOf(chanId) !== -1) { return; }
|
if (ready.indexOf(chanId) !== -1) { return; }
|
||||||
ready.push(chanId);
|
ready.push(chanId);
|
||||||
channels[chanId].updateStatus(); // c'est quoi?
|
channels[chanId].updateStatus(); // c'est quoi?
|
||||||
var friends = getFriendList(common);
|
var friends = getFriendList(proxy);
|
||||||
if (ready.length === Object.keys(friends).length) {
|
if (ready.length === Object.keys(friends).length) {
|
||||||
// All channels are ready
|
// All channels are ready
|
||||||
updateMyData(common);
|
updateMyData(proxy);
|
||||||
}
|
}
|
||||||
return ready.length;
|
return ready.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Id message allows us to map a netfluxId with a public curve key
|
// Id message allows us to map a netfluxId with a public curve key
|
||||||
var onIdMessage = function (common, msg, sender) {
|
var onIdMessage = function (proxy, network, msg, sender) {
|
||||||
var channel;
|
var channel;
|
||||||
var isId = Object.keys(channels).some(function (chanId) {
|
var isId = Object.keys(channels).some(function (chanId) {
|
||||||
if (channels[chanId].userList.indexOf(sender) !== -1) {
|
if (channels[chanId].userList.indexOf(sender) !== -1) {
|
||||||
@@ -516,6 +542,9 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsed[0] !== Types.mapId && parsed[0] !== Types.mapIdAck) { return; }
|
if (parsed[0] !== Types.mapId && parsed[0] !== Types.mapIdAck) { return; }
|
||||||
|
|
||||||
|
// check that the responding peer's encrypted netflux id matches
|
||||||
|
// the sender field. This is to prevent replay attacks.
|
||||||
if (parsed[2] !== sender || !parsed[1]) { return; }
|
if (parsed[2] !== sender || !parsed[1]) { return; }
|
||||||
channel.mapId[sender] = parsed[1];
|
channel.mapId[sender] = parsed[1];
|
||||||
|
|
||||||
@@ -523,15 +552,19 @@ define([
|
|||||||
|
|
||||||
if (parsed[0] !== Types.mapId) { return; } // Don't send your key if it's already an ACK
|
if (parsed[0] !== Types.mapId) { return; } // Don't send your key if it's already an ACK
|
||||||
// Answer with your own key
|
// Answer with your own key
|
||||||
var proxy = common.getProxy();
|
|
||||||
var network = common.getNetwork();
|
|
||||||
var rMsg = [Types.mapIdAck, proxy.curvePublic, channel.wc.myID];
|
var rMsg = [Types.mapIdAck, proxy.curvePublic, channel.wc.myID];
|
||||||
var rMsgStr = JSON.stringify(rMsg);
|
var rMsgStr = JSON.stringify(rMsg);
|
||||||
var cryptMsg = channel.encryptor.encrypt(rMsgStr);
|
var cryptMsg = channel.encryptor.encrypt(rMsgStr);
|
||||||
network.sendto(sender, cryptMsg);
|
network.sendto(sender, cryptMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// HERE
|
||||||
var onDirectMessage = function (common, msg, sender) {
|
var onDirectMessage = function (common, msg, sender) {
|
||||||
if (sender !== Msg.hk) { return void onIdMessage(common, msg, sender); }
|
var proxy = common.getProxy();
|
||||||
|
var network = common.getNetwork();
|
||||||
|
var realtime = common.getRealtime();
|
||||||
|
|
||||||
|
if (sender !== Msg.hk) { return void onIdMessage(proxy, network, msg, sender); }
|
||||||
var parsed = JSON.parse(msg);
|
var parsed = JSON.parse(msg);
|
||||||
if ((parsed.validateKey || parsed.owners) && parsed.channel) {
|
if ((parsed.validateKey || parsed.owners) && parsed.channel) {
|
||||||
return;
|
return;
|
||||||
@@ -542,7 +575,7 @@ define([
|
|||||||
// TODO: call a function that shows that the channel is ready? (remove a spinner, ...)
|
// TODO: call a function that shows that the channel is ready? (remove a spinner, ...)
|
||||||
// channel[parsed.channel].ready();
|
// channel[parsed.channel].ready();
|
||||||
channels[parsed.channel].ready = true;
|
channels[parsed.channel].ready = true;
|
||||||
onChannelReady(common, parsed.channel);
|
onChannelReady(proxy, parsed.channel);
|
||||||
var updateTypes = channels[parsed.channel].updateOnReady;
|
var updateTypes = channels[parsed.channel].updateOnReady;
|
||||||
if (updateTypes) {
|
if (updateTypes) {
|
||||||
channels[parsed.channel].updateUI(updateTypes);
|
channels[parsed.channel].updateUI(updateTypes);
|
||||||
@@ -552,12 +585,16 @@ define([
|
|||||||
}
|
}
|
||||||
var chan = parsed[3];
|
var chan = parsed[3];
|
||||||
if (!chan || !channels[chan]) { return; }
|
if (!chan || !channels[chan]) { return; }
|
||||||
pushMsg(common, channels[chan], parsed[4]);
|
pushMsg(realtime, proxy, common, channels[chan], parsed[4]);
|
||||||
channels[chan].refresh();
|
channels[chan].refresh();
|
||||||
};
|
};
|
||||||
var onMessage = function (common, msg, sender, chan) {
|
var onMessage = function (common, msg, sender, chan) {
|
||||||
if (!channels[chan.id]) { return; }
|
if (!channels[chan.id]) { return; }
|
||||||
var isMessage = pushMsg(common, channels[chan.id], msg);
|
|
||||||
|
var realtime = common.getRealtime();
|
||||||
|
var proxy = common.getProxy();
|
||||||
|
|
||||||
|
var isMessage = pushMsg(realtime, proxy, common, channels[chan.id], msg);
|
||||||
if (isMessage) {
|
if (isMessage) {
|
||||||
// Don't notify for your own messages
|
// Don't notify for your own messages
|
||||||
if (channels[chan.id].wc.myID !== sender) {
|
if (channels[chan.id].wc.myID !== sender) {
|
||||||
@@ -602,12 +639,15 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* TODO remove dependency on common
|
||||||
|
*/
|
||||||
Msg.init = function (common, ui) {
|
Msg.init = function (common, ui) {
|
||||||
// declare common variables
|
// declare common variables
|
||||||
var network = common.getNetwork();
|
var network = common.getNetwork();
|
||||||
var proxy = common.getProxy();
|
var proxy = common.getProxy();
|
||||||
|
var realtime = common.getRealtime();
|
||||||
Msg.hk = network.historyKeeper;
|
Msg.hk = network.historyKeeper;
|
||||||
var friends = getFriendList(common);
|
var friends = getFriendList(proxy);
|
||||||
|
|
||||||
// listen for messages...
|
// listen for messages...
|
||||||
network.on('message', function(msg, sender) {
|
network.on('message', function(msg, sender) {
|
||||||
@@ -645,7 +685,7 @@ define([
|
|||||||
for (var i = last + 1; i<messages.length; i++) {
|
for (var i = last + 1; i<messages.length; i++) {
|
||||||
msg = messages[i];
|
msg = messages[i];
|
||||||
name = (msg.channel !== channel.lastSender)?
|
name = (msg.channel !== channel.lastSender)?
|
||||||
getFriend(common, msg.channel).displayName: undefined;
|
getFriend(proxy, msg.channel).displayName: undefined;
|
||||||
|
|
||||||
ui.createMessage(msg, name).appendTo($messages);
|
ui.createMessage(msg, name).appendTo($messages);
|
||||||
channel.lastSender = msg.channel;
|
channel.lastSender = msg.channel;
|
||||||
@@ -667,7 +707,7 @@ define([
|
|||||||
var $chat = ui.getChannel(curvePublic);
|
var $chat = ui.getChannel(curvePublic);
|
||||||
if (!$chat) {
|
if (!$chat) {
|
||||||
$chat = ui.createChat(curvePublic);
|
$chat = ui.createChat(curvePublic);
|
||||||
createChatBox(common, $chat, curvePublic, ui);
|
ui.createChatBox(proxy, $chat, curvePublic);
|
||||||
}
|
}
|
||||||
// Show the correct div
|
// Show the correct div
|
||||||
ui.hideChat();
|
ui.hideChat();
|
||||||
@@ -682,9 +722,8 @@ define([
|
|||||||
|
|
||||||
// TODO take a callback
|
// TODO take a callback
|
||||||
var remove = function (curvePublic) {
|
var remove = function (curvePublic) {
|
||||||
var data = getFriend(common, curvePublic);
|
var data = getFriend(proxy, curvePublic);
|
||||||
var channel = channels[data.channel];
|
var channel = channels[data.channel];
|
||||||
//var newdata = createData(common, data.channel);
|
|
||||||
var msg = [Types.unfriend, proxy.curvePublic, +new Date()];
|
var msg = [Types.unfriend, proxy.curvePublic, +new Date()];
|
||||||
var msgStr = JSON.stringify(msg);
|
var msgStr = JSON.stringify(msg);
|
||||||
var cryptMsg = channel.encryptor.encrypt(msgStr);
|
var cryptMsg = channel.encryptor.encrypt(msgStr);
|
||||||
@@ -704,9 +743,7 @@ define([
|
|||||||
// Open the channels
|
// Open the channels
|
||||||
|
|
||||||
// TODO extract this into an external function
|
// TODO extract this into an external function
|
||||||
var openFriendChannel = function (f) {
|
var openFriendChannel = function (data, f) {
|
||||||
if (f === "me") { return; }
|
|
||||||
var data = friends[f];
|
|
||||||
var keys = Curve.deriveKeys(data.curvePublic, proxy.curvePrivate);
|
var keys = Curve.deriveKeys(data.curvePublic, proxy.curvePrivate);
|
||||||
var encryptor = Curve.createEncryptor(keys);
|
var encryptor = Curve.createEncryptor(keys);
|
||||||
network.join(data.channel).then(function (chan) {
|
network.join(data.channel).then(function (chan) {
|
||||||
@@ -719,13 +756,14 @@ define([
|
|||||||
refresh: function () { refresh(data.curvePublic); },
|
refresh: function () { refresh(data.curvePublic); },
|
||||||
notify: function () {
|
notify: function () {
|
||||||
ui.notify(data.curvePublic);
|
ui.notify(data.curvePublic);
|
||||||
common.notify();
|
common.notify(); // HERE
|
||||||
},
|
},
|
||||||
unnotify: function () { ui.unnotify(data.curvePublic); },
|
unnotify: function () { ui.unnotify(data.curvePublic); },
|
||||||
removeUI: function () { ui.remove(data.curvePublic); },
|
removeUI: function () { ui.remove(data.curvePublic); },
|
||||||
updateUI: function (types) { ui.update(data.curvePublic, types); },
|
updateUI: function (types) { ui.update(data.curvePublic, types); },
|
||||||
updateStatus: function () {
|
updateStatus: function () {
|
||||||
ui.updateStatus(data.curvePublic, channel.getStatus(data.curvePublic));
|
ui.updateStatus(data.curvePublic,
|
||||||
|
channel.getStatus(data.curvePublic));
|
||||||
},
|
},
|
||||||
setLastMessageRead: function (hash) {
|
setLastMessageRead: function (hash) {
|
||||||
data.lastKnownHash = hash;
|
data.lastKnownHash = hash;
|
||||||
@@ -774,7 +812,7 @@ define([
|
|||||||
var cryptMsg = channel.encryptor.encrypt(msgStr);
|
var cryptMsg = channel.encryptor.encrypt(msgStr);
|
||||||
|
|
||||||
channel.wc.bcast(cryptMsg).then(function () {
|
channel.wc.bcast(cryptMsg).then(function () {
|
||||||
pushMsg(common, channel, cryptMsg);
|
pushMsg(realtime, proxy, common, channel, cryptMsg);
|
||||||
cb();
|
cb();
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
cb(err);
|
cb(err);
|
||||||
@@ -823,7 +861,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var openFriendChannels = messenger.openFriendChannels = function () {
|
var openFriendChannels = messenger.openFriendChannels = function () {
|
||||||
Object.keys(friends).forEach(openFriendChannel);
|
eachFriend(friends, openFriendChannel);
|
||||||
};
|
};
|
||||||
|
|
||||||
messenger.setEditable = ui.setEditable;
|
messenger.setEditable = ui.setEditable;
|
||||||
@@ -832,13 +870,10 @@ define([
|
|||||||
|
|
||||||
// TODO split loop innards into ui methods
|
// TODO split loop innards into ui methods
|
||||||
var checkNewFriends = function () {
|
var checkNewFriends = function () {
|
||||||
Object.keys(friends).forEach(function (f) {
|
eachFriend(friends, function (friend, id) {
|
||||||
var $friend = ui.getFriend(f);
|
var $friend = ui.getFriend(id);
|
||||||
|
|
||||||
if (!$friend.length) {
|
if (!$friend.length) {
|
||||||
openFriendChannel(f);
|
openFriendChannel(friend, id);
|
||||||
if (f === 'me') { return; }
|
|
||||||
var friend = friends[f];
|
|
||||||
ui.addToFriendList(friend, display, remove);
|
ui.addToFriendList(friend, display, remove);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -846,7 +881,7 @@ define([
|
|||||||
|
|
||||||
common.onDisplayNameChanged(function () {
|
common.onDisplayNameChanged(function () {
|
||||||
checkNewFriends();
|
checkNewFriends();
|
||||||
updateMyData(common);
|
updateMyData(proxy);
|
||||||
});
|
});
|
||||||
|
|
||||||
return messenger;
|
return messenger;
|
||||||
@@ -856,17 +891,14 @@ define([
|
|||||||
// FIXME there are too many functions with this name
|
// FIXME there are too many functions with this name
|
||||||
var addToFriendList = Msg.addToFriendList = function (common, data, cb) {
|
var addToFriendList = Msg.addToFriendList = function (common, data, cb) {
|
||||||
var proxy = common.getProxy();
|
var proxy = common.getProxy();
|
||||||
if (!proxy.friends) {
|
var friends = getFriendList(proxy);
|
||||||
proxy.friends = {};
|
|
||||||
}
|
|
||||||
var friends = proxy.friends;
|
|
||||||
var pubKey = data.curvePublic;
|
var pubKey = data.curvePublic;
|
||||||
|
|
||||||
if (pubKey === proxy.curvePublic) { return void cb("E_MYKEY"); }
|
if (pubKey === proxy.curvePublic) { return void cb("E_MYKEY"); }
|
||||||
|
|
||||||
friends[pubKey] = data;
|
friends[pubKey] = data;
|
||||||
|
|
||||||
common.whenRealtimeSyncs(common.getRealtime(), function () {
|
Realtime.whenRealtimeSyncs(common.getRealtime(), function () {
|
||||||
cb();
|
cb();
|
||||||
common.pinPads([data.channel]);
|
common.pinPads([data.channel]);
|
||||||
});
|
});
|
||||||
@@ -876,6 +908,7 @@ define([
|
|||||||
/* Used to accept friend requests within apps other than /contacts/ */
|
/* Used to accept friend requests within apps other than /contacts/ */
|
||||||
Msg.addDirectMessageHandler = function (common) {
|
Msg.addDirectMessageHandler = function (common) {
|
||||||
var network = common.getNetwork();
|
var network = common.getNetwork();
|
||||||
|
var proxy = common.getProxy();
|
||||||
if (!network) { return void console.error('Network not ready'); }
|
if (!network) { return void console.error('Network not ready'); }
|
||||||
network.on('message', function (message, sender) {
|
network.on('message', function (message, sender) {
|
||||||
var msg;
|
var msg;
|
||||||
@@ -910,7 +943,7 @@ define([
|
|||||||
msgStr = Crypto.encrypt(JSON.stringify(msg), key);
|
msgStr = Crypto.encrypt(JSON.stringify(msg), key);
|
||||||
network.sendto(sender, msgStr);
|
network.sendto(sender, msgStr);
|
||||||
};
|
};
|
||||||
var existing = getFriend(common, msgData.curvePublic);
|
var existing = getFriend(proxy, msgData.curvePublic);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
todo(true);
|
todo(true);
|
||||||
return;
|
return;
|
||||||
@@ -941,7 +974,6 @@ define([
|
|||||||
var i = pendingRequests.indexOf(sender);
|
var i = pendingRequests.indexOf(sender);
|
||||||
if (i !== -1) { pendingRequests.splice(i, 1); }
|
if (i !== -1) { pendingRequests.splice(i, 1); }
|
||||||
common.log(common.Messages.contacts_rejected);
|
common.log(common.Messages.contacts_rejected);
|
||||||
var proxy = common.getProxy();
|
|
||||||
common.changeDisplayName(proxy[common.displayNameKey]);
|
common.changeDisplayName(proxy[common.displayNameKey]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
42
www/common/common-realtime.js
Normal file
42
www/common/common-realtime.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
define([
|
||||||
|
'/customize/application_config.js',
|
||||||
|
'/customize/messages.js',
|
||||||
|
], function (AppConfig, Messages) {
|
||||||
|
var common = {};
|
||||||
|
|
||||||
|
common.infiniteSpinnerDetected = false;
|
||||||
|
var BAD_STATE_TIMEOUT = typeof(AppConfig.badStateTimeout) === 'number'?
|
||||||
|
AppConfig.badStateTimeout: 30000;
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO make this not blow up when disconnected or lagging...
|
||||||
|
*/
|
||||||
|
common.whenRealtimeSyncs = function (realtime, cb) {
|
||||||
|
realtime.sync();
|
||||||
|
|
||||||
|
window.setTimeout(function () {
|
||||||
|
if (realtime.getAuthDoc() === realtime.getUserDoc()) {
|
||||||
|
return void cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
var to = setTimeout(function () {
|
||||||
|
realtime.abort();
|
||||||
|
// don't launch more than one popup
|
||||||
|
if (common.infiniteSpinnerDetected) { return; }
|
||||||
|
|
||||||
|
// inform the user their session is in a bad state
|
||||||
|
common.confirm(Messages.realtime_unrecoverableError, function (yes) {
|
||||||
|
if (!yes) { return; }
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
common.infiniteSpinnerDetected = true;
|
||||||
|
}, BAD_STATE_TIMEOUT);
|
||||||
|
realtime.onSettle(function () {
|
||||||
|
clearTimeout(to);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
return common;
|
||||||
|
});
|
||||||
@@ -14,13 +14,15 @@ define([
|
|||||||
'/common/common-codemirror.js',
|
'/common/common-codemirror.js',
|
||||||
'/common/common-file.js',
|
'/common/common-file.js',
|
||||||
'/file/file-crypto.js',
|
'/file/file-crypto.js',
|
||||||
|
'/common/common-realtime.js',
|
||||||
|
|
||||||
'/common/clipboard.js',
|
'/common/clipboard.js',
|
||||||
'/common/pinpad.js',
|
'/common/pinpad.js',
|
||||||
'/customize/application_config.js',
|
'/customize/application_config.js',
|
||||||
'/common/media-tag.js',
|
'/common/media-tag.js',
|
||||||
], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata,
|
], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata,
|
||||||
Messaging, CodeMirror, Files, FileCrypto, Clipboard, Pinpad, AppConfig, MediaTag) {
|
Messaging, CodeMirror, Files, FileCrypto, Realtime, Clipboard,
|
||||||
|
Pinpad, AppConfig, MediaTag) {
|
||||||
|
|
||||||
// Configure MediaTags to use our local viewer
|
// Configure MediaTags to use our local viewer
|
||||||
if (MediaTag && MediaTag.PdfPlugin) {
|
if (MediaTag && MediaTag.PdfPlugin) {
|
||||||
@@ -129,6 +131,9 @@ define([
|
|||||||
common.getLatestMessages = Messaging.getLatestMessages;
|
common.getLatestMessages = Messaging.getLatestMessages;
|
||||||
common.initMessagingUI = Messaging.UI.init;
|
common.initMessagingUI = Messaging.UI.init;
|
||||||
|
|
||||||
|
// Realtime
|
||||||
|
var whenRealtimeSyncs = common.whenRealtimeSyncs = Realtime.whenRealtimeSyncs;
|
||||||
|
|
||||||
// Userlist
|
// Userlist
|
||||||
common.createUserList = UserList.create;
|
common.createUserList = UserList.create;
|
||||||
|
|
||||||
@@ -244,36 +249,6 @@ define([
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
common.infiniteSpinnerDetected = false;
|
|
||||||
var BAD_STATE_TIMEOUT = typeof(AppConfig.badStateTimeout) === 'number'?
|
|
||||||
AppConfig.badStateTimeout: 30000;
|
|
||||||
var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
|
|
||||||
realtime.sync();
|
|
||||||
|
|
||||||
window.setTimeout(function () {
|
|
||||||
if (realtime.getAuthDoc() === realtime.getUserDoc()) {
|
|
||||||
return void cb();
|
|
||||||
}
|
|
||||||
|
|
||||||
var to = setTimeout(function () {
|
|
||||||
realtime.abort();
|
|
||||||
// don't launch more than one popup
|
|
||||||
if (common.infiniteSpinnerDetected) { return; }
|
|
||||||
|
|
||||||
// inform the user their session is in a bad state
|
|
||||||
common.confirm(Messages.realtime_unrecoverableError, function (yes) {
|
|
||||||
if (!yes) { return; }
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
common.infiniteSpinnerDetected = true;
|
|
||||||
}, BAD_STATE_TIMEOUT);
|
|
||||||
realtime.onSettle(function () {
|
|
||||||
clearTimeout(to);
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
}, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
common.getWebsocketURL = function () {
|
common.getWebsocketURL = function () {
|
||||||
if (!Config.websocketPath) { return Config.websocketURL; }
|
if (!Config.websocketPath) { return Config.websocketURL; }
|
||||||
var path = Config.websocketPath;
|
var path = Config.websocketPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user