Grammalecte  Check-in [1eac03608e]

Overview
Comment:[fx] merge webext2
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext2_fix
Files: files | file ages | folders
SHA3-256: 1eac03608ed187de92cc326abc34ad89c32164cb611a88629ca5a3b2ef193e30
User & Date: IllusionPerdu on 2017-08-08 16:39:04
Other Links: branch diff | manifest | tags
Context
2017-08-08
16:49
[core][fr] change typeof(exports) before the require block check-in: 6c8ee6edcf user: IllusionPerdu tags: core, webext2_fix
16:39
[fx] merge webext2 check-in: 1eac03608e user: IllusionPerdu tags: fx, webext2_fix
13:08
[fx] attempt for the lexicographer (can’t work that way, it seems) check-in: fd7a9b5ca3 user: olr tags: fx, webext2
2017-08-06
12:14
[core][js] set echo as console.log if no require available check-in: 7cc552ce5a user: olr tags: core, webext2_fix
Changes

Modified gc_lang/fr/config.ini from [68082dbc1d] to [4666c13388].

27
28
29
30
31
32
33
34

35
36



37
38
39
40
41
42
43
27
28
29
30
31
32
33

34


35
36
37
38
39
40
41
42
43
44







-
+
-
-
+
+
+







oxt_version = 6.2
oxt_identifier = French.linguistic.resources.from.Dicollecte.by.OlivierR

# Firefox
fx_identifier = French-GC@grammalecte.net
fx_name = Grammalecte [fr]

fx_standard_path = C:\Program Files\Mozilla Firefox\firefox.exe
win_fx_dev_path = C:\Program Files\Firefox Developer Edition\firefox.exe
fx_beta_path = C:\Program Files\Mozilla Firefox Beta\firefox.exe
fx_nightly_path = C:\Program Files (x86)\Nightly\firefox.exe
win_fx_nightly_path = C:\Program Files (x86)\Nightly\firefox.exe
linux_fx_dev_path = /usr/bin/firefox
linux_fx_nightly_path = /usr/bin/firefox


# Thunderbird
tb_identifier = French-GC-TB@grammalecte.net
tb_name = Grammalecte [fr]
tb_debug_extension_path = _build/tb-debug.profile/extensions/French-GC-TB@grammalecte.net
# Set Thunderbird folder in your PATH variable

Modified gc_lang/fr/modules-js/conj.js from [ab8249cda2] to [abb72eabf4].

481
482
483
484
485
486
487
488

489
490
491
492
493
494
495
481
482
483
484
485
486
487

488
489
490
491
492
493
494
495







-
+







if (typeof(browser) !== 'undefined') {
    // WebExtension (but not in Worker)
    conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (typeof(require) !== 'undefined') {
    // Add-on SDK and Thunderbird
    let helpers = require("resource://grammalecte/helpers.js");
    conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
} else if (typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) === "undefined") {
} else if (typeof(self) !== 'undefined' && typeof(self.port) !== 'undefined' && typeof(self.port.on) !== "undefined") {
    // used within Firefox content script (conjugation panel).
    // can’t load JSON from here, so we do it in ui.js and send it here.
    self.port.on("provideConjData", function (sJSONData) {
        conj.init(sJSONData);
    });    
} else {
    console.log("Module conj non initialisé");

Modified gc_lang/fr/webext/background.js from [03c66ef198] to [f23ea27e23].

1
2
3
4







5
6
7


8
9
10
11
12
13
14
15
16
17
18
19
















20
21
22
23
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



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16












17
18
19
20
21
22
23
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




+
+
+
+
+
+
+



+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





-
-
-
-
-
-
-
-





-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// Background 

"use strict";

function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

/*
    Worker (separate thread to avoid freezing Firefox)
*/
let xGCEWorker = new Worker("gce_worker.js");

xGCEWorker.onmessage = function (e) {
    // https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
    try {
    switch (e.data[0]) {
        case "grammar_errors":
            console.log("GRAMMAR ERRORS");
            console.log(e.data[1].aGrammErr);
            break;
        case "spelling_and_grammar_errors":
            console.log("SPELLING AND GRAMMAR ERRORS");
            console.log(e.data[1].aSpellErr);
            console.log(e.data[1].aGrammErr);
            break;
        case "tests_results":
            console.log("TESTS RESULTS");
        switch (e.data[0]) {
            case "grammar_errors":
                console.log("GRAMMAR ERRORS");
                console.log(e.data[1].aGrammErr);
                browser.runtime.sendMessage({sCommand: "grammar_errors", aGrammErr: e.data[1].aGrammErr});
                break;
            case "spelling_and_grammar_errors":
                console.log("SPELLING AND GRAMMAR ERRORS");
                console.log(e.data[1].aSpellErr);
                console.log(e.data[1].aGrammErr);
                break;
            case "text_to_test_result":
                browser.runtime.sendMessage({sCommand: "text_to_test_result", sResult: e.data[1]});
                break;
            case "fulltests_result":
                console.log("TESTS RESULTS");
            console.log(e.data[1]);
            break;
        case "options":
            console.log("OPTIONS");
            console.log(e.data[1]);
            break;
        case "tokens":
            console.log("TOKENS");
            console.log(e.data[1]);
            break;
        case "error":
            console.log("ERROR");
            console.log(e.data[1]);
            break;
        default:
            console.log("Unknown command: " + e.data[0]);
                browser.runtime.sendMessage({sCommand: "fulltests_result", sResult: e.data[1]});
                break;
            case "options":
                console.log("OPTIONS");
                console.log(e.data[1]);
                break;
            case "tokens":
                console.log("TOKENS");
                console.log(e.data[1]);
                browser.browserAction.setPopup({popup: "panel/main.html"});
                browser.runtime.sendMessage({sCommand: "show_tokens", oResult: e.data[1]});
                break;
            case "error":
                console.log("ERROR");
                console.log(e.data[1]);
                break;
            default:
                console.log("Unknown command: " + e.data[0]);
        }
    }
    catch (e) {
        showError(e);
    }
};

xGCEWorker.postMessage(["init", {sExtensionPath: browser.extension.getURL("."), sOptions: "", sContext: "Firefox"}]);

xGCEWorker.postMessage(["parse", {sText: "J’en aie mare...", sCountry: "FR", bDebug: false, bContext: false}]);

xGCEWorker.postMessage(["parseAndSpellcheck", {sText: "C’est terribles, ils va tout perdrre.", sCountry: "FR", bDebug: false, bContext: false}]);

xGCEWorker.postMessage(["getListOfTokens", {sText: "J’en ai assez de ces âneries ! Merci bien. Ça suffira."}]);

xGCEWorker.postMessage(["fullTests"]);


/*
    Messages from the extension (not the Worker)
*/
function handleMessage (oRequest, xSender, sendResponse) {
  console.log(`[background] received: ${oRequest.content}`);
  sendResponse({response: "response from background script"});
    //console.log(xSender);
    switch(oRequest.sCommand) {
        case "parse":
            xGCEWorker.postMessage(["parse", {sText: oRequest.sText, sCountry: "FR", bDebug: false, bContext: false}]);
            break;
        case "parse_and_spellcheck":
            xGCEWorker.postMessage(["parseAndSpellcheck", {sText: oRequest.sText, sCountry: "FR", bDebug: false, bContext: false}]);
            break;
        case "get_list_of_tokens":
            xGCEWorker.postMessage(["getListOfTokens", {sText: oRequest.sText}]);
            break;
        case "text_to_test":
            xGCEWorker.postMessage(["textToTest", {sText: oRequest.sText, sCountry: "FR", bDebug: false, bContext: false}]);
            break;
        case "fulltests":
            xGCEWorker.postMessage(["fullTests"]);
            break;
    }
    //sendResponse({response: "response from background script"});
}

browser.runtime.onMessage.addListener(handleMessage);


/*
    Context Menu
*/
browser.contextMenus.create({
    id: "grammar_checking",
    title: "Correction grammaticale",
    contexts: ["selection", "editable", "page"]
});

browser.contextMenus.create({
    id: "lexicographer",
    title: "Lexicographe",
    contexts: ["selection", "editable", "page"]
});

browser.contextMenus.onClicked.addListener(function (xInfo, xTab) {
    // xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData
    // xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab
    console.log(xInfo);
    console.log(xTab);
    console.log("Item " + xInfo.menuItemId + " clicked in tab " + xTab.id);
    console.log("editable: " + xInfo.editable + " · selected: " + xInfo.selectionText);
    // confusing: no way to get the node where we click?!
    switch (xInfo.menuItemId) {
        case "grammar_checking":
            break;
        case "lexicographer":
            if (xInfo.selectionText) {
                xGCEWorker.postMessage(["getListOfTokens", {sText: xInfo.selectionText}]);
            }
            break;
    }
});

Modified gc_lang/fr/webext/gce_worker.js from [2ab933f7e3] to [3fc4168020].

81
82
83
84
85
86
87



88
89
90
91
92
93
94
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97







+
+
+







            break;
        case "setOption":
            setOption(oParam.sOptName, oParam.bValue);
            break;
        case "resetOptions":
            resetOptions();
            break;
        case "textToTest":
            textToTest(oParam.sText, oParam.sCountry, oParam.bDebug, oParam.bContext);
            break;
        case "fullTests":
            fullTests();
            break;
        case "getListOfTokens":
            getListOfTokens(oParam.sText);
            break;
        default:
168
169
170
171
172
173
174













175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214







+
+
+
+
+
+
+
+
+
+
+
+
+
















-
+







    console.log(mfsp.getMasForm("pointilleuse", false));
    console.log(phonet.getSimil("est"));
    let aRes = gc_engine.parse("Je suit...");
    for (let oErr of aRes) {
        console.log(text.getReadableError(oErr));
    }
}

function textToTest (sText, sCountry, bDebug, bContext) {
    if (!gc_engine || !oDict) {
        postMessage(["error", "# Error: grammar checker or dictionary not loaded."]);
        return;
    }
    let aGrammErr = gc_engine.parse(sText, sCountry, bDebug, bContext);
    let sMsg = "";
    for (let oErr of aGrammErr) {
        sMsg += text.getReadableError(oErr) + "\n";
    }
    postMessage(["text_to_test_result", sMsg]);
}

function fullTests (sGCOptions='{"nbsp":true, "esp":true, "unit":true, "num":true}') {
    if (!gc_engine || !oDict) {
        postMessage(["error", "# Error: grammar checker or dictionary not loaded."]);
        return;
    }
    let dMemoOptions = gc_engine.getOptions();
    if (sGCOptions) {
        gc_engine.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
    }
    let sMsg = "";
    for (let sRes of oTest.testParse()) {
        sMsg += sRes + "\n";
        console.log(sRes);
    }
    gc_engine.setOptions(dMemoOptions);
    postMessage(["tests_results", sMsg]);
    postMessage(["fulltests_result", sMsg]);
}


// Lexicographer

function getListOfTokens (sText) {
    try {

Modified gc_lang/fr/webext/manifest.json from [49413af971] to [ebaa1e6143].

37
38
39
40
41
42
43
44


45
46
37
38
39
40
41
42
43

44
45
46
47







-
+
+


    "grammalecte/_dictionaries/French.json",
    "grammalecte/fr/conj_data.json",
    "grammalecte/fr/mfsp_data.json",
    "grammalecte/fr/phonet_data.json",
    "grammalecte/fr/tests_data.json"
  ],
  "permissions": [
    "activeTab"
    "activeTab",
    "contextMenus"
  ]
}

Modified gc_lang/fr/webext/panel/main.css from [96ab586647] to [fb043edbec].

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
129
130


131
132
133
134


135
136
137
138


139
140
141
142


143
144
145
146


147
148
149
150
151
152
153
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
129
130
131
132
133
134


135
136
137
138
139


140
141
142
143


144
145
146
147


148
149
150
151


152
153
154
155


156
157
158
159
160
161
162
163
164







-
+




-
+

+
+
+
+
+
+
+


-
-
-
-




+
+
-
-
+
+
+
+
+
+

-



-
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+

-
-
-
-
+
+
+
+


+

+
+











-
-
+
+



-
-
+
+


-
-
+
+


-
-
+
+


-
-
+
+


-
-
+
+









/* Main classes */

html {
    box-sizing: border-box;
    width: 530px;
    height: 880px;
    height: 500px;
    font-family: "Trebuchet MS", "Liberation Sans", sans-serif;
}
body {
    width: 530px;
    height: 880px;
    height: 500px;
}
/* 
    Maximal height of a panel in WebExtention seems to be 500px.
    When going over this limit, a scrollbar appears which destructs the
    horizontal balance of elements.
    --> vertical scrolling is done with overflow in #page.
        #page must have the same height than body.
*/

#main {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    background-color: hsl(210, 0%, 100%);
    min-height: 100%;
}

#menu {
    position: fixed;
#left {
    width: 54px;
    left: 5px;
    width: 50px;
    border-left: solid 2px hsl(210, 0%, 70%);
    border-bottom: solid 2px hsl(210, 0%, 70%);
    border-right: solid 2px hsl(210, 0%, 70%);
    border-radius: 0 0 5px 5px;
    background-color: hsl(210, 10%, 96%);
    border-right: solid 1px hsl(210, 0%, 70%);
    color: hsl(210, 10%, 96%);
}
#logo {
  padding: 10px;
    padding: 10px;
}
#left li {
  padding: 10px 5px;
  border-bottom: 1px solid hsl(210, 10%, 90%);
  text-align: center;
  cursor: pointer;
  color: hsl(210, 10%, 50%);
  list-style-type: none;
#menu li {
    padding: 10px 5px;
    border-bottom: 1px solid hsl(210, 10%, 90%);
    text-align: center;
    cursor: pointer;
    color: hsl(210, 10%, 50%);
    list-style-type: none;
}
#left li:hover {
  background-color: hsl(210, 10%, 92%);

}
#menu li:hover {
    background-color: hsl(210, 10%, 92%);
}


#page {
    padding-left: 60px;
    background-color: hsl(210, 0%, 100%);
    height: 500px;
    overflow: auto;
}
#page h1 {
    margin: 0 0 10px 0;
    color: hsl(210, 70%, 70%);
    font: bold 30px 'Yanone Kaffeesatz', "Liberation Sans Narrow", sans-serif;
}
#page p {
    margin: 10px 0 5px 0;
}

#home_page {
  display: block;
  padding: 20px;
    display: block;
    padding: 20px;
}

#tf_page {
  display: none;
  padding: 20px;
    display: none;
    padding: 20px;
}
#gc_page {
  display: none;
  padding: 20px 20px 30px 20px;
    display: none;
    padding: 20px 20px 30px 20px;
}
#gc_options_page {
  display: none;
  padding: 20px;
    display: none;
    padding: 20px;
}
#sc_options_page {
  display: none;
  padding: 20px;
    display: none;
    padding: 20px;
}
#lxg_page {
  display: none;
  padding: 20px;
    display: none;
    padding: 20px;
}


/*
  Conjugueur page
*/

241
242
243
244
245
246
247
248
249

250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
252
253
254
255
256
257
258


259
260
261
262
263
264
265
266
267

268
269
270
271
272
273
274
275







-
-
+








-
+







*/

#test_page {
  display: none;
}
#test_cmd {
    padding: 15px;
    background-color: hsl(0, 0%, 92%);
    border-bottom: 1px solid hsl(0, 0%, 86%);
    border-bottom: 1px solid hsl(0, 0%, 90%);
}
#test_cmd textarea {
    width: 100%;
    border: 2px solid hsl(0, 0%, 89%);
    border-radius: 3px;
    resize: vertical;
}

#test_results {
#tests_result {
    padding: 15px;
    background-color: hsl(0, 0%, 96%);
}

#test_page .button {
    display: inline-block;
    padding: 5px 10px;

Modified gc_lang/fr/webext/panel/main.html from [9daf05e1d1] to [941cf34c14].

1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

30
31
32
33
34
35

36
37
38
39
40
41
42
1
2
3
4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44











-
-
+
+
















+






+







<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="main.css"/>
  </head>

  <body>
    <div id="main">

      <header id="left">
        <nav id="menu">
      <header id="menu">
        <nav>
          <header id="logo">
            <img src="../img/logo-32.png">
          </header>
          <ul>
            <li class="select" data-page="home_page"><i class="fa fa-home icon"></i> 1.</li>
            <li class="select" data-page="conj_page"><i class="fa fa-star icon"></i> CJ</li>
            <li class="select" data-page="tf_page"><i class="fa fa-photo icon"></i> TF</li>
            <li class="select" data-page="gc_page"><i class="fa fa-question-circle icon"></i> CG</li>
            <li class="select" data-page="gc_options_page"><i class="fa fa-coffee icon"></i> OP1</li>
            <li class="select" data-page="sc_options_page"><i class="fa fa-keyboard-o icon"></i> OP2</li>
            <li class="select" data-page="lxg_page"><i class="fa fa-keyboard-o icon"></i> LXG</li>
            <li class="select" data-page="test_page"><i class="fa fa-keyboard-o icon"></i> TST</li>
          </ul>
        </nav>
      </header> <!-- #left -->

      <!--
      <div id="movewindow">
        <div id="resize_h_bigger" class="arrow" style="border-radius: 2px 0 0 0">↓</div>
        <div id="resize_h_smaller" class="arrow">↑</div>
        <div id="resize_w_bigger" class="arrow">←</div>
        <div id="resize_w_smaller" class="arrow" style="border-radius: 0 0 0 2px">→</div>
      </div>
      -->

      <div id="page">

        <section id="home_page" class="page">
          <h1>GRAMMALECTE</h1>
        </section>

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
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







-
-
+
+

-
+
-






-
+







          <h1>LEXICOGRAPHE</h1>
          <div id="tokens_list"></div>
        </section>

        <section id="test_page" class="page">
          <div id="test_cmd">
            <h1>TESTS</h1>
            <textarea id="text" rows="10"></textarea>
            <div id="testall" class="button blue">Tests complets</div> <div id="parse" class="button green fright">Analyser</div>
            <textarea id="text_to_test" rows="10"></textarea>
            <div id="fulltests" class="button blue">Tests complets</div> <div id="text_to_test" class="button green fright">Analyser</div>
          </div>
          <div id="test_results">
          <pre id="tests_result"></pre>
          </div>
        </section>

        <section id="conj_page" class="page">
          <h1>CONJUGUEUR</h1>
          <p class="right" style="margin: 10px 30px 0 0">
            <input type="text" id="verb" name="verb" maxlength="40" value="" placeholder="entrez un verbe" autofocus />
            <a id="conjugate" href="#" onclick="return false;">Conjuguer</a>
            <a id="conjugate" href="#">Conjuguer</a>
          <p>

          <div class="clearer"></div>

          <p id="conj_smallnote" hidden>Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.</p>
          <p id="conj_options">
            <label for="oneg">Négation</label> <input type="checkbox" id="oneg" name="oneg" value="ON"  /> 

Modified gc_lang/fr/webext/panel/main.js from [72659a6e1c] to [def169afbc].

1

2
3
4
5


6
7
8
9
10
11
12
13
14

15
16

17
18
19

20
21
22
23

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

1




2
3









4


5



6




7



8



9
10



11
12

















13
14
15
16
17
18
19
20
21
22
23
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157




158
159
160
161
162
163




164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183




184
185



186
-
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
+
-
-
-
-
+
-
-
-
+
-
-
-
+
+
-
-
-


-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+


-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
-
-
-


// Main panel
function showError (e) {
  console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}


"use strict";
function beastNameToURL(beastName) {
  switch (beastName) {
    case "Frog":
      return browser.extension.getURL("beasts/frog.jpg");
    case "Snake":
      return browser.extension.getURL("beasts/snake.jpg");
    case "Turtle":
      return browser.extension.getURL("beasts/turtle.jpg");
  }

}

/*
window.addEventListener(
  "click",
  function (xEvent) {
    Common functions
    let xElem = xEvent.target;
    if (xElem.id) {
      if (xElem.id) {

*/
      }
    } else if (xElem.className === "select") {
      showPage(xElem.dataset.page);
function showError (e) {
    } else if (xElem.tagName === "A") {
      openURL(xElem.getAttribute("href"));
    }
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}
  },
  false
);

function showPage (sPageName) {
  try {
    // hide them all
    for (let xNodePage of document.getElementsByClassName("page")) {
      xNodePage.style.display = "None";
    }
    // show the one
    document.getElementById(sPageName).style.display = "block";
    sendMessage("Mon message");
    // specific modifications
    if (sPageName === "conj_page") {
      document.body.style.width = "600px";
      document.documentElement.style.width = "600px";
      document.getElementById("movewindow").style.display = "none";
    } else {
      document.body.style.width = "530px";
      document.documentElement.style.width = "530px";
      document.getElementById("movewindow").style.display = "block";
    try {
        // hide them all
        for (let xNodePage of document.getElementsByClassName("page")) {
            xNodePage.style.display = "none";
        }
        // show the selected one
        document.getElementById(sPageName).style.display = "block";
        // specific modifications
        if (sPageName === "conj_page") {
            document.body.style.width = "600px";
            document.documentElement.style.width = "600px";
            //document.getElementById("movewindow").style.display = "none";
        } else {
            document.body.style.width = "530px";
            document.documentElement.style.width = "530px";
            //document.getElementById("movewindow").style.display = "block";
        }
    }
    catch (e) {
        showError(e);
    }
}

function startWaitIcon () {
    document.getElementById("waiticon").hidden = false;
}

function stopWaitIcon () {
    document.getElementById("waiticon").hidden = true;
}


/*
    Events
*/
window.addEventListener(
    "click",
    function (xEvent) {
        let xElem = xEvent.target;
        if (xElem.id) {
            switch (xElem.id) {
                case "text_to_test":
                    browser.runtime.sendMessage({sCommand: "text_to_test", sText: document.getElementById("text_to_test").value});
                    break;
                case "fulltests":
                    document.getElementById("tests_result").textContent = "Veuillez patienter…";
                    browser.runtime.sendMessage({sCommand: "fulltests"});
                    break;
            }
        } else if (xElem.className === "select") {
            showPage(xElem.dataset.page);
        } else if (xElem.tagName === "A") {
            openURL(xElem.getAttribute("href"));
        }
    },
    false
);


/* 
    Message sender
    and response handling
*/
function handleResponse (oResponse) {
    console.log(`[Panel] received:`);
    console.log(oResponse);
}

function handleError (error) {
    console.log(`[Panel] Error:`);
    console.log(error);
}

function sendMessageAndWaitResponse (oData) {
    let xPromise = browser.runtime.sendMessage(oData);
    xPromise.then(handleResponse, handleError);  
}


/*
    Messages received
*/
function handleMessage (oMessage, xSender, sendResponse) {
    console.log(xSender);
    switch(oMessage.sCommand) {
        case "show_tokens":
            console.log("show tokens");
            addParagraphOfTokens(oMessage.oResult);
            break;
        case "text_to_test_result":
            showTestResult(oMessage.sResult);
            break;
        case "fulltests_result":
            showTestResult(oMessage.sResult);
            break;
    }
    sendResponse({sCommand: "none", sResult: "done"});
}

browser.runtime.onMessage.addListener(handleMessage);


/*

    DEDICATED FUNCTIONS 

*/


/*
    Test page
*/
function showTestResult (sText) {
    document.getElementById("tests_result").textContent = sText;
}


/*
    Lexicographer page
*/

function addSeparator (sText) {
    if (document.getElementById("tokens_list").textContent !== "") {
        let xElem = document.createElement("p");
        xElem.className = "separator";
        xElem.textContent = sText;
        document.getElementById("tokens_list").appendChild(xElem);
    }
}

function addMessage (sClass, sText) {
    let xNode = document.createElement("p");
    xNode.className = sClass;
    xNode.textContent = sText;
    document.getElementById("tokens_list").appendChild(xNode);
}

function addParagraphOfTokens (lElem) {
    try {
        let xNodeDiv = document.createElement("div");
        xNodeDiv.className = "paragraph";
        for (let oToken of lElem) {
            xNodeDiv.appendChild(createTokenNode(oToken));
        }
        document.getElementById("tokens_list").appendChild(xNodeDiv);
  }
  catch (e) {
    showError(e);
  }
    }
    catch (e) {
        showError(e);
    }
}

function handleResponse(message) {
  console.log(`[Panel] received: ${message.response}`);
}

function createTokenNode (oToken) {
    let xTokenNode = document.createElement("div");
    xTokenNode.className = "token " + oToken.sType;
    let xTokenValue = document.createElement("b");
    xTokenValue.className = oToken.sType;
    xTokenValue.textContent = oToken.sValue;
    xTokenNode.appendChild(xTokenValue);
    let xSep = document.createElement("s");
    xSep.textContent = " : ";
    xTokenNode.appendChild(xSep);
    if (oToken.aLabel.length === 1) {
        xTokenNode.appendChild(document.createTextNode(oToken.aLabel[0]));
    } else {
        let xTokenList = document.createElement("ul");
        for (let sLabel of oToken.aLabel) {
            let xTokenLine = document.createElement("li");
            xTokenLine.textContent = sLabel;
            xTokenList.appendChild(xTokenLine);
        }
        xTokenNode.appendChild(xTokenList);
function handleError(error) {
  console.log(`[Panel] Error: ${error}`);
}

    }
    return xTokenNode;
function sendMessage (sMessage) {
  let sending = browser.runtime.sendMessage({content: sMessage});
  sending.then(handleResponse, handleError);  
}

Modified make.py from [e6482fde8c] to [48fa32607c].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23







+







import traceback
import configparser
import datetime
import argparse
import importlib
import unittest
import json
import platform

from distutils import dir_util, file_util

import dialog_bundled
import compile_rules
import helpers

346
347
348
349
350
351
352

353

354
355
356

357

358
359
360
361
362
363
364
365
366
367
347
348
349
350
351
352
353
354

355
356
357
358
359

360
361
362
363
364
365
366
367
368
369
370







+
-
+



+
-
+










                    if xArgs.perf or xArgs.perf_memo:
                        hDst = open("./gc_lang/"+sLang+"/perf_memo.txt", "a", encoding="utf-8", newline="\n")  if xArgs.perf_memo  else None
                        tests.perf(sVersion, hDst)

            # Firefox
            if xArgs.firefox:
                with helpers.cd("_build/xpi/"+sLang):
                    spfFirefox = dVars['win_fx_dev_path']  if platform.system() == "Windows"  else dVars['linux_fx_dev_path']
                    os.system("jpm run -b nightly")
                    os.system('jpm run -b "' + spfFirefox + '"')

            if xArgs.web_ext:
                with helpers.cd("_build/webext/"+sLang):
                    spfFirefox = dVars['win_fx_nightly_path']  if platform.system() == "Windows"  else dVars['linux_fx_nightly_path']
                    os.system(r'web-ext run --firefox="' + dVars['fx_nightly_path'] + '" --browser-console')            
                    os.system(r'web-ext run --firefox="' + spfFirefox + '" --browser-console')            

            # Thunderbird
            if xArgs.thunderbird:
                os.system("thunderbird -jsconsole -P debug")
        else:
            print("Folder not found: gc_lang/"+sLang)


if __name__ == '__main__':
    main()