Grammalecte  Check-in [09a2b4f200]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[fx] page for dictionaries (draft)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | comdic
Files: files | file ages | folders
SHA3-256:09a2b4f200a77af193eea72cc61e6a386be91bf3eb7116ae792328622bab1c03
User & Date: olr 2018-12-11 18:50:53
Context
2018-12-12
11:02
[fx] lexicon editor: ui rework -> save button always visible check-in: 46191a94a9 user: olr tags: comdic, fx
2018-12-11
18:50
[fx] page for dictionaries (draft) check-in: 09a2b4f200 user: olr tags: comdic, fx
2018-12-10
17:56
[fx] lexicon editor: launch from main panel and prevent multi-tabs check-in: 52dc932e38 user: olr tags: comdic, fx
Changes

Changes to gc_lang/fr/webext/background.js.

   220    220               break;
   221    221           case "openConjugueurTab":
   222    222               openConjugueurTab();
   223    223               break;
   224    224           case "openLexiconEditor":
   225    225               openLexiconEditor(dParam["dictionary"]);
   226    226               break;
          227  +        case "openDictionaries":
          228  +            openDictionaries();
   227    229           default:
   228    230               console.log("[background] Unknown command: " + sCommand);
   229    231               console.log(oRequest);
   230    232       }
   231    233       //sendResponse({response: "response from background script"});
   232    234   }
   233    235   
................................................................................
   361    363               openLexiconEditor();
   362    364               break;
   363    365       }
   364    366   });
   365    367   
   366    368   
   367    369   /*
   368         -    Lexicon editor tab
          370  +    Tabs
   369    371   */
   370    372   let nTabLexiconEditor = null;
          373  +let nTabDictionaries = null;
   371    374   
   372    375   browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) {
   373    376       if (nTabId === nTabLexiconEditor) {
   374    377           nTabLexiconEditor = null;
          378  +    }
          379  +    else if (nTabId === nTabDictionaries) {
          380  +        nTabDictionaries = null;
   375    381       }
   376    382   });
   377    383   
   378    384   
   379    385   /*
   380    386       Actions
   381    387   */
................................................................................
   407    413       }
   408    414   }
   409    415   
   410    416   function onLexiconEditorOpened (xTab) {
   411    417       //console.log(xTab);
   412    418       nTabLexiconEditor = xTab.id;
   413    419   }
          420  +
          421  +function openDictionaries () {
          422  +    if (nTabDictionaries === null) {
          423  +        if (bChrome) {
          424  +            browser.tabs.create({
          425  +                url: browser.extension.getURL("panel/dictionaries.html")
          426  +            }, onDictionariesOpened);
          427  +            return;
          428  +        }
          429  +        let xLexEditor = browser.tabs.create({
          430  +            url: browser.extension.getURL("panel/dictionaries.html")
          431  +        });
          432  +        xLexEditor.then(onDictionariesOpened, onError);
          433  +    }
          434  +}
          435  +
          436  +function onDictionariesOpened (xTab) {
          437  +    //console.log(xTab);
          438  +    nTabDictionaries = xTab.id;
          439  +}
   414    440   
   415    441   function openConjugueurTab () {
   416    442       if (bChrome) {
   417    443           browser.tabs.create({
   418    444               url: browser.extension.getURL("panel/conjugueur.html")
   419    445           });
   420    446           return;

Added gc_lang/fr/webext/panel/dictionaries.css.

            1  +/*
            2  +    CSS
            3  +*/

Added gc_lang/fr/webext/panel/dictionaries.html.

            1  +<!DOCTYPE HTML>
            2  +<html>
            3  +  <head>
            4  +    <link rel="stylesheet" type="text/css" href="dictionaries.css" />
            5  +    <title>Grammalecte · Dictionnaires communautaires</title>
            6  +    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
            7  +  </head>
            8  +
            9  +  <body>
           10  +
           11  +    <div class="inbox">
           12  +
           13  +      <h1>Dictionnaires communautaires</h1>
           14  +
           15  +      <div id="lexicon_page">
           16  +        <h2>Votre lexique</h2>
           17  +        <div class="big_block">
           18  +          <div id="save_button" class="fright">
           19  +            Enregistrer
           20  +          </div>
           21  +          <p>Nombre d’entrées : <span id="num_entries">0</span>.</p>
           22  +        </div>
           23  +
           24  +        <table id="lexicon_table">
           25  +
           26  +        </table>
           27  +      </div> <!-- #lexicon_page -->
           28  +
           29  +
           30  +    </div>
           31  +
           32  +
           33  +    <script src="../grammalecte/graphspell/helpers.js"></script>
           34  +    <script src="../grammalecte/graphspell/char_player.js"></script>
           35  +    <script src="../grammalecte/graphspell/str_transform.js"></script>
           36  +    <script src="../grammalecte/graphspell/dawg.js"></script>
           37  +    <script src="../grammalecte/graphspell/ibdawg.js"></script>
           38  +    <script src="../grammalecte/graphspell/spellchecker.js"></script>
           39  +    <script src="../grammalecte/fr/conj.js"></script>
           40  +    <script src="../grammalecte/fr/conj_generator.js"></script>
           41  +    <script src="../grammalecte/fr/lexicographe.js"></script>
           42  +    <script src="dictionaries.js"></script>
           43  +  </body>
           44  +
           45  +</html>

Added gc_lang/fr/webext/panel/dictionaries.js.

            1  +// JavaScript
            2  +
            3  +"use strict";
            4  +

Changes to gc_lang/fr/webext/panel/main.css.

   282    282       color: hsl(0, 10%, 96%);
   283    283   }
   284    284   #sc_options_page h2 {
   285    285       margin-top: 20px;
   286    286       font: normal 22px 'Yanone Kaffeesatz', "Oswald", "Liberation Sans Narrow", sans-serif;
   287    287       color: hsl(210, 50%, 50%);
   288    288   }
          289  +.button_row {
          290  +    display: flex;
          291  +    flex-direction: row-reverse;
          292  +    padding: 5px 0 0 0;
          293  +}
   289    294   .dic_button {
   290         -    float: right;
          295  +    margin-left: 10px;
   291    296       padding: 2px 10px;
   292    297       background-color: hsl(210, 50%, 50%);
   293    298       color: hsl(210, 10%, 96%);
   294    299       cursor: pointer;
   295    300       font-size: 14px;
   296    301       font-variant-caps: small-caps;
   297    302       border-radius: 3px;

Changes to gc_lang/fr/webext/panel/main.html.

   110    110               <h2>DICTIONNAIRES DE GRAMMALECTE</h2>
   111    111               <div class="option_section" id="main_dic_box">
   112    112                   <p><input type="checkbox" id="main_dic" data-dictionary="main" checked disabled="disabled" /> <label for="main_dic">Dictionnaire principal</label></p>
   113    113                   <p class="option_description">Environ 83 000 entrées, 500 000 flexions.<br/>Ni éditable, ni désactivable.<br/>Ce dictionnaire est créé à partir du dictionnaire orthographique pour Firefox et LibreOffice, conçu sur le <a id="link_grammalecte" class="link" data-url="http://grammalecte.net/home.php?prj=fr">site de Grammalecte</a>.</p>
   114    114               </div>
   115    115               <div class="option_section" id="community_dic_box">
   116    116                   <p><input type="checkbox" id="community_dic" data-dictionary="community" /> <label for="community_dic">Dictionnaire communautaire</label></p>
   117         -                <div class="dic_button" id="dic_community_button">Éditer</div>
   118    117                   <p class="option_description">Ce dictionnaire est créé et édité via l’éditeur lexical et est sauvegardé sur un serveur en ligne accessible à tous les membres.</p>
          118  +                <div class="button_row">
          119  +                  <div class="dic_button" id="dictionaries_button">Dictionnaires en ligne</div>
          120  +                  <div class="dic_button" id="dic_community_button">Éditer</div>
          121  +                </div>
   119    122               </div>
   120    123               <div class="option_section" id="personal_dic_box">
   121    124                   <p><input type="checkbox" id="personal_dic" data-dictionary="personal" /> <label for="personal_dic">Dictionnaire personnel</label></p>
   122         -                <div class="dic_button" id="dic_personal_button">Éditer</div>
   123    125                   <p class="option_description">Ce dictionnaire est créé et édité via l’éditeur lexical et n’est pas partagé.</p>
          126  +                <div class="button_row">
          127  +                  <div class="dic_button" id="dic_personal_button">Éditer</div>
          128  +                </div>
   124    129               </div>
   125    130             </div>
   126    131   
   127    132             <div id="hunspell_options" style="display: none; opacity: .25">
   128    133               <h2>DICTIONNAIRES HUNSPELL</h2>
   129    134               <p class="dictionaries_info">Les dictionnaires Hunspell ne sont utilisées que pour la correction orthographique proposée par Firefox (soulignement rouge).<br/><br/>Section inactive.<br/>Le système d’extension <i>WebExtension</i> ne propose pas encore d’interface de programmation pour le correcteur orthographique.</p>
   130    135               <div class="option_section" id="fr-FR-modern_box">

Changes to gc_lang/fr/webext/panel/main.js.

    73     73               }
    74     74               else if (xElem.id == "conj_button") {
    75     75                   browser.runtime.sendMessage({
    76     76                       sCommand: "openConjugueurTab",
    77     77                       dParam: {},
    78     78                       dInfo: {}
    79     79                   });
           80  +            }
           81  +            else if (xElem.id == "dictionaries_button") {
           82  +                browser.runtime.sendMessage({
           83  +                    sCommand: "openDictionaries",
           84  +                    dParam: { "dictionary": "__community__"},
           85  +                    dInfo: {}
           86  +                });
    80     87               }
    81     88               else if (xElem.id == "dic_community_button") {
    82     89                   browser.runtime.sendMessage({
    83     90                       sCommand: "openLexiconEditor",
    84     91                       dParam: { "dictionary": "__community__"},
    85     92                       dInfo: {}
    86     93                   });
................................................................................
   224    231   
   225    232   function displaySCOptions (dOptions) {
   226    233       if (!dOptions.hasOwnProperty("sc_options")) {
   227    234           console.log("no sc options found");
   228    235           return;
   229    236       }
   230    237       dOptions = dOptions.sc_options;
   231         -    //document.getElementById("extended_dic").checked = dOptions.extended_dic;
   232         -    document.getElementById("community_dic").checked = dOptions.community_dic;
          238  +    //document.getElementById("extended_dic").checked = dOptions.extended;
          239  +    document.getElementById("community_dic").checked = dOptions.community;
   233    240       document.getElementById("personal_dic").checked = dOptions.personal;
   234    241   }
   235    242   
   236    243   function storeSCOptions () {
   237    244       browser.storage.local.set({"sc_options": {
   238    245           extended: false,
   239    246           community: document.getElementById("community_dic").checked,