Grammalecte  Diff

Differences From Artifact [72e7a7fc85]:

To Artifact [1348682312]:


65
66
67
68
69
70
71
72

73
74
75
76

77
78
79
80
81
82
83
84
65
66
67
68
69
70
71

72
73
74
75

76

77
78
79
80
81
82
83







-
+



-
+
-







function showError (e) {
    for (let sParam in e) {
        console.log(sParam);
        console.log(e[sParam]);
    }
}

onconnect = function(e) {
self.addEventListener("connect", function(e){
    console.log("START CONNECTION");
    xPort = e.ports[0];
    xListPort.push(xPort);

    xPort.addEventListener("message", function(e){
    xPort.onmessage = function (e) {
        console.log("[Sharedworker] ONMESSAGE");
        console.log(e);
        console.log(e.data[0]);
        let oParam = e.data[1];
        switch (e.data[0]) {
            case "init":
                loadGrammarChecker(oParam.sExtensionPath, oParam.sOptions, oParam.sContext);
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
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







+




+






-
-
-
+
+
+







            case "fullTests":
                fullTests();
                break;
            case "getListOfTokens":
                getListOfTokens(oParam.sText);
                break;
            case "other":
                console.log("[Sharedworker Other] Number of client: "+xListPort.length);
                console.log("Message to Other");
                toReply.Other("Message to Other");
                break;
            case "all":
                console.log("[Sharedworker All] Number of client: "+xListPort.length);
                console.log("Message to All");
                toReply.All("Message to All");
                break;
            default:
                console.log("Unknown command: " + showError(e.data[0]));
        }
    }
    //xPort.start();
}
    });
    xPort.start();
});

let toReply = {
    All: function(data){
        xListPort.forEach(function(client){
            client.postMessage(data);
        });
    },