contact status
|
@ -24,6 +24,9 @@ There's a few bugs with avatars, however it works.
|
|||
### State change
|
||||
It's on it's way.
|
||||
|
||||
### Contact's status
|
||||
A status indicator is available next to the contact's avatar.
|
||||
|
||||
### File transfer
|
||||
Maybe later.
|
||||
|
||||
|
|
|
@ -87,6 +87,10 @@ body {
|
|||
font-family: monospace;
|
||||
}
|
||||
|
||||
#contact-lst > li > span {
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.remove {
|
||||
float: right;
|
||||
font-family: sans-serif;
|
||||
|
|
BIN
img/status/contact-away.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
img/status/contact-connected.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
img/status/contact-disconnected.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
img/status/contact-dnd.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
img/status/me-away.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
BIN
img/status/me-dnd.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
|
@ -21,6 +21,7 @@ var Client = function() {
|
|||
this.ui = null;
|
||||
this.status = null;
|
||||
this.contacts = [];
|
||||
this.waiting_contacts = [];
|
||||
};
|
||||
|
||||
Client.prototype.createSocket = function() {
|
||||
|
@ -44,6 +45,7 @@ Client.prototype.connect = function() {
|
|||
if (elem.is_connected) {
|
||||
elem.daemonize();
|
||||
elem.changeStatus();
|
||||
elem.addContact();
|
||||
} else {
|
||||
elem.disconnect();
|
||||
}
|
||||
|
@ -94,8 +96,13 @@ Client.prototype.updateStatus = function() {
|
|||
};
|
||||
|
||||
Client.prototype.addContact = function(name) {
|
||||
if (typeof name !== 'undefined') {
|
||||
this.waiting_contacts.push(name);
|
||||
}
|
||||
if (this.is_connected) {
|
||||
this.client.addContact(this, name);
|
||||
var tmp = this.waiting_contacts;
|
||||
this.waiting_contacts = [];
|
||||
this.client.addContact(this, tmp);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
var ContactList = function() {
|
||||
this.storage = chrome.storage.sync;
|
||||
this.contacts = {}; // {<name>: {name: <string>, li: <DOM element>, avatar: <url>}}
|
||||
this.contacts = {}; // {<name>: {name: <string>, li: <DOM element>, img: <DOM element>, avatar: <url>}}
|
||||
this.lst = document.getElementById("contact-lst");
|
||||
};
|
||||
|
||||
|
@ -52,11 +52,14 @@ ContactList.prototype.addContact = function(name) {
|
|||
$cs.avatars.get(infos.name, function(url) {
|
||||
li.style.backgroundImage = "url('" + url + "')";
|
||||
});
|
||||
img = document.createElement("img");
|
||||
this.setImageStatus(img, "offline");
|
||||
login = document.createElement("span");
|
||||
close = document.createElement("span");
|
||||
close.classList.add("remove");
|
||||
login.innerHTML = name;
|
||||
close.innerHTML = '<img src="img/delcontact.png" alt="x" title="delete contact">';
|
||||
li.appendChild(img);
|
||||
li.appendChild(login);
|
||||
li.appendChild(close);
|
||||
li.addEventListener("dblclick", function() {
|
||||
|
@ -72,6 +75,7 @@ ContactList.prototype.addContact = function(name) {
|
|||
})(this));
|
||||
|
||||
infos.li = li;
|
||||
infos.img = img;
|
||||
this.contacts[name] = infos;
|
||||
this.save();
|
||||
this.insertContact(infos);
|
||||
|
@ -87,8 +91,41 @@ ContactList.prototype.rmContact = function(name) {
|
|||
}
|
||||
};
|
||||
|
||||
ContactList.prototype.setImageStatus = function(img, status) {
|
||||
var status_list = {'default' : 'img/status/contact-connected.png',
|
||||
|
||||
'offline': 'img/status/contact-disconnected.png',
|
||||
'disconnected': 'img/status/contact-disconnected.png',
|
||||
'deconnecte': 'img/status/contact-disconnected.png',
|
||||
'deco': 'img/status/contact-disconnected.png',
|
||||
'hidden': 'img/status/contact-disconnected.png',
|
||||
'cache': 'img/status/contact-disconnected.png',
|
||||
|
||||
'away': 'img/status/contact-away.png',
|
||||
'inactif': 'img/status/contact-away.png',
|
||||
'absent': 'img/status/contact-away.png',
|
||||
'idle': 'img/status/contact-away.png',
|
||||
|
||||
'dnd': 'img/status/contact-dnd.png',
|
||||
'occuped': 'img/status/contact-dnd.png',
|
||||
'npd': 'img/status/contact-dnd.png',
|
||||
'occupe': 'img/status/contact-dnd.png'
|
||||
};
|
||||
|
||||
if (status_list.hasOwnProperty(status)) {
|
||||
img.src = status_list[status];
|
||||
} else {
|
||||
img.src = status_list.default;
|
||||
}
|
||||
img.alt = status;
|
||||
img.title = status;
|
||||
};
|
||||
|
||||
ContactList.prototype.changeContactStatus = function(name, status) {
|
||||
if (typeof this.contacts[name] !== "undefined") {
|
||||
this.setImageStatus(this.contacts[name].img, status);
|
||||
console.log(name + ' changed his status to ' + status);
|
||||
}
|
||||
};
|
||||
|
||||
ContactList.prototype.save = function() {
|
||||
|
|
|
@ -60,7 +60,7 @@ var NsClient = function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
$cs.contacts.changeContactStatus(mch[2], this.msgDecode(mch[6])); // TODO: FIX ME!
|
||||
$cs.contacts.changeContactStatus(mch[2], elem.msgDecode(mch[6])); // TODO: FIX ME!
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -90,7 +90,7 @@ var NsClient = function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
$cs.contacts.changeContactStatus(mch[7], this.msgDecode(mch[16])); // TODO: FIX ME!
|
||||
$cs.contacts.changeContactStatus(mch[7], elem.msgDecode(mch[16])); // TODO: FIX ME!
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -157,7 +157,6 @@ NsClient.prototype.changeStatus = function(client) {
|
|||
};
|
||||
|
||||
NsClient.prototype.recv = function(client, data) {
|
||||
console.log('Debug: ' + data); // TODO: REMOVE ME!
|
||||
for (var i = this.actions_enabled.length - 1; i >= 0; --i) {
|
||||
if (this.action[this.actions_enabled[i]](client, data)) {
|
||||
break;
|
||||
|
@ -165,30 +164,22 @@ NsClient.prototype.recv = function(client, data) {
|
|||
}
|
||||
};
|
||||
|
||||
NsClient.prototype.addContact = function(client, name) {
|
||||
// TODO
|
||||
};
|
||||
|
||||
NsClient.prototype.rmContact = function(client, name) {
|
||||
// TODO
|
||||
};
|
||||
|
||||
NsClient.prototype.speak = function(client, to, msg) {
|
||||
msg = 'user_cmd msg_user ' + to + ' msg ' + this.msgEncode(msg) + '\n';
|
||||
client.socket.write(msg, function(inf) {});
|
||||
};
|
||||
|
||||
NsClient.prototype.addContact = function(client, name) {
|
||||
var msg = 'user_cmd watch_log_user {' + name + '}\n';
|
||||
NsClient.prototype.addContact = function(client, lst) {
|
||||
var msg = 'user_cmd watch_log_user {' + lst.join(',') + '}\n';
|
||||
|
||||
client.socket.write(msg, function(inf) {
|
||||
var msg = 'user_cmd who {' + name + '}\n';
|
||||
console.log('stalking ' + name + ': ' + msg);
|
||||
var msg = 'user_cmd who {' + lst.join(',') + '}\n';
|
||||
client.socket.write(msg, function(inf) {});
|
||||
});
|
||||
};
|
||||
|
||||
NsClient.prototype.rmContact = function(client, name) {
|
||||
// TODO
|
||||
};
|
||||
|
||||
NsClient.prototype.replacePairs = function(str, pairs) {
|
||||
|
|