Implement requestMsg() for client-server-communication to receive data from the server
Change-Id: I6399679449199a3f5e75ca47348b4fd875f08142
diff --git a/dev/js/src/plugin/server.js b/dev/js/src/plugin/server.js
index d5c9cfb..4aeb6b9 100644
--- a/dev/js/src/plugin/server.js
+++ b/dev/js/src/plugin/server.js
@@ -194,19 +194,19 @@
// TODO:
// This is a bit stupid to get the service window
- let iframe = services[id].load();
- let win = iframe.contentWindow;
+ let service = services[id];
+ let iframe = service.load();
// Create object to communicate the toggle state
// once the iframe is loaded.
iframe.onload = function () {
let sendToggle = {
setState : function (val) {
- win.postMessage({
+ service.sendMsg({
action: 'state',
key : onClick['state'],
value : val
- }, '*'); // TODO: Fix origin
+ });
}
};
@@ -404,6 +404,19 @@
};
};
break;
+
+ // Get information from the embedding platform
+ case 'get':
+ if (d.key == 'KQ') {
+ if (KorAP.koralQuery !== undefined) {
+ d["value"] = KorAP.koralQuery;
+ };
+ };
+ };
+
+ // data needs to be mirrored
+ if (d._id) {
+ service.sendMsg(d);
};
// TODO: