Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Commit

Permalink
code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
breard-r committed Nov 6, 2014
1 parent 00d22a5 commit 7d9a975
Show file tree
Hide file tree
Showing 12 changed files with 501 additions and 500 deletions.
8 changes: 4 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//

chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('chromesoul.html', {
'width': 800,
'height': 500
});
chrome.app.window.create('chromesoul.html', {
'width': 800,
'height': 500
});
});
16 changes: 8 additions & 8 deletions chromesoul.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

<div id="main-ctn">
<div id="config-pannel">
<input type="text" placeholder="Login" id="login" class="opt" value="" /><br>
<input type="password" placeholder="Password (SOCKS)" id="pwd_socks" class="opt" value="" /><br>
<input type="checkbox" id="enable_notif" class="opt" checked="checked" /><label for="enable_notif">Enable notifications</label><br>
<input type="checkbox" id="enable_msg" class="opt" checked="checked" /><label for="enable_msg">Enable messages</label><br>
<input type="number" placeholder="12" id="chat-size" class="opt" value="" /><label for="chat-size">Chat font-size</label><br>
<button id="save">Save</button> <span id="status"></span>
<input type="text" placeholder="Login" id="login" class="opt" value="" /><br>
<input type="password" placeholder="Password (SOCKS)" id="pwd_socks" class="opt" value="" /><br>
<input type="checkbox" id="enable_notif" class="opt" checked="checked" /><label for="enable_notif">Enable notifications</label><br>
<input type="checkbox" id="enable_msg" class="opt" checked="checked" /><label for="enable_msg">Enable messages</label><br>
<input type="number" placeholder="12" id="chat-size" class="opt" value="" /><label for="chat-size">Chat font-size</label><br>
<button id="save">Save</button> <span id="status"></span>
</div>
<div id="chat-pannel">
<ul id="tab-lst"></ul>
<div id="tab-body-wrapper"></div>
<ul id="tab-lst"></ul>
<div id="tab-body-wrapper"></div>
</div>
</div>

Expand Down
10 changes: 5 additions & 5 deletions chromesoul.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var chromesoul = (function() {
var chromesoul = {
"opts": new OptionsManager(),
"ui": new Nsui(),
"contacts": new ContactList(),
"client": new Client(),
"avatars": new AvatarManager()
"opts": new OptionsManager(),
"ui": new Nsui(),
"contacts": new ContactList(),
"client": new Client(),
"avatars": new AvatarManager()
};

return (window.chromesoul = window.$cs = chromesoul);
Expand Down
24 changes: 12 additions & 12 deletions lib/avatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ AvatarManager.prototype.getContactPic = function(name, callback) {
xhr.open("GET", "http://cdn.local.epitech.net/userprofil/profilview/" + name + ".jpg", true);
xhr.responseType = "blob";
xhr.onload = (function(elem) {
return function(e) {
if (e.target.status === 200) {
elem.avatars[name] = window.webkitURL.createObjectURL(this.response);
} else {
elem.avatars[name] = "img/default-avatar.jpg";
}
return function(e) {
if (e.target.status === 200) {
elem.avatars[name] = window.webkitURL.createObjectURL(this.response);
} else {
elem.avatars[name] = "img/default-avatar.jpg";
}

if (typeof callback !== "undefined") {
callback(elem.avatars[name]);
}
};
if (typeof callback !== "undefined") {
callback(elem.avatars[name]);
}
};
})(this);
xhr.send();
}

AvatarManager.prototype.get = function(name, callback) {
if (typeof this.avatars[name] === "undefined") {
this.getContactPic(name, callback);
this.getContactPic(name, callback);
} else {
callback(this.avatars[name]);
callback(this.avatars[name]);
}
};
90 changes: 45 additions & 45 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,41 @@ var Client = function() {

Client.prototype.createSocket = function() {
if (this.socket === null) {
this.socket = new TxtSocket();
this.socket.onError = (function(elem) {
return function() {
elem.is_connected = false;
elem.connect();
};
})(this);
this.socket = new TxtSocket();
this.socket.onError = (function(elem) {
return function() {
elem.is_connected = false;
elem.connect();
};
})(this);
}
};

Client.prototype.connect = function() {
if (!this.is_connected) {
this.createSocket();
this.socket.connect(this.client.host, this.client.port, (function(elem) {
return function() {
elem.client.connect(elem, function() {
if (elem.is_connected) {
elem.daemonize();
elem.changeStatus();
elem.addContact();
} else {
elem.disconnect();
}
});
};
})(this));
this.createSocket();
this.socket.connect(this.client.host, this.client.port, (function(elem) {
return function() {
elem.client.connect(elem, function() {
if (elem.is_connected) {
elem.daemonize();
elem.changeStatus();
elem.addContact();
} else {
elem.disconnect();
}
});
};
})(this));
}
}

Client.prototype.disconnect = function() {
if (this.is_connected) {
this.is_connected = false;
this.client.disconnect(this);
this.socket.disconnect();
this.socket = null;
this.is_connected = false;
this.client.disconnect(this);
this.socket.disconnect();
this.socket = null;
}
this.changeStatus(this.client.status_disconnected);
};
Expand All @@ -72,49 +72,49 @@ Client.prototype.reconnect = function() {

Client.prototype.daemonize = function() {
this.socket.read((function(elem) {
return function(data) {
elem.client.recv(elem, data);
elem.daemonize();
};
return function(data) {
elem.client.recv(elem, data);
elem.daemonize();
};
})(this));
};

Client.prototype.changeStatus = function(status) {
if (typeof status === 'undefined') {
status = this.client.default_status;
status = this.client.default_status;
}
if (status !== this.status) {
this.status = status;
this.updateStatus();
this.status = status;
this.updateStatus();
}
};

Client.prototype.updateStatus = function() {
if (this.status !== null) {
this.client.changeStatus(this);
this.client.changeStatus(this);
}
};

Client.prototype.addContact = function(name) {
if (typeof name !== 'undefined') {
this.waiting_contacts.push(name);
this.waiting_contacts.push(name);
}
if (this.is_connected) {
var tmp = this.waiting_contacts;
this.waiting_contacts = [];
this.client.addContact(this, tmp);
var tmp = this.waiting_contacts;
this.waiting_contacts = [];
this.client.addContact(this, tmp);
}
};

Client.prototype.rmContact = function(name) {
if (this.is_connected) {
this.client.rmContact(this, name);
this.client.rmContact(this, name);
}
};

Client.prototype.speak = function(to, msg) {
if (this.is_connected) {
this.client.speak(this, to, msg);
this.client.speak(this, to, msg);
}
};

Expand All @@ -124,14 +124,14 @@ Client.prototype.init = function(client, ui) {

this.connect();
setInterval((function(elem) {
return function() {
elem.connect();
};
return function() {
elem.connect();
};
})(this), 10000);

setInterval((function(elem) {
return function() {
elem.updateStatus();
};
return function() {
elem.updateStatus();
};
})(this), 180000);
};
Loading

0 comments on commit 7d9a975

Please sign in to comment.