Grammalecte  Check-in [8ea07ff627]

Overview
Comment:[tb] code cleaning: fix import (not necessary for TextDecoder, TextEncoder)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | tb
Files: files | file ages | folders
SHA3-256: 8ea07ff62713e1ce3b40ea8162cca796dd67d458d529759ddac8488ba7028929
User & Date: olr on 2018-08-07 12:40:29
Original Comment: [tb] code cleaning: fix import (not necessary for TextDecoder, TextEncoder
Other Links: manifest | tags
Context
2018-08-07
13:02
[tb] deprecated code check-in: 0ecc0883e5 user: olr tags: trunk, tb
12:40
[tb] code cleaning: fix import (not necessary for TextDecoder, TextEncoder) check-in: 8ea07ff627 user: olr tags: trunk, tb
09:03
[graphspell][js] console.log() for debugging check-in: 31905c2c2f user: olr tags: trunk, graphspell
Changes

Modified gc_lang/fr/tb/content/file_handler.js from [6a1367bab5] to [1ba36d2189].

1
2
3
4
5
6
7

8

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

7
8
9
10
11
12
13
14
15
16






-
+

+







// JavaScript

"use strict";

// Assuming that Cc, Ci and Cu are already loaded

const {TextDecoder, TextEncoder, OS} = Components.utils.import("resource://gre/modules/osfile.jsm", {});
//const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm", {});

ChromeUtils.import("resource://gre/modules/osfile.jsm")

const oFileHandler = {
    // https://developer.mozilla.org/fr/docs/Mozilla/JavaScript_code_modules/OSFile.jsm/OS.File_for_the_main_thread

    xDataFolder: null,

    prepareDataFolder: function () {
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
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







-

+
















-

+







    },

    loadFile: async function (sFilename) {
        if (!this.xDataFolder) {
            this.prepareDataFolder();
        }
        try {
            let xDecoder = new TextDecoder();
            let array = await OS.File.read(this.createPathFileName(sFilename));
            let xDecoder = new TextDecoder();
            return xDecoder.decode(array);
        }
        catch (e) {
            console.error(e);
            return null;
        }
    },

    loadAs: function (callback) {
        let xFilePicker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
        xFilePicker.init(window, "Charger fichier", Ci.nsIFilePicker.modeOpen);
        xFilePicker.appendFilters(Ci.nsIFilePicker.filterAll | Ci.nsIFilePicker.filterText);
        xFilePicker.open(async function (nReturnValue) {
            if (nReturnValue == Ci.nsIFilePicker.returnOK || nReturnValue == Ci.nsIFilePicker.returnReplace) {
                console.log(xFilePicker.file.path);
                try {
                    let xDecoder = new TextDecoder();
                    let array = await OS.File.read(xFilePicker.file.path);
                    let xDecoder = new TextDecoder();
                    callback(xDecoder.decode(array));
                }
                catch (e) {
                    console.error(e);
                    callback(null);
                }
            }

Modified gc_lang/fr/tb/content/overlay.js from [99ae888938] to [f448460dc2].

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
52
53
54
55
56
57
58

59
60
61
62
63
64
65







-







                        }
                    }
                },
                function (aReason) { console.log('Promise rejected - ', aReason); }
            ).catch(
                function (aCaught) { console.log('Promise Error - ', aCaught); }
            );

        }
    },
    fullTests: function () {
        console.log('Performing tests... Wait...');
        let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
        xPromise.then(
            function (aVal) {
583
584
585
586
587
588
589
590

591
592
593
594
595
596
597
582
583
584
585
586
587
588

589
590
591
592
593
594
595
596







-
+







    setOptionsInPanel: function (oOptions) {
        for (let sOptName in oOptions) {
            //console.log(sOptName + ":" + oOptions[sOptName]);
            if (document.getElementById(sOptName) !== null) {
                document.getElementById(sOptName).checked = oOptions[sOptName];
                if (sOptName.startsWith("o_group_")) {
                    this.switchGroup(sOptName);
                } 
                }
                if (document.getElementById("res_"+sOptName) !== null) {
                    document.getElementById("res_"+sOptName).textContent = "";
                }
            }
        }
    },
    switchGroup: function (sOptName) {
656
657
658
659
660
661
662
663

664
665
666
667
668
669
670
655
656
657
658
659
660
661

662
663
664
665
666
667
668
669







-
+







    applyOptions: function (sText) {
        try {
            const t0 = Date.now();
            //window.setCursor("wait"); // change pointer
            document.getElementById('progressbar').value = 0;
            document.getElementById('progressbar').max = 6;
            let n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0, n6 = 0, n7 = 0;
            

            // espaces surnuméraires
            if (document.getElementById("o_group_ssp").checked) {
                if (document.getElementById("o_end_of_paragraph").checked) {
                    [sText, n1] = this.formatText(sText, "end_of_paragraph");
                    document.getElementById('res_o_end_of_paragraph').textContent = n1;
                }
                if (document.getElementById("o_between_words").checked) {

Modified gc_lang/fr/tb/content/overlay.xul from [0101f0b174] to [7f8f4b47ad].

15
16
17
18
19
20
21
22
23


24
25
26
27
28
29
30
15
16
17
18
19
20
21


22
23
24
25
26
27
28
29
30







-
-
+
+







  <script type="application/javascript" src="editor.js"/>


  <stringbundleset id="stringbundleset">
    <stringbundle id="grammarchecker-strings" src="chrome://grammarchecker/locale/grammarchecker.properties"/>
  </stringbundleset>

  <commandset id="composerEditMenuItems" commandupdater="true" 
              events="focus" 
  <commandset id="composerEditMenuItems" commandupdater="true"
              events="focus"
              oncommandupdate="goUpdateCommand('cmd_grammar')">
    <command id="cmd_grammar" label="&grammarchecker.button.label;" oncommand="goDoCommand('cmd_grammar')"/>
  </commandset>

  <menupopup id="taskPopup">
    <!-- menu tools -->
    <menuitem id="grammarchecker-hello" command="cmd_grammar"/>
340
341
342
343
344
345
346
347

348
349
350
351
352
353
354
355
356
357
358
359
360
340
341
342
343
344
345
346

347
348
349
350
351
352
353
354
355
356
357
358
359
360







-
+














    <!--

      GRAMMAR CHECKING PANEL

    -->
    <splitter id="grammarchecker-splitter" state="collapsed" collapse="after"><grippy /></splitter>
    

    <vbox id="grammarchecker-panel">
      <dialogheader id="grammalecte-title" title="Grammalecte" description="&detected_mistakes;"/>
      <div id="grammalecte-errors"/>
      <hbox id="grammalecte-infobox">
        <label id="grammalecte-info" />
        <spacer flex="1" />
        <label id="closebutton" value="Fermer" onclick="oGrammarChecker.onClosePanel(event);" />
      </hbox>
    </vbox>

  </vbox>

</overlay>