Permalink
Browse files

Use window.opener in popup rather than polling. Fixes #789

  • Loading branch information...
1 parent 3f7d78e commit 583ee967a9a44452febe5fe8ceae886908edaf4b @tmcw tmcw committed Feb 27, 2013
Showing with 10 additions and 28 deletions.
  1. +7 −11 js/id/oauth.js
  2. +3 −17 land.html
View
@@ -73,17 +73,13 @@ iD.OAuth = function(context) {
['top', screen.height / 2 - h / 2]].map(function(x) {
return x.join('=');
}).join(','),
- popup = window.open("about:blank", 'oauth_window', settings),
- locationCheck = window.setInterval(function() {
- if (popup.closed) return window.clearInterval(locationCheck);
- if (popup.location.search) {
- var search = popup.location.search,
- oauth_token = ohauth.stringQs(search.slice(1));
- popup.close();
- get_access_token(oauth_token);
- window.clearInterval(locationCheck);
- }
- }, 100);
+ popup = window.open("about:blank", 'oauth_window', settings);
+
+ window.authComplete = function(token) {
+ var oauth_token = ohauth.stringQs(token);
+ get_access_token(oauth_token);
+ delete window.authComplete;
+ };
function reqTokenDone(err, xhr) {
if (err) callback(err);
View
@@ -1,23 +1,9 @@
<!DOCTYPE html>
-<html>
- <head>
- <meta charset='utf-8'>
- <title>iD</title>
- <style>
- body {
- font:normal 20px/30px 'Helvetica Neue';
- text-align:center;
- }
- </style>
- </head>
+<html><head></head>
<body>
- <h1 id='land'></h1>
<script>
- var i = 2;
- window.setInterval(function() {
- document.getElementById('land').innerHTML = (new Array(i++)).join('.');
- i = (i > 8) ? 2 : i;
- }, 200);
+ opener.authComplete(window.location.search.slice(1));
+ window.close();
</script>
</body>
</html>

0 comments on commit 583ee96

Please sign in to comment.