christiangenco / dbinbox

an inbox for your Dropbox
dbinbox.com
MIT License
285 stars 42 forks source link

`complete` callback #66

Open dy opened 8 years ago

dy commented 8 years ago

Hi @christiangenco!

We’re using dbinbox (basic plan) iframe for one of our projects and we want to add some notification and tracking if a file transfer is completed or at least the file is added to the queue by user. For now embedded iframe has no any sort of messaging, though in console there is an object being logged when a file is sent, but that happens within the iframe. Is it possible to add simple postMessage mechanism to notify about simple events like add, send, progress, complete? Is there any sense in making a PR for that?

Thanks.

christiangenco commented 8 years ago

Ooo, this is a good idea. To be clear: do you want this callback in javascript?

The codebase in github has diverged a lot from that actually deployed at http://dbinbox.com so a pull request would be tricky. What would be helpful on my end is if you wrote up what your ideal code would look like on your end for handling the callback, and I'll fiddle with things on my end to get that to work.

dy commented 8 years ago

Yes, exactly, a javascript callback. What I expect — in main index.html, where I include iframe, I do:

window.addEventListener('message', function (event) {
    if (event.origin !== 'https://dbinbox.com') return;
    if (event.data === 'add') console.log('file added');
    if (event.data === 'complete') console.log('file sent');
    event.source.postMessage('thanks, lad!', event.origin);
}, false);

Basically the behaviour from here.

christiangenco commented 8 years ago

Okay cool, I can do something like that. I'll send you an email when it's ready!

Christian.

On Thu, Aug 4, 2016 at 5:44 PM, Dima Yv notifications@github.com wrote:

Yes, exactly, a javascript callback. What I expect — in main index.html, where I include iframe, I do:

window.addEventListener('message',function(event) { if(event.origin !== 'https://dbinbox.com') return; if (event.data === 'add') console.log('file added'); if (event.data === 'complete') console.log('file sent'); event.source.postMessage('thanks, lad!', event.origin); },false);

Basically the behaviour from here http://stackoverflow.com/a/8849807/1052640.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/christiangenco/dbinbox/issues/66#issuecomment-237705926, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK8oV9D2LGzPWPf6TTcWe0yTYCJMUChks5qcmtCgaJpZM4Jb6Y1 .

dy commented 8 years ago

Great, thanks a lot!