Mercurial > summit-idp
changeset 66:a63f69858b68
Fixed hash check so it's called every 500ms rather than only on page load.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Tue, 29 Jun 2010 16:51:09 -0700 |
parents | 707345220707 |
children | 8be999c3d066 |
files | static-files/js/index.js |
diffstat | 1 files changed, 29 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/static-files/js/index.js Tue Jun 29 16:20:11 2010 -0700 +++ b/static-files/js/index.js Tue Jun 29 16:51:09 2010 -0700 @@ -186,27 +186,36 @@ }); }); - var verify = window.location.hash.match(/#verify=(.+)/); - if (verify && Config.value.state != "logged-in") { - verify = verify[1]; - Config.setValue({state: "wait-for-verify"}); - Ajax.postJSON( - "api/challenge/respond", - {token: verify}, - function(success, data) { + function checkHash() { + var verify = window.location.hash.match(/#verify=(.+)/); + if (verify) { + if (Config.value.state == "logged-in") { window.location.hash = ""; - updateUI(); - if (success) { - Config.setValue({state: "logged-in", - token: data.token, - userID: data.user_id, - email: data.email}); - } else { - $("#wait-for-verify .error").slideDown(); - } - }); - } else - updateUI(); + return; + } + verify = verify[1]; + Config.setValue({state: "wait-for-verify"}); + Ajax.postJSON( + "api/challenge/respond", + {token: verify}, + function(success, data) { + window.location.hash = ""; + updateUI(); + if (success) { + Config.setValue({state: "logged-in", + token: data.token, + userID: data.user_id, + email: data.email}); + } else { + $("#wait-for-verify .error").slideDown(); + } + }); + } + } + + checkHash(); + window.setInterval(checkHash, 500); + updateUI(); } $(window).ready(initUI);