24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
function (xEvent) {
let xElem = xEvent.target;
if (xElem.id) {
// tests
if (xElem.id === "text_to_test_button") {
browser.runtime.sendMessage({
sCommand: "textToTest",
dParam: {sText: document.getElementById("text_to_test").value, sCountry: "FR", bDebug: true, bContext: false},
dInfo: {}
});
}
else if (xElem.id === "fulltests_button") {
document.getElementById("tests_result").textContent = "Veuillez patienter…";
browser.runtime.sendMessage({
sCommand: "fullTests",
dParam: {},
dInfo: {}
});
}
else if (xElem.id == "restart_worker") {
browser.runtime.sendMessage({
sCommand: "restartWorker",
dParam: { "nDelayLimit": 3 },
dInfo: {}
});
}
// grammar options
else if (xElem.id === "default_options_button") {
browser.runtime.sendMessage({
sCommand: "resetOptions",
dParam: {},
dInfo: {}
});
}
else if (xElem.id.startsWith("option_")) {
if (xElem.dataset.option) {
browser.runtime.sendMessage({
sCommand: "setOption",
dParam: {sOptName: xElem.dataset.option, bValue: xElem.checked},
dInfo: {}
});
}
}
// dictionaries options
else if (xElem.id.endsWith("_dic")) {
if (xElem.dataset.dictionary) {
storeSCOptions();
browser.runtime.sendMessage({
sCommand: "setDictionaryOnOff",
dParam: {sDictionary: xElem.dataset.dictionary, bActivate: xElem.checked},
dInfo: {}
});
}
}
else if (xElem.id.startsWith("spelling_")) {
updateSpellingChoiceUI(xElem.id);
let sMainDicName = document.getElementById(xElem.id).dataset.dicname;
browser.storage.local.set({"main_dic_name": sMainDicName});
browser.runtime.sendMessage({
sCommand: "setDictionary",
dParam: { sDictionary: "main", oDict: sMainDicName },
dInfo: { sExtPath: browser.extension.getURL("") }
});
}
// UI options
else if (xElem.id.startsWith("ui_option_")) {
storeUIOptions();
}
//
else if (xElem.id.startsWith("link_")) {
browser.tabs.create({url: xElem.dataset.url});
}
else if (xElem.id == "conj_button") {
browser.runtime.sendMessage({
sCommand: "openConjugueurTab",
dParam: {},
dInfo: {}
});
}
else if (xElem.id == "dictionaries_button") {
browser.runtime.sendMessage({
sCommand: "openDictionaries",
dParam: {},
dInfo: {}
});
}
else if (xElem.id == "dic_community_button") {
browser.runtime.sendMessage({
sCommand: "openLexiconEditor",
dParam: { "dictionary": "__community__"},
dInfo: {}
});
}
else if (xElem.id == "dic_personal_button") {
browser.runtime.sendMessage({
sCommand: "openLexiconEditor",
dParam: { "dictionary": "__personal__"},
dInfo: {}
});
}
// change UI page
} else if (xElem.className.startsWith("select")) {
showPage(xElem.dataset.page);
}/* else if (xElem.tagName === "A") {
openURL(xElem.getAttribute("href"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
function (xEvent) {
let xElem = xEvent.target;
if (xElem.id) {
// tests
if (xElem.id === "text_to_test_button") {
browser.runtime.sendMessage({
sCommand: "textToTest",
oParam: {sText: document.getElementById("text_to_test").value, sCountry: "FR", bDebug: true, bContext: false},
oInfo: {}
});
}
else if (xElem.id === "fulltests_button") {
document.getElementById("tests_result").textContent = "Veuillez patienter…";
browser.runtime.sendMessage({
sCommand: "fullTests",
oParam: {},
oInfo: {}
});
}
else if (xElem.id == "restart_worker") {
browser.runtime.sendMessage({
sCommand: "restartWorker",
oParam: { "nDelayLimit": 3 },
oInfo: {}
});
}
// grammar options
else if (xElem.id === "default_options_button") {
browser.runtime.sendMessage({
sCommand: "resetOptions",
oParam: {},
oInfo: {}
});
}
else if (xElem.id.startsWith("option_")) {
if (xElem.dataset.option) {
browser.runtime.sendMessage({
sCommand: "setOption",
oParam: {sOptName: xElem.dataset.option, bValue: xElem.checked},
oInfo: {}
});
}
}
// dictionaries options
else if (xElem.id.endsWith("_dic")) {
if (xElem.dataset.dictionary) {
storeSCOptions();
browser.runtime.sendMessage({
sCommand: "setDictionaryOnOff",
oParam: {sDictionary: xElem.dataset.dictionary, bActivate: xElem.checked},
oInfo: {}
});
}
}
else if (xElem.id.startsWith("spelling_")) {
updateSpellingChoiceUI(xElem.id);
let sMainDicName = document.getElementById(xElem.id).dataset.dicname;
browser.storage.local.set({"main_dic_name": sMainDicName});
browser.runtime.sendMessage({
sCommand: "setDictionary",
oParam: { sDictionary: "main", oDict: sMainDicName },
oInfo: { sExtPath: browser.extension.getURL("") }
});
}
// UI options
else if (xElem.id.startsWith("ui_option_")) {
storeUIOptions();
}
//
else if (xElem.id.startsWith("link_")) {
browser.tabs.create({url: xElem.dataset.url});
}
else if (xElem.id == "conj_button") {
browser.runtime.sendMessage({
sCommand: "openConjugueurTab",
oParam: {},
oInfo: {}
});
}
else if (xElem.id == "dictionaries_button") {
browser.runtime.sendMessage({
sCommand: "openDictionaries",
oParam: {},
oInfo: {}
});
}
else if (xElem.id == "dic_community_button") {
browser.runtime.sendMessage({
sCommand: "openLexiconEditor",
oParam: { "dictionary": "__community__"},
oInfo: {}
});
}
else if (xElem.id == "dic_personal_button") {
browser.runtime.sendMessage({
sCommand: "openLexiconEditor",
oParam: { "dictionary": "__personal__"},
oInfo: {}
});
}
// change UI page
} else if (xElem.className.startsWith("select")) {
showPage(xElem.dataset.page);
}/* else if (xElem.tagName === "A") {
openURL(xElem.getAttribute("href"));
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
}
/*
Messages received
*/
function handleMessage (oMessage, xSender, sendResponse) {
let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
switch(sActionDone) {
case "textToTest":
case "fullTests":
showTestResult(result);
break;
case "resetOptions":
displayGCOptions(result);
|
|
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
}
/*
Messages received
*/
function handleMessage (oMessage, xSender, sendResponse) {
let {sActionDone, result, oInfo, bEnd, bError} = oMessage;
switch(sActionDone) {
case "textToTest":
case "fullTests":
showTestResult(result);
break;
case "resetOptions":
displayGCOptions(result);
|