diff --git a/chromesoul.css b/chromesoul.css index 10930ef..f186680 100644 --- a/chromesoul.css +++ b/chromesoul.css @@ -14,7 +14,7 @@ body { #user-status { position: fixed; - right: 285px; + right: 155px; top: 10px; margin: 0; padding: 0; @@ -29,6 +29,10 @@ body { padding: 0; } +.clickable { + cursor: pointer; +} + /* * Contact list */ diff --git a/chromesoul.html b/chromesoul.html index d69fa35..e36143b 100644 --- a/chromesoul.html +++ b/chromesoul.html @@ -6,12 +6,11 @@ -

- Status:
- +

+ disconnected

-
+
settings
diff --git a/img/default-avatar.jpg b/img/default-avatar.jpg index 0e7e73b..d71090c 100644 Binary files a/img/default-avatar.jpg and b/img/default-avatar.jpg differ diff --git a/img/status/me-connected.png b/img/status/me-connected.png new file mode 100644 index 0000000..6334575 Binary files /dev/null and b/img/status/me-connected.png differ diff --git a/img/status/me-disconnected.png b/img/status/me-disconnected.png new file mode 100644 index 0000000..47ecb3c Binary files /dev/null and b/img/status/me-disconnected.png differ diff --git a/lib/contacts.nsui.js b/lib/contacts.nsui.js index 71cfc03..b27f79b 100644 --- a/lib/contacts.nsui.js +++ b/lib/contacts.nsui.js @@ -56,7 +56,7 @@ ContactList.prototype.addContact = function(name) { close = document.createElement("span"); close.classList.add("remove"); login.innerHTML = name; - close.innerHTML = "x"; + close.innerHTML = 'x'; li.appendChild(login); li.appendChild(close); li.addEventListener("dblclick", function() { diff --git a/lib/ns_client.js b/lib/ns_client.js index 7f11d05..9b34052 100644 --- a/lib/ns_client.js +++ b/lib/ns_client.js @@ -172,22 +172,16 @@ NsClient.prototype.sendMessage = function(to, message) { }; NsClient.prototype.updateStatus = function() { - var status_txt = document.getElementById("status_txt"); + var status = "disconnected", status_msg = ""; if (this.is_connected) { - if (status_txt !== null) { - status_txt.innerHTML = this.state; - } - - var status_msg = "user_cmd state "; + status_msg = "user_cmd state "; + status = this.state; status_msg += this.state + ":"; status_msg += Math.round(new Date().getTime() / 1000) + "\n"; chrome.socket.write(this.socket, str2ab(status_msg), function(w_inf) {}); - } else { - if (status_txt !== null) { - status_txt.innerHTML = 'disconnected'; - } } + $cs.ui.onUserStatusChange(status); }; NsClient.prototype.changeStatus = function(new_status) { diff --git a/lib/nsui.js b/lib/nsui.js index 62da932..30675b1 100644 --- a/lib/nsui.js +++ b/lib/nsui.js @@ -20,7 +20,21 @@ var Nsui = function() { }; Nsui.prototype.setReconnect = function(func) { - document.getElementById("reconnect").addEventListener("click", func, false); + document.getElementById("user-status").addEventListener("click", func, false); +}; + +Nsui.prototype.onUserStatusChange = function(new_status) { + var el = document.getElementById("user-status-img"); + + if (el !== null) { + if (new_status !== "disconnected") { + el.src = 'img/status/me-connected.png'; + } else { + el.src = 'img/status/me-disconnected.png'; + } + el.alt = new_status; + el.title = new_status; + } }; Nsui.prototype.createTab = function(name) {