diff --git a/.gitignore b/.gitignore
index 1896ae2..3265426 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
*~
test*
publish
-*.swp
diff --git a/CREDITS.md b/CREDITS.md
index 291abfd..80129b7 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -2,7 +2,6 @@
* [Rodolphe Breard](http://blog.uraniborg.net/) (development)
* [Romain Mardargent](http://ro-maen.com/) (design)
-* [SirBelga](https://github.com/SirBelga) (the mysterious merge-request guy who contributes to the code)
### Special thanks
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 952159b..0000000
--- a/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-NAME = chromesoul
-VERSION = $(shell cat manifest.json | /bin/grep '"version"' | cut -d '"' -f 4)
-SRC = background.js \
- chromesoul.css \
- chromesoul.html \
- chromesoul.js \
- CREDITS.md \icon_128.png \
- icon_16.png \
- img \
- lib \
- LICENCE.txt \
- manifest.json \
- README.md \
- third-party
-PUBDIR = publish
-ARCHIVE = $(PUBDIR)/chromesoul_$(VERSION).zip
-
-all:
- zip -r $(ARCHIVE) $(SRC)
- rm -f $(PUBDIR)/chromesoul.zip
- ln -s $(ARCHIVE) $(PUBDIR)/chromesoul.zip
diff --git a/PRIVACY.md b/PRIVACY.md
deleted file mode 100644
index 245c0d0..0000000
--- a/PRIVACY.md
+++ /dev/null
@@ -1,5 +0,0 @@
-## Privacy policy
-
-Chromesoul is an instant messaging client, hence you need to supply your identification information in order to connect to the server. Your password is stored in Chrome's local storage and is not shared with anyone else than the server you want to connect to. Your login and contact list are stored in Chrome's synced storage, which implies that if you are logged in with a Google account, it will be shared with others Chrome browsers where you are logged in with your Google account. You can read more about how Google encrypts the synced data: [set or change a sync passphrase](https://support.google.com/chrome/answer/1181035)
-
-In order to protect your privacy, Chromesoul does not log any conversation or activity and does not retrieve any analytic data. However, the server you connect to is not edited, maintained or affiliated in any way with Chromesoul and therefore may follow a different privacy policy.
diff --git a/background.js b/background.js
index d44220d..811910f 100644
--- a/background.js
+++ b/background.js
@@ -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
+ });
});
diff --git a/chromesoul.html b/chromesoul.html
index 6dff6f7..56ec90b 100644
--- a/chromesoul.html
+++ b/chromesoul.html
@@ -5,7 +5,7 @@
';
if (typeof msg.login !== "undefined" && msg.login !== null) {
- fmt += '
' + msg.login + ': ';
+ fmt += '
' + msg.login + ': ';
} else {
- fmt += '
' + document.getElementById('login').value + ': ';
+ fmt += '
' + document.getElementById('login').value + ': ';
}
fmt += this.sanitizeText(msg.message).replace(lnk_exp, '
$1');
@@ -205,59 +205,59 @@ Nsui.prototype.sanitizeText = function(str) {
};
Nsui.prototype.currentTabStyle = function() {
- $cs.opts.restore();
- if (this.tab_lst.length > 1) {
- for (var tab in this.tab_lst) {
- if (tab.el_lst.classList.contains("tab-current")) {
- tab.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
- break;
- }
- }
- }
- else if (this.tab_lst.length > 0) {
- this.tab_lst[0].chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
- }
+ $cs.opts.restore();
+ if (this.tab_lst.length > 1) {
+ for (var tab in this.tab_lst) {
+ if (tab.el_lst.classList.contains("tab-current")) {
+ tab.chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
+ break;
+ }
+ }
+ }
+ else if (this.tab_lst.length > 0) {
+ this.tab_lst[0].chat_log.style.fontSize = $cs.opts.values["chat-size"] + "px";
+ }
};
Nsui.prototype.showContent = function(part_id) {
var i, ctn_lst = ["config-pannel", "chat-pannel"];
- if (part_id === "chat-pannel") {
- this.currentTabStyle();
- }
+ if (part_id === "chat-pannel") {
+ this.currentTabStyle();
+ }
for (i = ctn_lst.length - 1; i>= 0; --i) {
- if (ctn_lst[i] === part_id) {
- document.getElementById(ctn_lst[i]).style.display = "block";
- } else {
- document.getElementById(ctn_lst[i]).style.display = "none";
- }
+ if (ctn_lst[i] === part_id) {
+ document.getElementById(ctn_lst[i]).style.display = "block";
+ } else {
+ document.getElementById(ctn_lst[i]).style.display = "none";
+ }
}
};
Nsui.prototype.switchContent = function(part_id, part_id_to) {
if (document.getElementById(part_id).style.display !== "block") {
- this.showContent(part_id);
+ this.showContent(part_id);
} else {
- this.showContent(part_id_to);
+ this.showContent(part_id_to);
}
};
Nsui.prototype.init = function() {
window.onfocus = (function(elem) {
- return function() {
- elem.focus = true;
- };
+ return function() {
+ elem.focus = true;
+ };
})(this);
window.onblur = (function(elem) {
- return function() {
- elem.focus = false;
- };
+ return function() {
+ elem.focus = false;
+ };
})(this);
document.getElementById("settings-btn").addEventListener("click", (function(elem) {
- return function() {
- elem.switchContent("config-pannel", "chat-pannel");
- };
+ return function() {
+ elem.switchContent("config-pannel", "chat-pannel");
+ };
})(this), false);
Tab.prototype.closeHandler = (function(elem) {
@@ -268,7 +268,7 @@ Nsui.prototype.init = function() {
Tab.prototype.showHandler = (function(elem) {
return function() {
- elem.hideAllTabs();
+ elem.hideAllTabs();
};
})(this);
diff --git a/lib/options.js b/lib/options.js
index 39c516c..500f195 100644
--- a/lib/options.js
+++ b/lib/options.js
@@ -25,36 +25,36 @@ var OptionsManager = function() {
OptionsManager.prototype.types = {
"get": {
- "text": function(elem) {
- return elem.value;
- },
- "password": function(elem) {
- return elem.value;
- },
- "checkbox": function(elem) {
- return elem.checked;
- },
- "number": function(elem) {
- return elem.value;
- }
+ "text": function(elem) {
+ return elem.value;
+ },
+ "password": function(elem) {
+ return elem.value;
+ },
+ "checkbox": function(elem) {
+ return elem.checked;
+ },
+ "number": function(elem) {
+ return elem.value;
+ }
},
"set": {
- "text": function(elem, val) {
- elem.value = val;
- },
- "password": function(elem, val) {
- elem.value = val;
- },
- "checkbox": function(elem, val) {
- if (!val) {
- elem.removeAttribute('checked');
- } else {
- elem.setAttribute('checked');
- }
- },
- "number": function(elem, val) {
- elem.value = val;
- }
+ "text": function(elem, val) {
+ elem.value = val;
+ },
+ "password": function(elem, val) {
+ elem.value = val;
+ },
+ "checkbox": function(elem, val) {
+ if (!val) {
+ elem.removeAttribute('checked');
+ } else {
+ elem.setAttribute('checked');
+ }
+ },
+ "number": function(elem, val) {
+ elem.value = val;
+ }
}
};
@@ -62,7 +62,7 @@ OptionsManager.prototype.get = function(name) {
var ret = null;
if (typeof this.values[name] !== "undefined") {
- ret = this.values[name];
+ ret = this.values[name];
}
return ret;
@@ -76,53 +76,47 @@ OptionsManager.prototype.init = function() {
this.restore();
if (this.save !== null) {
- this.save_btn.addEventListener("click", (function(elem) {
- return function() {
- elem.save();
- };
- })(this));
+ this.save_btn.addEventListener("click", (function(elem) {
+ return function() {
+ elem.save();
+ };
+ })(this));
}
-
- var chat_size = document.getElementById("chat-size");
- chat_size.addEventListener("change", function() {
- var body = document.getElementById("body-id");
- body.style.fontSize = chat_size.value + "px";
- }, false);
};
OptionsManager.prototype.savePart = function(pass) {
var i = 0, data = {}, storage;
- if (pass) {
- storage = this.pass_storage;
+ if (pass) {
+ storage = this.pass_storage;
} else {
- storage = this.storage;
+ storage = this.storage;
}
if (this.opts !== null) {
- for (i = this.opts.length - 1; i >= 0; --i) {
- 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")) {
- data[this.opts[i].id] = this.getElemValue(this.opts[i]);
- this.values[this.opts[i].id] = data[this.opts[i].id];
- }
- }
- storage.set(data, (function(elem) {
+ for (i = this.opts.length - 1; i >= 0; --i) {
+ 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")) {
+ data[this.opts[i].id] = this.getElemValue(this.opts[i]);
+ this.values[this.opts[i].id] = data[this.opts[i].id];
+ }
+ }
+ storage.set(data, (function(elem) {
return function () {
- if (elem !== null) {
+ if (elem !== null) {
elem.innerHTML = "Options saved.";
setTimeout(function() {
- elem.innerHTML = "";
+ elem.innerHTML = "";
}, 3000);
- }
+ }
};
- })(this.status));
+ })(this.status));
}
};
OptionsManager.prototype.save = function() {
this.savePart(true);
- this.savePart(false);
+ this.savePart(false);
};
OptionsManager.prototype.restore = function() {
@@ -131,7 +125,7 @@ OptionsManager.prototype.restore = function() {
for (i in items) {
el = document.getElementById(i);
if (el !== null) {
- elem.values[i] = items[i];
+ elem.values[i] = items[i];
elem.setElemValue(el, items[i]);
}
}
@@ -150,7 +144,7 @@ OptionsManager.prototype.getElemValue = function(elem) {
var val = null, type = this.getElemType(elem);
if (typeof this.types.get[type] !== "undefined") {
- val = this.types.get[type](elem);
+ val = this.types.get[type](elem);
}
return val;
@@ -160,7 +154,7 @@ OptionsManager.prototype.setElemValue = function(elem, val) {
var type = elem.getAttribute('type');
if (typeof this.types.set[type] !== "undefined") {
- this.types.set[type](elem, val);
+ this.types.set[type](elem, val);
}
};
diff --git a/lib/tab.nsui.js b/lib/tab.nsui.js
old mode 100644
new mode 100755
index c313140..9765ad7
--- a/lib/tab.nsui.js
+++ b/lib/tab.nsui.js
@@ -22,6 +22,7 @@ var Tab = function(name) {
this.buff_len = 1000;
this.history_index = 0;
this.history = [];
+ $cs.opts.restore();
this.initListElement();
this.initBodyElement();
};
@@ -62,53 +63,53 @@ Tab.prototype.initListElement = function() {
Tab.prototype.initBodyElement = function() {
var chat_input_w = document.createElement("div");
-
+
this.chat_input = document.createElement("input");
this.chat_input.placeholder = "Some text here...";
-
+
this.chat_log = document.createElement("p");
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.classList.add("tab-body");
this.el_body.id = this.name;
this.el_body.style.display = "none";
-
+
chat_input_w.classList.add("chat-input-wrapper");
-
+
this.chat_input.classList.add("chat-input");
this.chat_input.setAttribute("type", "text");
this.chat_input.addEventListener("keyup", (function(elem) {
- return function(event) {
- var key_submit = 13, key_up = 38, key_down = 40;
+ return function(event) {
+ var key_submit = 13, key_up = 38, key_down = 40;
- if (event.keyCode === key_submit && this.value != "") {
- var msg = this.value;
- this.value = "";
+ if (event.keyCode === key_submit && this.value != "") {
+ var msg = this.value;
+ this.value = "";
- if (typeof $cs.client !== "undefined" && $cs.opts.get("enable_msg")) {
- $cs.client.speak(elem.name, msg);
- $cs.ui.addContentToTab(elem.name, {"message": msg});
- } else {
- console.error("chromesoul client not found");
- }
- } else if (event.keyCode === key_up) {
- if (elem.history_index < elem.history.length) {
- elem.history_index++;
- this.value = elem.history[elem.history.length - elem.history_index];
- }
- } else if (event.keyCode === key_down) {
- if (elem.history_index > 0) {
- elem.history_index--;
- if (elem.history_index > 0) {
- this.value = elem.history[elem.history.length - elem.history_index];
- } else {
- this.value = "";
- }
- }
- }
- };
+ if (typeof $cs.client !== "undefined" && $cs.opts.get("enable_msg")) {
+ $cs.client.speak(elem.name, msg);
+ $cs.ui.addContentToTab(elem.name, {"message": msg});
+ } else {
+ console.error("chromesoul client not found");
+ }
+ } else if (event.keyCode === key_up) {
+ if (elem.history_index < elem.history.length) {
+ elem.history_index++;
+ this.value = elem.history[elem.history.length - elem.history_index];
+ }
+ } else if (event.keyCode === key_down) {
+ if (elem.history_index > 0) {
+ elem.history_index--;
+ if (elem.history_index > 0) {
+ this.value = elem.history[elem.history.length - elem.history_index];
+ } else {
+ this.value = "";
+ }
+ }
+ }
+ };
})(this), false);
chat_input_w.appendChild(this.chat_input);
@@ -119,7 +120,7 @@ Tab.prototype.initBodyElement = function() {
Tab.prototype.close = function() {
if (typeof this.closeHandler !== "undefined") {
- this.closeHandler();
+ this.closeHandler();
}
this.wr_body.removeChild(this.el_body);
this.wr_lst.removeChild(this.el_lst);
@@ -131,15 +132,16 @@ Tab.prototype.hide = function() {
};
Tab.prototype.show = function() {
+ this.options.restore();
if (typeof this.showHandler !== "undefined") {
- this.showHandler();
+ this.showHandler();
}
this.el_lst.classList.remove("tab-active");
this.el_lst.classList.add("tab-current");
this.el_body.style.display = "block";
- $cs.opts.restore()
+ $cs.opts.restore()
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();
};
@@ -153,19 +155,19 @@ Tab.prototype.setActive = function() {
Tab.prototype.flushText = function() {
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) {
- this.history.shift();
+ this.history.shift();
}
};
Tab.prototype.appendMessage = function(msg) {
this.history_index = 0;
this.chat_log.innerHTML += '
' + $cs.ui.formatMessage(msg) + '
';
-
+
if (!(typeof msg.login !== "undefined" && msg.login !== null)) {
- this.history.push(msg.message);
+ this.history.push(msg.message);
}
this.flushText();
this.chat_log.scrollTop = 42 * this.buff_len;
diff --git a/lib/txt_socket.js b/lib/txt_socket.js
index 1d9fcf6..0bea6b4 100644
--- a/lib/txt_socket.js
+++ b/lib/txt_socket.js
@@ -22,17 +22,17 @@ var TxtSocket = function() {
TxtSocket.prototype.connect = function(host, port, callback) {
chrome.socket.create('tcp', {}, (function(elem) {
- return function(inf) {
- elem.socket_id = inf.socketId;
- chrome.socket.connect(elem.socket_id, host, port, callback);
- };
+ return function(inf) {
+ elem.socket_id = inf.socketId;
+ chrome.socket.connect(elem.socket_id, host, port, callback);
+ };
})(this));
};
TxtSocket.prototype.disconnect = function() {
if (this.socket_id !== null) {
- chrome.socket.disconnect(this.socket_id);
- chrome.socket.destroy(this.socket_id);
+ chrome.socket.disconnect(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");
if (offset === -1) {
- chrome.socket.read(this.socket_id, (function(elem) {
- return function(rd_inf) {
- if (rd_inf.resultCode > 0) {
- elem.buffer += elem.ab2str(rd_inf.data);
- elem.read(callback);
- } else {
- elem.throwError({code: rd_inf.resultCode});
- }
- };
- })(this));
+ chrome.socket.read(this.socket_id, (function(elem) {
+ return function(rd_inf) {
+ if (rd_inf.resultCode > 0) {
+ elem.buffer += elem.ab2str(rd_inf.data);
+ elem.read(callback);
+ } else {
+ elem.throwError({code: rd_inf.resultCode});
+ }
+ };
+ })(this));
} else {
- tmp = this.buffer.substr(0, offset);
- this.buffer = this.buffer.substr(offset + 1);
- callback(tmp);
+ tmp = this.buffer.substr(0, offset);
+ this.buffer = this.buffer.substr(offset + 1);
+ callback(tmp);
}
};
TxtSocket.prototype.write = function(str, callback) {
chrome.socket.write(this.socket_id, this.str2ab(str), (function(elem) {
- return function(w_inf) {
- if (w_inf.bytesWritten >= 0) {
- callback(w_inf);
- } else {
- elem.throwError({code: w_inf.bytesWritten});
- }
- };
+ return function(w_inf) {
+ if (w_inf.bytesWritten >= 0) {
+ callback(w_inf);
+ } else {
+ elem.throwError({code: w_inf.bytesWritten});
+ }
+ };
})(this));
};
@@ -83,7 +83,7 @@ TxtSocket.prototype.str2ab = function(str) {
var i = 0, buff = new ArrayBuffer(str.length), buff_v = new Uint8Array(buff);
for (i = str.length - 1; i >= 0; --i) {
- buff_v[i] = str.charCodeAt(i);
+ buff_v[i] = str.charCodeAt(i);
}
return buff;
diff --git a/manifest.json b/manifest.json
index 4060ff5..e427cd9 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,23 +1,23 @@
{
"name": "Chromesoul",
- "version": "0.6.2",
+ "version": "0.5.7",
"minimum_chrome_version": "25",
"manifest_version": 2,
"offline_enabled": false,
"description": "Netsoul client for Google Chrome.",
"icons": {
- "16": "icon_16.png",
- "128": "icon_128.png"
+ "16": "icon_16.png",
+ "128": "icon_128.png"
},
"app": {
- "background": {
- "scripts": ["background.js"]
- }
+ "background": {
+ "scripts": ["background.js"]
+ }
},
"permissions": [
- "http://cdn.local.epitech.net/userprofil/profilview/",
- "storage",
- "notifications",
- {"socket": ["tcp-connect:ns-server.epita.fr:4242"]}
+ "http://cdn.local.epitech.net/userprofil/profilview/",
+ "storage",
+ "notifications",
+ {"socket": ["tcp-connect:ns-server.epita.fr:4242"]}
]
}