Index: gc_lang/fr/webext/manifest.json
==================================================================
--- gc_lang/fr/webext/manifest.json
+++ gc_lang/fr/webext/manifest.json
@@ -125,10 +125,11 @@
],
"permissions": [
"activeTab",
"contextMenus",
+ "downloads",
"storage"
],
"chrome_settings_overrides": {
"search_provider": {
Index: gc_lang/fr/webext/panel/lex_editor.css
==================================================================
--- gc_lang/fr/webext/panel/lex_editor.css
+++ gc_lang/fr/webext/panel/lex_editor.css
@@ -160,11 +160,11 @@
#buttonline {
text-align: right;
}
-#add_to_dictionary {
+#add_to_lexicon {
display: inline-block;
padding: 7px 10px;
font-size: 20px;
background-color: hsl(0, 30%, 30%);
color: hsl(0, 30%, 60%);
@@ -172,10 +172,10 @@
text-transform: uppercase;
text-align: center;
text-decoration: none;
cursor: pointer;
}
-#add_to_dictionary:hover {
+#add_to_lexicon:hover {
background-color: hsl(0, 60%, 40%);
color: hsl(0, 60%, 70%);
box-shadow: 0 0 2px hsl(0, 60%, 50%);
}
Index: gc_lang/fr/webext/panel/lex_editor.html
==================================================================
--- gc_lang/fr/webext/panel/lex_editor.html
+++ gc_lang/fr/webext/panel/lex_editor.html
@@ -231,11 +231,11 @@
Index: gc_lang/fr/webext/panel/lex_editor.js
==================================================================
--- gc_lang/fr/webext/panel/lex_editor.js
+++ gc_lang/fr/webext/panel/lex_editor.js
@@ -46,11 +46,13 @@
document.getElementById("editor").addEventListener("click", onSelectionClick, false);
document.getElementById("word").addEventListener("keyup", onWrite, false);
document.getElementById("word2").addEventListener("keyup", onWrite2, false);
document.getElementById("lemma").addEventListener("keyup", () => { oFlex.update(); }, false);
-document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); } , false);
+document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false);
+document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false);
+
/*
ACTIONS
*/
@@ -269,9 +271,46 @@
} else {
oPage.hideActions();
}
},
- addToDictionary: function () {
+ addToLexicon: function () {
+ try {
+ oLexicon.addFlexions(this.lFlexion);
+ oLexicon.save();
+ }
+ catch (e) {
+ showError(e);
+ }
+ }
+}
+
+
+
+const oLexicon = {
+
+ lFlexion: [],
+
+ addFlexions: function (lFlex) {
+ for (let aFlex of lFlex) {
+ this.lFlexion.push(aFlex);
+ }
+ },
+
+ load: function () {
+
+ },
+
+ save: function () {
+ console.log(this.lFlexion);
+ },
+
+ build: function () {
+ return null;
+ },
+ export: function () {
+ let xBlob = new Blob(['{ "app": "grammalecte", "data": ["énum", "test"] }'], {type: 'application/json'});
+ let sURL = URL.createObjectURL(xBlob);
+ browser.downloads.download({ filename: "grammalecte_personal_dictionary.json", url: sURL, saveAs: true });
}
}