JMLX42 / cocorico

Cocorico is an open online voting platform powered by the blockchain.
https://cocorico.cc
MIT License
89 stars 21 forks source link

iframe postMessage data should include the value of the vote id #83

Closed thibauld closed 8 years ago

thibauld commented 8 years ago

I use several cocorico iframe on one page. Each of these iframe emit messages with postMessage but I am unable to trace back which iFrame emitted which message if the message does not include the id of the vote (1 vote <-> 1 iframe). Unless I am mistaken, I did not see the id of the vote in the voteComplete nor voteSuccess MessageEvents.

image

My first idea would be to pass voteComplete_[voteId] as data but I am definitely not a JS expert :)

JMLX42 commented 8 years ago

You can use the URL in e.currentTarget.window.document.location to get the vote id:

window.addEventListener('message', function(e) {
  var voteId = e.currentTarget.window.document.location.pathname.split('/')[3];

  // ...
});