Dictionnaire
-
+
+
[—]
0 entrées
Exporter
-
-
+
+
+
Nouveau dictionnaire partagé
+
Nom : fr.x. · Description :
+
Créer
+
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
@@ -47,10 +47,20 @@
} else {
console.log("HTML node named <" + sElemId + "> not found.")
}
}
+function switchDisplay (sElemId, sDisplay="block") {
+ if (document.getElementById(sElemId)) {
+ if (document.getElementById(sElemId).style.display != "none") {
+ document.getElementById(sElemId).style.display = "none";
+ } else {
+ document.getElementById(sElemId).style.display = sDisplay;
+ }
+ }
+}
+
const oTabulations = {
lPage: ["lexicon_page", "add_page", "search_page", "info_page"],
@@ -531,17 +541,19 @@
}
return null;
},
saveDictionary: function (sName, oJSON) {
- console.log(sName);
if (sName == "__personal__") {
browser.runtime.sendMessage({ sCommand: "setDictionary", dParam: {sDictionary: "personal", oDict: oJSON}, dInfo: {} });
browser.storage.local.set({ "personal_dictionary": oJSON });
}
else {
this.oDictionaries[sName] = oJSON;
+ if (oJSON === null) {
+ delete this.oDictionaries[sName];
+ }
browser.storage.local.set({ "shared_dictionaries": this.oDictionaries });
}
}
}
@@ -617,10 +629,12 @@
listen: function () {
document.getElementById("dic_selector").addEventListener("change", () => {this.load(document.getElementById("dic_selector").value)}, false);
document.getElementById("save_button").addEventListener("click", () => { this.build(); }, false);
document.getElementById("export_button").addEventListener("click", () => { this.export(); }, false);
document.getElementById("import_input").addEventListener("change", () => { this.import(); }, false);
+ document.getElementById("new_dictionary_button").addEventListener("click", () => { switchDisplay("new_dictionary_section"); }, false);
+ document.getElementById("delete_dictionary_button").addEventListener("click", () => { this.delete() }, false);
},
build: function () {
let xProgressNode = document.getElementById("wait_progress");
let lEntry = oLexiconTable.getEntries();
@@ -634,10 +648,21 @@
oDictHandler.saveDictionary(this.sName, null);
this.setDictData(0, "[néant]");
}
hideElement("save_button");
},
+
+ delete: function () {
+ if (confirm("Voulez-vous effacer le dictionnaire “"+this.sName+"” ?")) {
+ oLexiconTable.clear();
+ oDictHandler.saveDictionary(this.sName, null);
+ this.setDictData(0, "[néant]");
+ if (this.sName != "__personal__") {
+ this.load("__personal__");
+ }
+ }
+ },
export: function () {
let xBlob = new Blob([ JSON.stringify(this.oIBDAWG.getJSON()) ], {type: 'application/json'});
let sURL = URL.createObjectURL(xBlob);
browser.downloads.download({ filename: "fr."+this.sName+".json", url: sURL, saveAs: true });