|
|
@ -27,12 +27,14 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener("message", function (event) {
|
|
|
|
window.addEventListener("message", function (event) {
|
|
|
|
|
|
|
|
var txid, command;
|
|
|
|
if (event && event.data) {
|
|
|
|
if (event && event.data) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
//console.log(JSON.parse(event.data));
|
|
|
|
//console.log(JSON.parse(event.data));
|
|
|
|
var msg = JSON.parse(event.data);
|
|
|
|
var msg = JSON.parse(event.data);
|
|
|
|
var command = msg.command;
|
|
|
|
command = msg.command;
|
|
|
|
var txid = msg.txid;
|
|
|
|
txid = msg.txid;
|
|
|
|
|
|
|
|
if (!txid) { return; }
|
|
|
|
COMMANDS[command](msg.content, function (response) {
|
|
|
|
COMMANDS[command](msg.content, function (response) {
|
|
|
|
// postMessage with same txid
|
|
|
|
// postMessage with same txid
|
|
|
|
postMessage({
|
|
|
|
postMessage({
|
|
|
@ -41,7 +43,11 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
postMessage({
|
|
|
|
|
|
|
|
txid: txid,
|
|
|
|
|
|
|
|
content: err,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
console.error(err, command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.error(event);
|
|
|
|
console.error(event);
|
|
|
|