Last active
June 12, 2016 23:35
-
-
Save Abbe98/5b5f6db7ee8cbd5dd459ade6ec375b87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // create popup window | |
| var domain = 'http://wikimaps.mapwarper.net'; | |
| var myPopup = window.open(domain + '/u/auth/github?omniauth_window_type=newWindow&auth_origin_url=' + window.location.href, 'myWindow'); | |
| // periodical message sender | |
| var messenger = setInterval(function() { | |
| var message = 'requestCredentials'; | |
| //send the message and target URI | |
| myPopup.postMessage(message, domain); | |
| }, 500); | |
| // listen to response | |
| window.addEventListener('message', function(event) { | |
| // the message listener get's triggered by any URL make sure it's the right one | |
| if (event.origin !== domain) return; | |
| clearInterval(messenger); | |
| console.log(event.data); | |
| }, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment