Grammalecte  Check-in [63625992e9]

Overview
Comment:[core][js] conj initialization
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | webext2
Files: files | file ages | folders
SHA3-256: 63625992e938d9825a345798171c14da57b5165f78c5a9d779fd9b8e7a2b2bce
User & Date: olr on 2017-08-03 08:24:29
Other Links: branch diff | manifest | tags
Context
2017-08-03
08:43
[core][js] mfsp initialization check-in: ef57c2c66f user: olr tags: core, webext2
08:24
[core][js] conj initialization check-in: 63625992e9 user: olr tags: core, webext2
2017-08-02
06:57
[core][js] remove let check-in: 9b5050cd48 user: olr tags: core, webext2
Changes

Modified gc_core/js/helpers.js from [60e583b5e8] to [a78485e9a7].

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
        // load ressources in workers (suggested by Mozilla extensions reviewers)
        // for more options have a look here: https://gist.github.com/Noitidart/ec1e6b9a593ec7e3efed
        // if not in workers, use sdk/data.load() instead
        try {
            let xRequest;
            if (typeof XMLHttpRequest !== "undefined") {
                xRequest = new XMLHttpRequest();
            }
            else {
                // JS bullshit again… necessary for Thunderbird
                let { Cc, Ci } = require("chrome");
                xRequest = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
                xRequest.QueryInterface(Ci.nsIXMLHttpRequest);
            }
            xRequest.open('GET', spf, false); // 3rd arg is false for synchronous, sync is acceptable in workers
            xRequest.send();







<
|







47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
        // load ressources in workers (suggested by Mozilla extensions reviewers)
        // for more options have a look here: https://gist.github.com/Noitidart/ec1e6b9a593ec7e3efed
        // if not in workers, use sdk/data.load() instead
        try {
            let xRequest;
            if (typeof XMLHttpRequest !== "undefined") {
                xRequest = new XMLHttpRequest();

            } else {
                // JS bullshit again… necessary for Thunderbird
                let { Cc, Ci } = require("chrome");
                xRequest = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
                xRequest.QueryInterface(Ci.nsIXMLHttpRequest);
            }
            xRequest.open('GET', spf, false); // 3rd arg is false for synchronous, sync is acceptable in workers
            xRequest.send();

Modified gc_lang/fr/modules-js/conj.js from [84d4cf88d5] to [a6c15a3f17].

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
475
476
477
478
479
480
481




482
483

484
485
486

487
488
489
490
491


492
493
494
495
496
497
498
// License: GPL 3

"use strict";

${map}


let helpers = null; // module not loaded in Firefox content script

const conj = {
    _lVtyp: null,
    _lTags: null,
    _dPatternConj: {},
    _dVerb: {},

    init: function (sJSONData) {
................................................................................
            return (this.dConj.get(":PQ").get(":Q3")) ? this.dConj.get(":PQ").get(":Q3") : this.dConj.get(":PQ").get(":Q1");
        }
        return (this.dConj.get(":PQ").get(":Q4")) ? this.dConj.get(":PQ").get(":Q4") : this.dConj.get(":PQ").get(":Q1");
    }
}






if (typeof(exports) !== 'undefined') {
    // used within Grammalecte library

    helpers = require("resource://grammalecte/helpers.js");
    conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
} else {

    // 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);
    });


}


if (typeof(exports) !== 'undefined') {
    exports._lVtyp = conj._lVtyp;
    exports._lTags = conj._lTags;
    exports._dPatternConj = conj._dPatternConj;







<
<







 







>
>
>
>
|
<
>
|

<
>





>
>







2
3
4
5
6
7
8


9
10
11
12
13
14
15
...
473
474
475
476
477
478
479
480
481
482
483
484

485
486
487

488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
// License: GPL 3

"use strict";

${map}




const conj = {
    _lVtyp: null,
    _lTags: null,
    _dPatternConj: {},
    _dVerb: {},

    init: function (sJSONData) {
................................................................................
            return (this.dConj.get(":PQ").get(":Q3")) ? this.dConj.get(":PQ").get(":Q3") : this.dConj.get(":PQ").get(":Q1");
        }
        return (this.dConj.get(":PQ").get(":Q4")) ? this.dConj.get(":PQ").get(":Q4") : this.dConj.get(":PQ").get(":Q1");
    }
}


// Initialization
if (typeof(browser) !== 'undefined') {
    // WebExtension
    conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (typeof(exports) !== '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') {
    // 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("Error: Impossible d’initialiser le module conj");
}


if (typeof(exports) !== 'undefined') {
    exports._lVtyp = conj._lVtyp;
    exports._lTags = conj._lTags;
    exports._dPatternConj = conj._dPatternConj;

Modified gc_lang/fr/webext/gce_worker.js from [245798772a] to [804f6b6cbe].

18
19
20
21
22
23
24


25
26
27
28
29
30
31
    — Edge 15 – behind the Experimental JavaScript Features setting in about:flags.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
*/

helpers.echo("START");




let oTokenizer = null;
let oDict = null;
let oLxg = null;

function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {







>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    — Edge 15 – behind the Experimental JavaScript Features setting in about:flags.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
*/

helpers.echo("START");

helpers.echo(conj.getConj("devenir", ":E", ":2s"));


let oTokenizer = null;
let oDict = null;
let oLxg = null;

function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {

Modified gc_lang/fr/webext/manifest.json from [f93daca40b] to [282aafe91a].

30
31
32
33
34
35
36

37
38
39
40
41
42
43

44
45
46
47
48
    "browser_style": false
  },
  "background": {
    "scripts": [
      "grammalecte/helpers.js",
      "grammalecte/text.js",
      "grammalecte/tokenizer.js",

      "gce_worker.js"
    ]
  },
  "web_accessible_resources": [
    "beasts/frog.jpg",
    "beasts/turtle.jpg",
    "beasts/snake.jpg"

  ],
  "permissions": [
    "activeTab"
  ]
}







>




|
|
|
>





30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    "browser_style": false
  },
  "background": {
    "scripts": [
      "grammalecte/helpers.js",
      "grammalecte/text.js",
      "grammalecte/tokenizer.js",
      "grammalecte/fr/conj.js",
      "gce_worker.js"
    ]
  },
  "web_accessible_resources": [
    "grammalecte/fr/conj_data.json",
    "grammalecte/fr/mfsp_data.json",
    "grammalecte/fr/phonet_data.json",
    "grammalecte/fr/tests_data.json"
  ],
  "permissions": [
    "activeTab"
  ]
}