Overview
Comment: | [tb] code cleaning |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tb | tbme |
Files: | files | file ages | folders |
SHA3-256: |
6a95ec929ec86f91d53f836f8614b58b |
User & Date: | olr on 2019-09-05 06:00:31 |
Other Links: | branch diff | manifest | tags |
Context
2019-09-05
| ||
06:56 | [tb] gc options: ui update check-in: 66ee6776cc user: olr tags: tb, tbme | |
06:00 | [tb] code cleaning check-in: 6a95ec929e user: olr tags: tb, tbme | |
2019-09-04
| ||
19:51 | [tb] useless console.log() check-in: 4cc1a6db6e user: olr tags: tb, tbme | |
Changes
Modified gc_lang/fr/mailext/content/spellchecker.js from [f4fc6376bf] to [ca575ac13b].
︙ | ︙ | |||
12 13 14 15 16 17 18 | https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Using_spell_checking_in_XUL https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/FileUtils.jsm */ "use strict"; | < < < < < < < | | < < < < < < < | > | < | 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 | https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Using_spell_checking_in_XUL https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/FileUtils.jsm */ "use strict"; const { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm"); const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm"); var oSpellControl = { xSCEngine: null, init: function () { if (this.xSCEngine === null) { try { let sSpellchecker = "@mozilla.org/spellchecker/myspell;1"; if ("@mozilla.org/spellchecker/hunspell;1" in Cc) { sSpellchecker = "@mozilla.org/spellchecker/hunspell;1"; } if ("@mozilla.org/spellchecker/engine;1" in Cc) { sSpellchecker = "@mozilla.org/spellchecker/engine;1"; } this.xSCEngine = Cc[sSpellchecker].getService(Ci.mozISpellCheckingEngine); } catch (e) { console.log("Can’t initiate the spellchecker."); console.error(e); } } }, getDictionariesList: function () { this.init(); try { let l = {}; let c = {}; this.xSCEngine.getDictionaryList(l, c); return l.value; } catch (e) { console.error(e); return []; } }, setDictionary: function (sLocale) { if (this.getDictionariesList().includes(sLocale)) { try { this.xSCEngine.dictionary = sLocale; // en-US, fr, etc. return true; } catch (e) { console.error(e); return false; } } else { console.log("Warning. No dictionary for locale: " + sLocale); console.log("Existing dictionaries: " + this.getDictionariesList().join(" | ")); } return false; }, check: function (sWord) { // todo: check in personal dict? try { return this.xSCEngine.check(sWord); } catch (e) { console.error(e); return false; } }, suggest: function (sWord) { try { let lSugg = {}; this.xSCEngine.suggest(sWord, lSugg, {}); return lSugg.value; // lSugg.value is a JavaScript Array of strings } catch (e) { console.error(e); return ['#Erreur.']; } }, addDirectory: function (sFolder) { try { let xNsiFolder = new FileUtils.File(sFolder); this.xSCEngine.addDirectory(xNsiFolder); } catch (e) { console.log("Unable to add directory: " + sFolder); console.error(e); } }, removeDirectory: function (sFolder) { // does not work but no exception raised (bug?) try { let xNsiFolder = new FileUtils.File(sFolder); this.xSCEngine.removeDirectory(xNsiFolder); } catch (e) { console.log("Unable to remove directory: " + sFolder); console.error(e); } }, setExtensionDictFolder: function (sDictName, bActivate) { try { let that = this; let sPath = "/content/dictionaries/" + sDictName; AddonManager.getAddonByID("French-GC-TB@grammalecte.net") .then(function (xAddon) { let xURI = xAddon.getResourceURI(sPath); //console.log(xURI); let sFolder = xURI.filePath; if (sFolder !== undefined) { if (/^\/[A-Z]:\//.test(sFolder)) { // Windows path sFolder = sFolder.slice(1).replace(/\//g, "\\\\"); } console.log("folder: " + sFolder); if (bActivate) { that.addDirectory(sFolder); } else { that.removeDirectory(sFolder); } } }); } catch (e) { console.log("Unable to add extension folder"); console.error(e); } } }; |