code styling

This commit is contained in:
Rodolphe Breard 2014-11-06 18:52:14 +01:00
parent 00d22a5535
commit 7d9a97558c
12 changed files with 488 additions and 487 deletions

View file

@ -15,8 +15,8 @@
// //
chrome.app.runtime.onLaunched.addListener(function() { chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('chromesoul.html', { chrome.app.window.create('chromesoul.html', {
'width': 800, 'width': 800,
'height': 500 'height': 500
}); });
}); });

View file

@ -19,16 +19,16 @@
<div id="main-ctn"> <div id="main-ctn">
<div id="config-pannel"> <div id="config-pannel">
<input type="text" placeholder="Login" id="login" class="opt" value="" /><br> <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="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_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="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> <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> <button id="save">Save</button> <span id="status"></span>
</div> </div>
<div id="chat-pannel"> <div id="chat-pannel">
<ul id="tab-lst"></ul> <ul id="tab-lst"></ul>
<div id="tab-body-wrapper"></div> <div id="tab-body-wrapper"></div>
</div> </div>
</div> </div>

View file

@ -1,10 +1,10 @@
var chromesoul = (function() { var chromesoul = (function() {
var chromesoul = { var chromesoul = {
"opts": new OptionsManager(), "opts": new OptionsManager(),
"ui": new Nsui(), "ui": new Nsui(),
"contacts": new ContactList(), "contacts": new ContactList(),
"client": new Client(), "client": new Client(),
"avatars": new AvatarManager() "avatars": new AvatarManager()
}; };
return (window.chromesoul = window.$cs = chromesoul); return (window.chromesoul = window.$cs = chromesoul);

View file

@ -24,25 +24,25 @@ AvatarManager.prototype.getContactPic = function(name, callback) {
xhr.open("GET", "http://cdn.local.epitech.net/userprofil/profilview/" + name + ".jpg", true); xhr.open("GET", "http://cdn.local.epitech.net/userprofil/profilview/" + name + ".jpg", true);
xhr.responseType = "blob"; xhr.responseType = "blob";
xhr.onload = (function(elem) { xhr.onload = (function(elem) {
return function(e) { return function(e) {
if (e.target.status === 200) { if (e.target.status === 200) {
elem.avatars[name] = window.webkitURL.createObjectURL(this.response); elem.avatars[name] = window.webkitURL.createObjectURL(this.response);
} else { } else {
elem.avatars[name] = "img/default-avatar.jpg"; elem.avatars[name] = "img/default-avatar.jpg";
} }
if (typeof callback !== "undefined") { if (typeof callback !== "undefined") {
callback(elem.avatars[name]); callback(elem.avatars[name]);
} }
}; };
})(this); })(this);
xhr.send(); xhr.send();
} }
AvatarManager.prototype.get = function(name, callback) { AvatarManager.prototype.get = function(name, callback) {
if (typeof this.avatars[name] === "undefined") { if (typeof this.avatars[name] === "undefined") {
this.getContactPic(name, callback); this.getContactPic(name, callback);
} else { } else {
callback(this.avatars[name]); callback(this.avatars[name]);
} }
}; };

View file

@ -26,41 +26,41 @@ var Client = function() {
Client.prototype.createSocket = function() { Client.prototype.createSocket = function() {
if (this.socket === null) { if (this.socket === null) {
this.socket = new TxtSocket(); this.socket = new TxtSocket();
this.socket.onError = (function(elem) { this.socket.onError = (function(elem) {
return function() { return function() {
elem.is_connected = false; elem.is_connected = false;
elem.connect(); elem.connect();
}; };
})(this); })(this);
} }
}; };
Client.prototype.connect = function() { Client.prototype.connect = function() {
if (!this.is_connected) { if (!this.is_connected) {
this.createSocket(); this.createSocket();
this.socket.connect(this.client.host, this.client.port, (function(elem) { this.socket.connect(this.client.host, this.client.port, (function(elem) {
return function() { return function() {
elem.client.connect(elem, function() { elem.client.connect(elem, function() {
if (elem.is_connected) { if (elem.is_connected) {
elem.daemonize(); elem.daemonize();
elem.changeStatus(); elem.changeStatus();
elem.addContact(); elem.addContact();
} else { } else {
elem.disconnect(); elem.disconnect();
} }
}); });
}; };
})(this)); })(this));
} }
} }
Client.prototype.disconnect = function() { Client.prototype.disconnect = function() {
if (this.is_connected) { if (this.is_connected) {
this.is_connected = false; this.is_connected = false;
this.client.disconnect(this); this.client.disconnect(this);
this.socket.disconnect(); this.socket.disconnect();
this.socket = null; this.socket = null;
} }
this.changeStatus(this.client.status_disconnected); this.changeStatus(this.client.status_disconnected);
}; };
@ -72,49 +72,49 @@ Client.prototype.reconnect = function() {
Client.prototype.daemonize = function() { Client.prototype.daemonize = function() {
this.socket.read((function(elem) { this.socket.read((function(elem) {
return function(data) { return function(data) {
elem.client.recv(elem, data); elem.client.recv(elem, data);
elem.daemonize(); elem.daemonize();
}; };
})(this)); })(this));
}; };
Client.prototype.changeStatus = function(status) { Client.prototype.changeStatus = function(status) {
if (typeof status === 'undefined') { if (typeof status === 'undefined') {
status = this.client.default_status; status = this.client.default_status;
} }
if (status !== this.status) { if (status !== this.status) {
this.status = status; this.status = status;
this.updateStatus(); this.updateStatus();
} }
}; };
Client.prototype.updateStatus = function() { Client.prototype.updateStatus = function() {
if (this.status !== null) { if (this.status !== null) {
this.client.changeStatus(this); this.client.changeStatus(this);
} }
}; };
Client.prototype.addContact = function(name) { Client.prototype.addContact = function(name) {
if (typeof name !== 'undefined') { if (typeof name !== 'undefined') {
this.waiting_contacts.push(name); this.waiting_contacts.push(name);
} }
if (this.is_connected) { if (this.is_connected) {
var tmp = this.waiting_contacts; var tmp = this.waiting_contacts;
this.waiting_contacts = []; this.waiting_contacts = [];
this.client.addContact(this, tmp); this.client.addContact(this, tmp);
} }
}; };
Client.prototype.rmContact = function(name) { Client.prototype.rmContact = function(name) {
if (this.is_connected) { if (this.is_connected) {
this.client.rmContact(this, name); this.client.rmContact(this, name);
} }
}; };
Client.prototype.speak = function(to, msg) { Client.prototype.speak = function(to, msg) {
if (this.is_connected) { if (this.is_connected) {
this.client.speak(this, to, msg); this.client.speak(this, to, msg);
} }
}; };
@ -124,14 +124,14 @@ Client.prototype.init = function(client, ui) {
this.connect(); this.connect();
setInterval((function(elem) { setInterval((function(elem) {
return function() { return function() {
elem.connect(); elem.connect();
}; };
})(this), 10000); })(this), 10000);
setInterval((function(elem) { setInterval((function(elem) {
return function() { return function() {
elem.updateStatus(); elem.updateStatus();
}; };
})(this), 180000); })(this), 180000);
}; };

View file

@ -24,17 +24,17 @@ ContactList.prototype.insertContact = function(elem) {
var i, next = null; var i, next = null;
for (i in this.contacts) { for (i in this.contacts) {
if (this.contacts.hasOwnProperty(i)) { if (this.contacts.hasOwnProperty(i)) {
if (elem.name < this.contacts[i].name && (next === null || this.contacts[i].name < next.name)) { if (elem.name < this.contacts[i].name && (next === null || this.contacts[i].name < next.name)) {
next = this.contacts[i]; next = this.contacts[i];
} }
} }
} }
if (next !== null) { if (next !== null) {
this.lst.insertBefore(elem.li, next.li); this.lst.insertBefore(elem.li, next.li);
} else { } else {
this.lst.appendChild(elem.li); this.lst.appendChild(elem.li);
} }
}; };
@ -42,83 +42,84 @@ ContactList.prototype.addContact = function(name) {
var infos = {}, li = null, login = null, close = null; var infos = {}, li = null, login = null, close = null;
if (typeof this.contacts[name] === "undefined") { if (typeof this.contacts[name] === "undefined") {
infos = { infos = {
"name": name, "name": name,
"li": null, "li": null,
"avatar": null "avatar": null
}; };
li = document.createElement("li"); li = document.createElement("li");
$cs.avatars.get(infos.name, function(url) { $cs.avatars.get(infos.name, function(url) {
li.style.backgroundImage = "url('" + url + "')"; li.style.backgroundImage = "url('" + url + "')";
}); });
img = document.createElement("img"); img = document.createElement("img");
this.setImageStatus(img, "offline"); this.setImageStatus(img, "offline");
login = document.createElement("span"); login = document.createElement("span");
close = document.createElement("span"); close = document.createElement("span");
close.classList.add("remove"); close.classList.add("remove");
login.innerHTML = name; login.innerHTML = name;
close.innerHTML = '<img src="img/delcontact.png" alt="x" title="delete contact">'; close.innerHTML = '<img src="img/delcontact.png" alt="x" title="delete contact">';
li.appendChild(img); li.appendChild(img);
li.appendChild(login); li.appendChild(login);
li.appendChild(close); li.appendChild(close);
li.addEventListener("dblclick", function() { li.addEventListener("dblclick", function() {
var nel = $cs.ui.addNewTab(name); var nel = $cs.ui.addNewTab(name);
$cs.ui.hideAllTabs(); $cs.ui.hideAllTabs();
$cs.ui.showContent("chat-pannel"); $cs.ui.showContent("chat-pannel");
nel.show(); nel.show();
}); });
close.addEventListener("click", (function(elem) { close.addEventListener("click", (function(elem) {
return function() { return function() {
elem.rmContact(name); elem.rmContact(name);
}; };
})(this)); })(this));
infos.li = li; infos.li = li;
infos.img = img; infos.img = img;
this.contacts[name] = infos; this.contacts[name] = infos;
this.save(); this.save();
this.insertContact(infos); this.insertContact(infos);
} }
$cs.client.addContact(name); $cs.client.addContact(name);
}; };
ContactList.prototype.rmContact = function(name) { ContactList.prototype.rmContact = function(name) {
if (typeof this.contacts[name] !== "undefined") { if (typeof this.contacts[name] !== "undefined") {
this.lst.removeChild(this.contacts[name].li); this.lst.removeChild(this.contacts[name].li);
delete this.contacts[name]; delete this.contacts[name];
this.save(); this.save();
} }
}; };
ContactList.prototype.setImageStatus = function(img, status) { ContactList.prototype.setImageStatus = function(img, status) {
var status_list = {'default' : 'img/status/contact-connected.png', var status_list = {
'default' : 'img/status/contact-connected.png',
'offline': 'img/status/contact-disconnected.png', 'offline': 'img/status/contact-disconnected.png',
'disconnected': 'img/status/contact-disconnected.png', 'disconnected': 'img/status/contact-disconnected.png',
'deconnecte': 'img/status/contact-disconnected.png', 'deconnecte': 'img/status/contact-disconnected.png',
'deco': 'img/status/contact-disconnected.png', 'deco': 'img/status/contact-disconnected.png',
'hidden': 'img/status/contact-disconnected.png', 'hidden': 'img/status/contact-disconnected.png',
'cache': 'img/status/contact-disconnected.png', 'cache': 'img/status/contact-disconnected.png',
'away': 'img/status/contact-away.png', 'away': 'img/status/contact-away.png',
'inactif': 'img/status/contact-away.png', 'inactif': 'img/status/contact-away.png',
'absent': 'img/status/contact-away.png', 'absent': 'img/status/contact-away.png',
'idle': 'img/status/contact-away.png', 'idle': 'img/status/contact-away.png',
'locked': 'img/status/contact-away.png', 'locked': 'img/status/contact-away.png',
'lock': 'img/status/contact-away.png', 'lock': 'img/status/contact-away.png',
'dnd': 'img/status/contact-dnd.png', 'dnd': 'img/status/contact-dnd.png',
'occuped': 'img/status/contact-dnd.png', 'occuped': 'img/status/contact-dnd.png',
'npd': 'img/status/contact-dnd.png', 'npd': 'img/status/contact-dnd.png',
'occupe': 'img/status/contact-dnd.png' 'occupe': 'img/status/contact-dnd.png'
}; };
if (status_list.hasOwnProperty(status)) { if (status_list.hasOwnProperty(status)) {
img.src = status_list[status]; img.src = status_list[status];
} else { } else {
img.src = status_list.default; img.src = status_list.default;
} }
img.alt = status; img.alt = status;
img.title = status; img.title = status;
@ -126,8 +127,8 @@ ContactList.prototype.setImageStatus = function(img, status) {
ContactList.prototype.changeContactStatus = function(name, status) { ContactList.prototype.changeContactStatus = function(name, status) {
if (typeof this.contacts[name] !== "undefined") { if (typeof this.contacts[name] !== "undefined") {
this.setImageStatus(this.contacts[name].img, status); this.setImageStatus(this.contacts[name].img, status);
console.log(name + ' changed his status to ' + status); console.log(name + ' changed his status to ' + status);
} }
}; };
@ -135,9 +136,9 @@ ContactList.prototype.save = function() {
var i, data = {"contact_list": []}; var i, data = {"contact_list": []};
for (i in this.contacts) { for (i in this.contacts) {
if (this.contacts.hasOwnProperty(i)) { if (this.contacts.hasOwnProperty(i)) {
data.contact_list.push(i); data.contact_list.push(i);
} }
} }
data.contact_list.sort(); data.contact_list.sort();
this.storage.set(data, function() {}); this.storage.set(data, function() {});
@ -146,13 +147,13 @@ ContactList.prototype.save = function() {
ContactList.prototype.restore = function() { ContactList.prototype.restore = function() {
this.storage.get("contact_list", (function(elem) { this.storage.get("contact_list", (function(elem) {
return function(items) { return function(items) {
elem.contacts = {}; elem.contacts = {};
elem.lst.innerHTML = ""; elem.lst.innerHTML = "";
if (typeof items.contact_list !== "undefined") { if (typeof items.contact_list !== "undefined") {
for (i = items.contact_list.length - 1; i >= 0; --i) { for (i = items.contact_list.length - 1; i >= 0; --i) {
elem.addContact(items.contact_list[i]); elem.addContact(items.contact_list[i]);
} }
} }
}; };
})(this)); })(this));
}; };
@ -163,9 +164,9 @@ ContactList.prototype.init = function() {
this.restore(); this.restore();
this.save(); this.save();
add_btn.addEventListener("keyup", function(event) { add_btn.addEventListener("keyup", function(event) {
if (event.keyCode == 13 && this.value != "") { if (event.keyCode == 13 && this.value != "") {
$cs.contacts.addContact(this.value); $cs.contacts.addContact(this.value);
this.value = ""; this.value = "";
} }
}); });
}; };

View file

@ -23,77 +23,77 @@ var NsClient = function() {
this.action = {}; this.action = {};
this.action.ping = function(client, str) { this.action.ping = function(client, str) {
if (str.substr(0, 5) !== 'ping ') { if (str.substr(0, 5) !== 'ping ') {
return false; return false;
} }
client.socket.write(str, function(inf) {}); client.socket.write(str, function(inf) {});
return true; return true;
}; };
this.action.msg = (function(elem) { this.action.msg = (function(elem) {
return function(client, str) { return function(client, str) {
var mo = {}, mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| msg ([^ ]*)/.exec(str); var mo = {}, mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| msg ([^ ]*)/.exec(str);
if (mch === null) { if (mch === null) {
return false; return false;
} }
mo.socket = mch[1]; mo.socket = mch[1];
mo.login = mch[2]; mo.login = mch[2];
mo.host = mch[3]; mo.host = mch[3];
mo.location = elem.msgDecode(mch[4]); mo.location = elem.msgDecode(mch[4]);
mo.group = mch[5]; mo.group = mch[5];
mo.message = elem.msgDecode(mch[6]); mo.message = elem.msgDecode(mch[6]);
$cs.ui.addContentToTab(mo.login, mo); // TODO: FIX ME! $cs.ui.addContentToTab(mo.login, mo); // TODO: FIX ME!
return true; return true;
}; };
})(this); })(this);
this.action.status = (function(elem) { this.action.status = (function(elem) {
return function(client, str) { return function(client, str) {
var mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| state ([^ ]*):(\d+)/.exec(str); var mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| state ([^ ]*):(\d+)/.exec(str);
if (mch === null) { if (mch === null) {
return false; return false;
} }
$cs.contacts.changeContactStatus(mch[2], elem.msgDecode(mch[6])); // TODO: FIX ME! $cs.contacts.changeContactStatus(mch[2], elem.msgDecode(mch[6])); // TODO: FIX ME!
return true; return true;
}; };
})(this); })(this);
this.action.login_out = function(client, str) { this.action.login_out = function(client, str) {
var status = 'offline', mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| (login|logout)/.exec(str); var status = 'offline', mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| (login|logout)/.exec(str);
if (mch === null) { if (mch === null) {
return false; return false;
} }
if (mch[6] === 'login') { if (mch[6] === 'login') {
status = 'actif'; status = 'actif';
} }
$cs.contacts.changeContactStatus(mch[2], status); // TODO: FIX ME! $cs.contacts.changeContactStatus(mch[2], status); // TODO: FIX ME!
return true; return true;
}; };
this.action.who = (function(elem) { this.action.who = (function(elem) {
return function(client, str) { return function(client, str) {
var mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| who (\d+) (.*?) (.*?) (\d+) (\d+) (\d+) (\d+) (.*?) (.*?) (.*?) (.*?):(.*) (.*)/.exec(str); var mch = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| who (\d+) (.*?) (.*?) (\d+) (\d+) (\d+) (\d+) (.*?) (.*?) (.*?) (.*?):(.*) (.*)/.exec(str);
if (mch === null) { if (mch === null) {
return false; return false;
} }
$cs.contacts.changeContactStatus(mch[7], elem.msgDecode(mch[16])); // TODO: FIX ME! $cs.contacts.changeContactStatus(mch[7], elem.msgDecode(mch[16])); // TODO: FIX ME!
return true; return true;
}; };
})(this); })(this);
}; };
@ -101,66 +101,66 @@ NsClient.prototype.connect = function(client, callback) {
var login, pwd_socks; var login, pwd_socks;
if (!client.is_connected) { if (!client.is_connected) {
login = $cs.opts.get('login'); login = $cs.opts.get('login');
pwd_socks = $cs.opts.get('pwd_socks'); pwd_socks = $cs.opts.get('pwd_socks');
if (login !== null && pwd_socks !== null) { if (login !== null && pwd_socks !== null) {
client.socket.read(function(data) { client.socket.read(function(data) {
var auth = ''; var auth = '';
data = data.split(' '); data = data.split(' ');
auth = 'ext_user_log '; auth = 'ext_user_log ';
auth += login + ' '; auth += login + ' ';
auth += hex_md5(data[2] + '-' + data[3] + '/' + data[4] + pwd_socks) + ' '; auth += hex_md5(data[2] + '-' + data[3] + '/' + data[4] + pwd_socks) + ' ';
auth += 'chromesoul chromesoul\n'; auth += 'chromesoul chromesoul\n';
client.socket.write('auth_ag ext_user none none\n', function(inf) { client.socket.write('auth_ag ext_user none none\n', function(inf) {
client.socket.read(function(data) { client.socket.read(function(data) {
client.socket.write(auth, function(inf) { client.socket.write(auth, function(inf) {
client.socket.read(function(data) { client.socket.read(function(data) {
if (data === 'rep 002 -- cmd end') { if (data === 'rep 002 -- cmd end') {
client.is_connected = true; client.is_connected = true;
console.info('connected to the netsoul server'); console.info('connected to the netsoul server');
} else { } else {
console.error('authentication failure'); console.error('authentication failure');
} }
callback(); callback();
}); });
}); });
}); });
}); });
}); });
} else { } else {
callback(); callback();
} }
} else { } else {
callback(); callback();
} }
}; };
NsClient.prototype.disconnect = function(client) { NsClient.prototype.disconnect = function(client) {
var msg = 'user_cmd msg_user exit\n'; var msg = 'user_cmd msg_user exit\n';
client.socket.write(msg, function() { client.socket.write(msg, function() {
client.socket.disconnect(); client.socket.disconnect();
}); });
}; };
NsClient.prototype.changeStatus = function(client) { NsClient.prototype.changeStatus = function(client) {
if (client.is_connected) { if (client.is_connected) {
status_msg = 'user_cmd state '; status_msg = 'user_cmd state ';
status_msg += this.msgEncode(client.status) + ':'; status_msg += this.msgEncode(client.status) + ':';
status_msg += Math.round(new Date().getTime() / 1000) + '\n'; status_msg += Math.round(new Date().getTime() / 1000) + '\n';
client.socket.write(status_msg, function(inf) { client.socket.write(status_msg, function(inf) {
$cs.ui.onUserStatusChange(client.status); $cs.ui.onUserStatusChange(client.status);
}); });
} else { } else {
$cs.ui.onUserStatusChange(client.status); $cs.ui.onUserStatusChange(client.status);
} }
}; };
NsClient.prototype.recv = function(client, data) { NsClient.prototype.recv = function(client, data) {
for (var i = this.actions_enabled.length - 1; i >= 0; --i) { for (var i = this.actions_enabled.length - 1; i >= 0; --i) {
if (this.action[this.actions_enabled[i]](client, data)) { if (this.action[this.actions_enabled[i]](client, data)) {
break; break;
} }
} }
}; };
@ -173,8 +173,8 @@ NsClient.prototype.addContact = function(client, lst) {
var msg = 'user_cmd watch_log_user {' + lst.join(',') + '}\n'; var msg = 'user_cmd watch_log_user {' + lst.join(',') + '}\n';
client.socket.write(msg, function(inf) { client.socket.write(msg, function(inf) {
var msg = 'user_cmd who {' + lst.join(',') + '}\n'; var msg = 'user_cmd who {' + lst.join(',') + '}\n';
client.socket.write(msg, function(inf) {}); client.socket.write(msg, function(inf) {});
}); });
}; };
@ -184,27 +184,27 @@ NsClient.prototype.rmContact = function(client, name) {
NsClient.prototype.replacePairs = function(str, pairs) { NsClient.prototype.replacePairs = function(str, pairs) {
for (var i in pairs) { for (var i in pairs) {
if (pairs.hasOwnProperty(i)) { if (pairs.hasOwnProperty(i)) {
str = str.replace(pairs[i], i); str = str.replace(pairs[i], i);
} }
} }
return str; return str;
} }
NsClient.prototype.msgDecode = function(msg) { NsClient.prototype.msgDecode = function(msg) {
return this.replacePairs(unescape(msg), { return this.replacePairs(unescape(msg), {
'@': /%40/g, '@': /%40/g,
'*': /%2A/g, '*': /%2A/g,
'/': /%2F/g, '/': /%2F/g,
'+': /%2B/g '+': /%2B/g
}); });
}; };
NsClient.prototype.msgEncode = function(msg) { NsClient.prototype.msgEncode = function(msg) {
return this.replacePairs(escape(msg), { return this.replacePairs(escape(msg), {
'%40': /@/g, '%40': /@/g,
'%2A': /\*/g, '%2A': /\*/g,
'%2F': /\//g, '%2F': /\//g,
'%2B': /\+/g, '%2B': /\+/g,
}); });
}; };

View file

@ -21,8 +21,8 @@ var Nsui = function() {
Nsui.prototype.setReconnect = function(func) { Nsui.prototype.setReconnect = function(func) {
document.getElementById("user-status").addEventListener("click", function() { document.getElementById("user-status").addEventListener("click", function() {
func(); func();
$cs.contacts.restore(); $cs.contacts.restore();
}, false); }, false);
}; };
@ -30,13 +30,13 @@ Nsui.prototype.onUserStatusChange = function(new_status) {
var el = document.getElementById("user-status-img"); var el = document.getElementById("user-status-img");
if (el !== null) { if (el !== null) {
if (new_status !== "disconnected") { if (new_status !== "disconnected") {
el.src = 'img/status/me-connected.png'; el.src = 'img/status/me-connected.png';
} else { } else {
el.src = 'img/status/me-disconnected.png'; el.src = 'img/status/me-disconnected.png';
} }
el.alt = new_status; el.alt = new_status;
el.title = new_status; el.title = new_status;
} }
}; };
@ -52,17 +52,17 @@ Nsui.prototype.deleteTab = function(tab) {
var new_tab = this.getNextTab(tab.name); var new_tab = this.getNextTab(tab.name);
this.tab_lst = this.tab_lst.filter(function(element, index, array) { this.tab_lst = this.tab_lst.filter(function(element, index, array) {
return tab.name !== element.name; return tab.name !== element.name;
}); });
if (new_tab !== null) { if (new_tab !== null) {
new_tab.show(); new_tab.show();
} }
}; };
Nsui.prototype.hideAllTabs = function() { Nsui.prototype.hideAllTabs = function() {
for (i = this.tab_lst.length - 1; i >= 0; --i) { for (i = this.tab_lst.length - 1; i >= 0; --i) {
this.tab_lst[i].hide(); this.tab_lst[i].hide();
} }
}; };
@ -70,10 +70,10 @@ Nsui.prototype.getTabByName = function(name) {
var i, ret = null; var i, ret = null;
for (i = this.tab_lst.length - 1; i >= 0; --i) { for (i = this.tab_lst.length - 1; i >= 0; --i) {
if (this.tab_lst[i].name === name) { if (this.tab_lst[i].name === name) {
ret = this.tab_lst[i]; ret = this.tab_lst[i];
break ; break ;
} }
} }
return ret; return ret;
@ -83,13 +83,13 @@ Nsui.prototype.getNextTab = function(current_name) {
var i, prev = null; var i, prev = null;
for (i = this.tab_lst.length - 1; i >= 0; --i) { for (i = this.tab_lst.length - 1; i >= 0; --i) {
if (this.tab_lst[i].name === current_name) { if (this.tab_lst[i].name === current_name) {
if (prev === null && typeof this.tab_lst[i - 1] !== "undefined") { if (prev === null && typeof this.tab_lst[i - 1] !== "undefined") {
prev = this.tab_lst[i - 1]; prev = this.tab_lst[i - 1];
} }
break ; break ;
} }
prev = this.tab_lst[i]; prev = this.tab_lst[i];
} }
return prev; return prev;
@ -99,12 +99,12 @@ Nsui.prototype.addNewTab = function(tab_name) {
var tab = this.getTabByName(tab_name); var tab = this.getTabByName(tab_name);
if (tab === null) { if (tab === null) {
tab = this.createTab(tab_name); tab = this.createTab(tab_name);
} }
if (this.tab_lst.length <= 1) { if (this.tab_lst.length <= 1) {
tab.show(); tab.show();
} else if (!tab.isCurrent()) { } else if (!tab.isCurrent()) {
tab.setActive(); tab.setActive();
} }
return tab; return tab;
@ -114,46 +114,46 @@ Nsui.prototype.sendNotification = function(image, title, message) {
var notif; var notif;
if (message.lenght > 32) { if (message.lenght > 32) {
message = message.substr(0, 32) + "…"; message = message.substr(0, 32) + "…";
} }
if (typeof chrome.notifications !== "undefined") { if (typeof chrome.notifications !== "undefined") {
chrome.notifications.create( chrome.notifications.create(
'', '',
{ {
type: 'basic', type: 'basic',
iconUrl: image, iconUrl: image,
title: title, title: title,
message: message, message: message,
priority: 0 priority: 0
}, },
function(id) { function(id) {
setTimeout(function() { setTimeout(function() {
chrome.notifications.clear(id, function() {}); chrome.notifications.clear(id, function() {});
}, 5000); }, 5000);
} }
); );
chrome.notifications.onClicked.addListener(function(id) { chrome.notifications.onClicked.addListener(function(id) {
window.focus(); window.focus();
chrome.notifications.clear(id, function() {}); chrome.notifications.clear(id, function() {});
}); });
} else { } else {
notif = webkitNotifications.createNotification( notif = webkitNotifications.createNotification(
image, image,
title, title,
message message
); );
notif.onclick = function() { notif.onclick = function() {
window.focus(); window.focus();
this.cancel(); this.cancel();
}; };
notif.show(); notif.show();
setTimeout(function() { setTimeout(function() {
notif.cancel(); notif.cancel();
}, 5000); }, 5000);
} }
} }
@ -161,16 +161,16 @@ Nsui.prototype.addContentToTab = function(tab_name, content) {
var tab = null; var tab = null;
if ($cs.opts.get("enable_msg")) { if ($cs.opts.get("enable_msg")) {
tab = this.addNewTab(tab_name); tab = this.addNewTab(tab_name);
tab.appendMessage(content); tab.appendMessage(content);
if (!this.focus && typeof content.login !== "undefined" && content.login !== null && $cs.opts.get("enable_notif")) { if (!this.focus && typeof content.login !== "undefined" && content.login !== null && $cs.opts.get("enable_notif")) {
$cs.avatars.get(content.login, (function(elem) { $cs.avatars.get(content.login, (function(elem) {
return function(url) { return function(url) {
elem.sendNotification(url, content.login, content.message); elem.sendNotification(url, content.login, content.message);
}; };
})(this)); })(this));
} }
} }
}; };
@ -189,9 +189,9 @@ Nsui.prototype.formatMessage = function(msg) {
fmt += '<span class="chat-timestamp">' + this.formatInteger(dt.getHours(), 2) + ':' + this.formatInteger(dt.getMinutes(), 2) + ':' + this.formatInteger(dt.getSeconds(), 2) + '</span><div class="chat-message-body">'; fmt += '<span class="chat-timestamp">' + this.formatInteger(dt.getHours(), 2) + ':' + this.formatInteger(dt.getMinutes(), 2) + ':' + this.formatInteger(dt.getSeconds(), 2) + '</span><div class="chat-message-body">';
if (typeof msg.login !== "undefined" && msg.login !== null) { if (typeof msg.login !== "undefined" && msg.login !== null) {
fmt += '<span class="spk-oth">' + msg.login + ': </span>'; fmt += '<span class="spk-oth">' + msg.login + ': </span>';
} else { } else {
fmt += '<span class="spk-me">' + document.getElementById('login').value + ': </span>'; fmt += '<span class="spk-me">' + document.getElementById('login').value + ': </span>';
} }
fmt += this.sanitizeText(msg.message).replace(lnk_exp, '<a href="$1" target="_blank">$1</a>'); fmt += this.sanitizeText(msg.message).replace(lnk_exp, '<a href="$1" target="_blank">$1</a>');
@ -205,59 +205,59 @@ Nsui.prototype.sanitizeText = function(str) {
}; };
Nsui.prototype.currentTabStyle = function() { Nsui.prototype.currentTabStyle = function() {
$cs.opts.restore(); $cs.opts.restore();
if (this.tab_lst.length > 1) { if (this.tab_lst.length > 1) {
for (var tab in this.tab_lst) { for (var tab in this.tab_lst) {
if (tab.el_lst.classList.contains("tab-current")) { if (tab.el_lst.classList.contains("tab-current")) {
tab.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px"; tab.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
break; break;
} }
} }
} }
else if (this.tab_lst.length > 0) { else if (this.tab_lst.length > 0) {
this.tab_lst[0].chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px"; this.tab_lst[0].chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
} }
}; };
Nsui.prototype.showContent = function(part_id) { Nsui.prototype.showContent = function(part_id) {
var i, ctn_lst = ["config-pannel", "chat-pannel"]; var i, ctn_lst = ["config-pannel", "chat-pannel"];
if (part_id === "chat-pannel") { if (part_id === "chat-pannel") {
this.currentTabStyle(); this.currentTabStyle();
} }
for (i = ctn_lst.length - 1; i>= 0; --i) { for (i = ctn_lst.length - 1; i>= 0; --i) {
if (ctn_lst[i] === part_id) { if (ctn_lst[i] === part_id) {
document.getElementById(ctn_lst[i]).style.display = "block"; document.getElementById(ctn_lst[i]).style.display = "block";
} else { } else {
document.getElementById(ctn_lst[i]).style.display = "none"; document.getElementById(ctn_lst[i]).style.display = "none";
} }
} }
}; };
Nsui.prototype.switchContent = function(part_id, part_id_to) { Nsui.prototype.switchContent = function(part_id, part_id_to) {
if (document.getElementById(part_id).style.display !== "block") { if (document.getElementById(part_id).style.display !== "block") {
this.showContent(part_id); this.showContent(part_id);
} else { } else {
this.showContent(part_id_to); this.showContent(part_id_to);
} }
}; };
Nsui.prototype.init = function() { Nsui.prototype.init = function() {
window.onfocus = (function(elem) { window.onfocus = (function(elem) {
return function() { return function() {
elem.focus = true; elem.focus = true;
}; };
})(this); })(this);
window.onblur = (function(elem) { window.onblur = (function(elem) {
return function() { return function() {
elem.focus = false; elem.focus = false;
}; };
})(this); })(this);
document.getElementById("settings-btn").addEventListener("click", (function(elem) { document.getElementById("settings-btn").addEventListener("click", (function(elem) {
return function() { return function() {
elem.switchContent("config-pannel", "chat-pannel"); elem.switchContent("config-pannel", "chat-pannel");
}; };
})(this), false); })(this), false);
Tab.prototype.closeHandler = (function(elem) { Tab.prototype.closeHandler = (function(elem) {
@ -268,7 +268,7 @@ Nsui.prototype.init = function() {
Tab.prototype.showHandler = (function(elem) { Tab.prototype.showHandler = (function(elem) {
return function() { return function() {
elem.hideAllTabs(); elem.hideAllTabs();
}; };
})(this); })(this);

View file

@ -25,36 +25,36 @@ var OptionsManager = function() {
OptionsManager.prototype.types = { OptionsManager.prototype.types = {
"get": { "get": {
"text": function(elem) { "text": function(elem) {
return elem.value; return elem.value;
}, },
"password": function(elem) { "password": function(elem) {
return elem.value; return elem.value;
}, },
"checkbox": function(elem) { "checkbox": function(elem) {
return elem.checked; return elem.checked;
}, },
"number": function(elem) { "number": function(elem) {
return elem.value; return elem.value;
} }
}, },
"set": { "set": {
"text": function(elem, val) { "text": function(elem, val) {
elem.value = val; elem.value = val;
}, },
"password": function(elem, val) { "password": function(elem, val) {
elem.value = val; elem.value = val;
}, },
"checkbox": function(elem, val) { "checkbox": function(elem, val) {
if (!val) { if (!val) {
elem.removeAttribute('checked'); elem.removeAttribute('checked');
} else { } else {
elem.setAttribute('checked'); elem.setAttribute('checked');
} }
}, },
"number": function(elem, val) { "number": function(elem, val) {
elem.value = val; elem.value = val;
} }
} }
}; };
@ -62,7 +62,7 @@ OptionsManager.prototype.get = function(name) {
var ret = null; var ret = null;
if (typeof this.values[name] !== "undefined") { if (typeof this.values[name] !== "undefined") {
ret = this.values[name]; ret = this.values[name];
} }
return ret; return ret;
@ -76,47 +76,47 @@ OptionsManager.prototype.init = function() {
this.restore(); this.restore();
if (this.save !== null) { if (this.save !== null) {
this.save_btn.addEventListener("click", (function(elem) { this.save_btn.addEventListener("click", (function(elem) {
return function() { return function() {
elem.save(); elem.save();
}; };
})(this)); })(this));
} }
}; };
OptionsManager.prototype.savePart = function(pass) { OptionsManager.prototype.savePart = function(pass) {
var i = 0, data = {}, storage; var i = 0, data = {}, storage;
if (pass) { if (pass) {
storage = this.pass_storage; storage = this.pass_storage;
} else { } else {
storage = this.storage; storage = this.storage;
} }
if (this.opts !== null) { if (this.opts !== null) {
for (i = this.opts.length - 1; i >= 0; --i) { for (i = this.opts.length - 1; i >= 0; --i) {
if ((pass && (this.getElemType(this.opts[i]) === "password" || this.getElemType(this.opts[i]) === "text")) if ((pass && (this.getElemType(this.opts[i]) === "password" || this.getElemType(this.opts[i]) === "text"))
|| (!pass && this.getElemType(this.opts[i]) !== "password" && this.getElemType(this.opts[i]) !== "text")) { || (!pass && this.getElemType(this.opts[i]) !== "password" && this.getElemType(this.opts[i]) !== "text")) {
data[this.opts[i].id] = this.getElemValue(this.opts[i]); data[this.opts[i].id] = this.getElemValue(this.opts[i]);
this.values[this.opts[i].id] = data[this.opts[i].id]; this.values[this.opts[i].id] = data[this.opts[i].id];
} }
} }
storage.set(data, (function(elem) { storage.set(data, (function(elem) {
return function () { return function () {
if (elem !== null) { if (elem !== null) {
elem.innerHTML = "Options saved."; elem.innerHTML = "Options saved.";
setTimeout(function() { setTimeout(function() {
elem.innerHTML = ""; elem.innerHTML = "";
}, 3000); }, 3000);
} }
}; };
})(this.status)); })(this.status));
} }
}; };
OptionsManager.prototype.save = function() { OptionsManager.prototype.save = function() {
this.savePart(true); this.savePart(true);
this.savePart(false); this.savePart(false);
}; };
OptionsManager.prototype.restore = function() { OptionsManager.prototype.restore = function() {
@ -125,7 +125,7 @@ OptionsManager.prototype.restore = function() {
for (i in items) { for (i in items) {
el = document.getElementById(i); el = document.getElementById(i);
if (el !== null) { if (el !== null) {
elem.values[i] = items[i]; elem.values[i] = items[i];
elem.setElemValue(el, items[i]); elem.setElemValue(el, items[i]);
} }
} }
@ -144,7 +144,7 @@ OptionsManager.prototype.getElemValue = function(elem) {
var val = null, type = this.getElemType(elem); var val = null, type = this.getElemType(elem);
if (typeof this.types.get[type] !== "undefined") { if (typeof this.types.get[type] !== "undefined") {
val = this.types.get[type](elem); val = this.types.get[type](elem);
} }
return val; return val;
@ -154,7 +154,7 @@ OptionsManager.prototype.setElemValue = function(elem, val) {
var type = elem.getAttribute('type'); var type = elem.getAttribute('type');
if (typeof this.types.set[type] !== "undefined") { if (typeof this.types.set[type] !== "undefined") {
this.types.set[type](elem, val); this.types.set[type](elem, val);
} }
}; };

74
lib/tab.nsui.js Executable file → Normal file
View file

@ -22,7 +22,7 @@ var Tab = function(name) {
this.buff_len = 1000; this.buff_len = 1000;
this.history_index = 0; this.history_index = 0;
this.history = []; this.history = [];
$cs.opts.restore(); $cs.opts.restore();
this.initListElement(); this.initListElement();
this.initBodyElement(); this.initBodyElement();
}; };
@ -69,7 +69,7 @@ Tab.prototype.initBodyElement = function() {
this.chat_log = document.createElement("p"); this.chat_log = document.createElement("p");
this.chat_log.classList.add("chat-log"); this.chat_log.classList.add("chat-log");
this.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px"; this.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
this.el_body = document.createElement("div"); this.el_body = document.createElement("div");
this.el_body.classList.add("tab-body"); this.el_body.classList.add("tab-body");
@ -81,35 +81,35 @@ Tab.prototype.initBodyElement = function() {
this.chat_input.classList.add("chat-input"); this.chat_input.classList.add("chat-input");
this.chat_input.setAttribute("type", "text"); this.chat_input.setAttribute("type", "text");
this.chat_input.addEventListener("keyup", (function(elem) { this.chat_input.addEventListener("keyup", (function(elem) {
return function(event) { return function(event) {
var key_submit = 13, key_up = 38, key_down = 40; var key_submit = 13, key_up = 38, key_down = 40;
if (event.keyCode === key_submit && this.value != "") { if (event.keyCode === key_submit && this.value != "") {
var msg = this.value; var msg = this.value;
this.value = ""; this.value = "";
if (typeof $cs.client !== "undefined" && $cs.opts.get("enable_msg")) { if (typeof $cs.client !== "undefined" && $cs.opts.get("enable_msg")) {
$cs.client.speak(elem.name, msg); $cs.client.speak(elem.name, msg);
$cs.ui.addContentToTab(elem.name, {"message": msg}); $cs.ui.addContentToTab(elem.name, {"message": msg});
} else { } else {
console.error("chromesoul client not found"); console.error("chromesoul client not found");
} }
} else if (event.keyCode === key_up) { } else if (event.keyCode === key_up) {
if (elem.history_index < elem.history.length) { if (elem.history_index < elem.history.length) {
elem.history_index++; elem.history_index++;
this.value = elem.history[elem.history.length - elem.history_index]; this.value = elem.history[elem.history.length - elem.history_index];
} }
} else if (event.keyCode === key_down) { } else if (event.keyCode === key_down) {
if (elem.history_index > 0) { if (elem.history_index > 0) {
elem.history_index--; elem.history_index--;
if (elem.history_index > 0) { if (elem.history_index > 0) {
this.value = elem.history[elem.history.length - elem.history_index]; this.value = elem.history[elem.history.length - elem.history_index];
} else { } else {
this.value = ""; this.value = "";
} }
} }
} }
}; };
})(this), false); })(this), false);
chat_input_w.appendChild(this.chat_input); chat_input_w.appendChild(this.chat_input);
@ -120,7 +120,7 @@ Tab.prototype.initBodyElement = function() {
Tab.prototype.close = function() { Tab.prototype.close = function() {
if (typeof this.closeHandler !== "undefined") { if (typeof this.closeHandler !== "undefined") {
this.closeHandler(); this.closeHandler();
} }
this.wr_body.removeChild(this.el_body); this.wr_body.removeChild(this.el_body);
this.wr_lst.removeChild(this.el_lst); this.wr_lst.removeChild(this.el_lst);
@ -132,16 +132,16 @@ Tab.prototype.hide = function() {
}; };
Tab.prototype.show = function() { Tab.prototype.show = function() {
this.options.restore(); this.options.restore();
if (typeof this.showHandler !== "undefined") { if (typeof this.showHandler !== "undefined") {
this.showHandler(); this.showHandler();
} }
this.el_lst.classList.remove("tab-active"); this.el_lst.classList.remove("tab-active");
this.el_lst.classList.add("tab-current"); this.el_lst.classList.add("tab-current");
this.el_body.style.display = "block"; this.el_body.style.display = "block";
$cs.opts.restore() $cs.opts.restore()
this.chat_log.scrollTop = 42000; this.chat_log.scrollTop = 42000;
this.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px"; this.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
this.chat_input.focus(); this.chat_input.focus();
}; };
@ -155,10 +155,10 @@ Tab.prototype.setActive = function() {
Tab.prototype.flushText = function() { Tab.prototype.flushText = function() {
while (this.chat_log.children.length > this.buff_len) { while (this.chat_log.children.length > this.buff_len) {
this.chat_log.removeChild(this.chat_log.children[0]); this.chat_log.removeChild(this.chat_log.children[0]);
} }
while (this.history.length > this.buff_len) { while (this.history.length > this.buff_len) {
this.history.shift(); this.history.shift();
} }
}; };
@ -167,7 +167,7 @@ Tab.prototype.appendMessage = function(msg) {
this.chat_log.innerHTML += '<div class="chat-message">' + $cs.ui.formatMessage(msg) + '</div>'; this.chat_log.innerHTML += '<div class="chat-message">' + $cs.ui.formatMessage(msg) + '</div>';
if (!(typeof msg.login !== "undefined" && msg.login !== null)) { if (!(typeof msg.login !== "undefined" && msg.login !== null)) {
this.history.push(msg.message); this.history.push(msg.message);
} }
this.flushText(); this.flushText();
this.chat_log.scrollTop = 42 * this.buff_len; this.chat_log.scrollTop = 42 * this.buff_len;

View file

@ -22,17 +22,17 @@ var TxtSocket = function() {
TxtSocket.prototype.connect = function(host, port, callback) { TxtSocket.prototype.connect = function(host, port, callback) {
chrome.socket.create('tcp', {}, (function(elem) { chrome.socket.create('tcp', {}, (function(elem) {
return function(inf) { return function(inf) {
elem.socket_id = inf.socketId; elem.socket_id = inf.socketId;
chrome.socket.connect(elem.socket_id, host, port, callback); chrome.socket.connect(elem.socket_id, host, port, callback);
}; };
})(this)); })(this));
}; };
TxtSocket.prototype.disconnect = function() { TxtSocket.prototype.disconnect = function() {
if (this.socket_id !== null) { if (this.socket_id !== null) {
chrome.socket.disconnect(this.socket_id); chrome.socket.disconnect(this.socket_id);
chrome.socket.destroy(this.socket_id); chrome.socket.destroy(this.socket_id);
} }
}; };
@ -40,32 +40,32 @@ TxtSocket.prototype.read = function(callback) {
var tmp = '', offset = this.buffer.indexOf("\n"); var tmp = '', offset = this.buffer.indexOf("\n");
if (offset === -1) { if (offset === -1) {
chrome.socket.read(this.socket_id, (function(elem) { chrome.socket.read(this.socket_id, (function(elem) {
return function(rd_inf) { return function(rd_inf) {
if (rd_inf.resultCode > 0) { if (rd_inf.resultCode > 0) {
elem.buffer += elem.ab2str(rd_inf.data); elem.buffer += elem.ab2str(rd_inf.data);
elem.read(callback); elem.read(callback);
} else { } else {
elem.throwError({code: rd_inf.resultCode}); elem.throwError({code: rd_inf.resultCode});
} }
}; };
})(this)); })(this));
} else { } else {
tmp = this.buffer.substr(0, offset); tmp = this.buffer.substr(0, offset);
this.buffer = this.buffer.substr(offset + 1); this.buffer = this.buffer.substr(offset + 1);
callback(tmp); callback(tmp);
} }
}; };
TxtSocket.prototype.write = function(str, callback) { TxtSocket.prototype.write = function(str, callback) {
chrome.socket.write(this.socket_id, this.str2ab(str), (function(elem) { chrome.socket.write(this.socket_id, this.str2ab(str), (function(elem) {
return function(w_inf) { return function(w_inf) {
if (w_inf.bytesWritten >= 0) { if (w_inf.bytesWritten >= 0) {
callback(w_inf); callback(w_inf);
} else { } else {
elem.throwError({code: w_inf.bytesWritten}); elem.throwError({code: w_inf.bytesWritten});
} }
}; };
})(this)); })(this));
}; };
@ -83,7 +83,7 @@ TxtSocket.prototype.str2ab = function(str) {
var i = 0, buff = new ArrayBuffer(str.length), buff_v = new Uint8Array(buff); var i = 0, buff = new ArrayBuffer(str.length), buff_v = new Uint8Array(buff);
for (i = str.length - 1; i >= 0; --i) { for (i = str.length - 1; i >= 0; --i) {
buff_v[i] = str.charCodeAt(i); buff_v[i] = str.charCodeAt(i);
} }
return buff; return buff;

View file

@ -6,18 +6,18 @@
"offline_enabled": false, "offline_enabled": false,
"description": "Netsoul client for Google Chrome.", "description": "Netsoul client for Google Chrome.",
"icons": { "icons": {
"16": "icon_16.png", "16": "icon_16.png",
"128": "icon_128.png" "128": "icon_128.png"
}, },
"app": { "app": {
"background": { "background": {
"scripts": ["background.js"] "scripts": ["background.js"]
} }
}, },
"permissions": [ "permissions": [
"http://cdn.local.epitech.net/userprofil/profilview/", "http://cdn.local.epitech.net/userprofil/profilview/",
"storage", "storage",
"notifications", "notifications",
{"socket": ["tcp-connect:ns-server.epita.fr:4242"]} {"socket": ["tcp-connect:ns-server.epita.fr:4242"]}
] ]
} }