Index: gc_lang/fr/webext/manifest.json
==================================================================
--- gc_lang/fr/webext/manifest.json
+++ gc_lang/fr/webext/manifest.json
@@ -130,10 +130,11 @@
"permissions": [
"*://localhost/*",
"*://dic.grammalecte.net/*",
"activeTab",
"contextMenus",
+ "cookies",
"downloads",
"storage"
],
"chrome_settings_overrides": {
Index: gc_lang/fr/webext/panel/dictionaries.css
==================================================================
--- gc_lang/fr/webext/panel/dictionaries.css
+++ gc_lang/fr/webext/panel/dictionaries.css
@@ -31,32 +31,54 @@
padding: 10px 30px 30px 30px;
background: hsl(0, 0%, 100%);
border: 2px solid hsl(210, 0%, 90%);
border-radius: 20px;
}
+
+
+#message_box {
+ display: none;
+ position: fixed;
+ top: 33%;
+ left: calc(50% - 325px);
+}
+#message {
+ display: inline-block;
+ padding: 1px 10px;
+ width: 600px;
+ background-color: hsl(0, 50%, 50%);
+ color: hsl(0, 50%, 98%);
+ border-style: solid;
+ border-width: 2px 0 2px 2px;
+ border-color: hsl(0, 50%, 40%);
+ border-radius: 3px 0 0 3px;
+}
+#message_close_button {
+ display: inline-block;
+ padding: 1px 5px;
+ background-color: hsl(0, 50%, 40%);
+ color: hsl(0, 90%, 90%);
+ border-style: solid;
+ border-width: 2px 2px 2px 0;
+ border-color: hsl(0, 50%, 30%);
+ border-radius: 0 3px 3px 0;
+ cursor: pointer;
+}
+
h1 {
margin: 5px 0 5px 0;
color: hsl(210, 50%, 50%);
- font: bold 30px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
- text-align: center;
+ font: bold 24px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}
h2 {
margin: 10px 0 2px 0;
color: hsl(0, 50%, 50%);
font: bold 20px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif;
}
-/*
- Main buttons
-*/
-
-ul {
- margin-left: 30px;
-}
-
input[type=text].large {
display: inline-block;
width: 250px;
padding: 5px 10px;
border: 2px solid hsl(0, 0%, 80%);
@@ -81,10 +103,25 @@
input[placeholder] {
color: hsl(0, 0%, 50%);
}
+
+#connect_panel {
+ background-color: hsl(210, 50%, 90%);
+ border-radius: 5px;
+ padding: 3px 10px;
+}
+#submit_button {
+ display: inline-block;
+ padding: 1px 5px;
+ background-color: hsl(210, 50%, 30%);
+ color: hsl(210, 0%, 100%);
+ border-radius: 3px;
+ cursor: pointer;
+}
+
.dic_button {
margin: 2px;
display: inline-block;
}
Index: gc_lang/fr/webext/panel/dictionaries.html
==================================================================
--- gc_lang/fr/webext/panel/dictionaries.html
+++ gc_lang/fr/webext/panel/dictionaries.html
@@ -6,42 +6,44 @@
-
-
-
Dictionnaires communautaires
-
-
-
-
Appliquer les modifications
-
Dictionnaires sélectionnés
-
[Aucun]
-
-
-
0 dictionnaires disponibles
-
-
-
-
+
+
+
+
Grammalecte · Dictionnaires communautaires
+
+
+
+
+
+ Connecté. Identifiants : ,
+
+
+
+
+
Dictionnaires sélectionnés
+
[Aucun]
+
+
Appliquer les modifications
+
0 dictionnaires disponibles
+
+
+
Index: gc_lang/fr/webext/panel/dictionaries.js
==================================================================
--- gc_lang/fr/webext/panel/dictionaries.js
+++ gc_lang/fr/webext/panel/dictionaries.js
@@ -56,42 +56,98 @@
let hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
}
-oConnect = {
+const oMessage = {
+ show: function (sMessage, nDelay=10000) {
+ document.getElementById("message").textContent = sMessage;
+ showElement("message_box");
+ window.setTimeout(this.close, nDelay);
+ },
+
+ listen: function () {
+ document.getElementById("message_close_button").addEventListener("click", (xEvent) => { this.close(); });
+ },
+
+ close: function () {
+ hideElement("message_box");
+ }
+}
+
+
+const oConnect = {
bConnected: false,
init: function () {
if (bChrome) {
- browser.storage.local.get("credentials", this._init().bind(this));
+ browser.cookies.getAll({ domain: "localhost" }, this._init.bind(this));
return;
}
- let xPromise = browser.storage.local.get("credentials");
+ let xPromise = browser.cookies.getAll({ domain: "localhost" });
xPromise.then(this._init.bind(this), showError);
},
- _init: function (oData) {
- if (oData.hasOwnProperty("credentials")) {
- hideElement("connect_form");
- showElement("connect_info");
+ _init: function (lData) {
+ for (let xCookie of lData) {
+ console.log(xCookie.name, xCookie.value);
this.bConnected = true;
}
- else {
+ if (this.bConnected) {
hideElement("connect_form");
showElement("connect_info");
}
+ else {
+ showElement("connect_form");
+ hideElement("connect_info");
+ }
},
listen: function () {
- document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect() });
+ document.getElementById("submit_button").addEventListener("click", (xEvent) => { this.connect(); });
},
connect: function () {
- let sEmail = document.getElementById("email").value;
- let sPassword = document.getElementById("password").value;
- console.log(sEmail, sPassword);
+ let xForm = new FormData(document.getElementById('connect_form'));
+ for (let [k, v] of xForm.entries()) {
+ console.log("* ", k, v);
+ }
+ oMessage.show("TEST");
+ fetch("http://localhost/connect/", {
+ method: "POST", // *GET, POST, PUT, DELETE, etc.
+ //mode: "cors", // no-cors, cors, *same-origin
+ //cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
+ /*headers: {
+ "Content-Type": "multipart/form-data", // text/plain, application/json
+ },*/
+ credentials: "omit", // include, *same-origin, omit
+ body: xForm
+ })
+ .then((response) => {
+ if (response.ok) {
+ for (let param in response) {
+ console.log(param, response[param]);
+ }
+ console.log(response.body);
+ return response.json();
+ } else {
+ for (let param in response) {
+ console.log(param, response[param]);
+ }
+ return null;
+ }
+ })
+ .then((response) => {
+ if (response) {
+ console.log(response);
+ } else {
+ console.log(response);
+ }
+ })
+ .catch((e) => {
+ showError(e);
+ });
}
}
class Table {
@@ -354,8 +410,10 @@
}
const oDicTable = new Table("dictionaries_table", ["Nom", "Entrées", "Description", "Date"], "wait_progress", "num_dic", false, true);
oDicTable.init();
+
+oMessage.listen();
oConnect.init();
oConnect.listen();