Grammalecte  Check-in [be93ad702e]

Overview
Comment:[fx] console.log adjustments
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext2
Files: files | file ages | folders
SHA3-256: be93ad702ef781f7d369ef31e0a58e67026f9cc81b902128e652191e788536c3
User & Date: olr on 2017-08-31 04:31:06
Other Links: branch diff | manifest | tags
Context
2017-08-31
04:32
[fx] console.log adjustments check-in: 25bd31d7ed user: olr tags: fx, webext2
04:31
[fx] console.log adjustments check-in: be93ad702e user: olr tags: fx, webext2
04:20
[fx] rename xPort -> xGrammalectePort check-in: 485e91923f user: olr tags: fx, webext2
Changes

Modified gc_lang/fr/webext/background.js from [9d2c8ffd1c] to [d5244ca895].

1
2
3

4
5
6
7

8
9
10
11
12
13
14
// 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) {



>




>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 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) {
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
                browser.storage.local.set({"gc_options": result});
                break;
            case "setOptions":
            case "setOption":
                browser.storage.local.set({"gc_options": result});
                break;
            default:
                console.log("Unknown command: " + sActionDone);
                console.log(result);
        }
    }
    catch (e) {
        showError(e);
    }
};








|
|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
                browser.storage.local.set({"gc_options": result});
                break;
            case "setOptions":
            case "setOption":
                browser.storage.local.set({"gc_options": result});
                break;
            default:
                console.log("[background] Unknown command: " + sActionDone);
                console.log(e.data);
        }
    }
    catch (e) {
        showError(e);
    }
};

108
109
110
111
112
113
114

115
116
117
118
119
120
121
            xGCEWorker.postMessage(oRequest);
            break;
        case "openURL":
            browser.tabs.create({url: dParam.sURL});
            break;
        default:
            console.log("[background] Unknown command: " + sCommand);

    }
    //sendResponse({response: "response from background script"});
}

browser.runtime.onMessage.addListener(handleMessage);









>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
            xGCEWorker.postMessage(oRequest);
            break;
        case "openURL":
            browser.tabs.create({url: dParam.sURL});
            break;
        default:
            console.log("[background] Unknown command: " + sCommand);
            console.log(oRequest);
    }
    //sendResponse({response: "response from background script"});
}

browser.runtime.onMessage.addListener(handleMessage);


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
                openConjugueurWindow();
                break;
            default:
                console.log("[background] Unknown command: " + sCommand);
                console.log(oRequest);
        }
    });
    xPort.postMessage({sActionDone: "newId", result: iPortId});
}

browser.runtime.onConnect.addListener(handleConnexion);


/*
    Context Menu







|







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
                openConjugueurWindow();
                break;
            default:
                console.log("[background] Unknown command: " + sCommand);
                console.log(oRequest);
        }
    });
    //xPort.postMessage({sActionDone: "newId", result: iPortId});
}

browser.runtime.onConnect.addListener(handleConnexion);


/*
    Context Menu
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
    contexts: ["all"]
});


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);
    // confusing: no way to get the node where we click?!
    switch (xInfo.menuItemId) {
        case "parseAndSpellcheck":
            parseAndSpellcheckSelectedText(xTab.id, xInfo.selectionText);
            break;
        case "getListOfTokens": 
            getListOfTokensFromSelectedText(xTab.id, xInfo.selectionText);
            break;
        case "conjugueur_window":
            openConjugueurWindow();
            break;
        case "conjugueur_tab":
            openConjugueurTab();
            break;




    }    
});


/*
    Keyboard shortcuts
*/







|
<














>
>
>
>







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
215
216
217
218
219
220
    contexts: ["all"]
});


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
    

    // confusing: no way to get the node where we click?!
    switch (xInfo.menuItemId) {
        case "parseAndSpellcheck":
            parseAndSpellcheckSelectedText(xTab.id, xInfo.selectionText);
            break;
        case "getListOfTokens": 
            getListOfTokensFromSelectedText(xTab.id, xInfo.selectionText);
            break;
        case "conjugueur_window":
            openConjugueurWindow();
            break;
        case "conjugueur_tab":
            openConjugueurTab();
            break;
        default:
            console.log("[Background] Unknown menu id: " + xInfo.menuItemId);
            console.log(xInfo);
            console.log(xTab);
    }    
});


/*
    Keyboard shortcuts
*/
265
266
267
268
269
270
271
272
273
274
275
276
277
278
        width: 710,
        height: 980
    });
    xConjWindow.then(onCreated, onError);
}


function onCreated (windowInfo) {
    console.log(`Created window: ${windowInfo.id}`);
}

function onError (error) {
    console.log(`Error: ${error}`);
}







|
|





271
272
273
274
275
276
277
278
279
280
281
282
283
284
        width: 710,
        height: 980
    });
    xConjWindow.then(onCreated, onError);
}


function onCreated (xWindowInfo) {
    //console.log(`Created window: ${xWindowInfo.id}`);
}

function onError (error) {
    console.log(`Error: ${error}`);
}