Skip to content

Commit

Permalink
updating auto-submit form to hide element using CSS, moved
Browse files Browse the repository at this point in the history
auto-submitting javascript off body attribute and into a timeout to
verify availability of form in the DOM.
  • Loading branch information
Joshua Childs committed Mar 24, 2011
1 parent a086999 commit 973eb80
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/openid/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,23 @@ def Util.log(message)
end

def Util.auto_submit_html(form, title='OpenID transaction in progress')
return "
<html>
<head>
<title>#{title}</title>
</head>
<body onload='document.forms[0].submit();'>
#{form}
<script>
var elements = document.forms[0].elements;
for (var i = 0; i < elements.length; i++) {
elements[i].style.display = \"none\";
}
</script>
</body>
</html>
"
return "<html>
<head>
<title>#{title}</title>
<style>form { visibility: hidden }</style>
<script>
var server_proceed = setTimeout(function() {
if (typeof document.forms[0] == 'object') {
clearTimeout(server_proceed);
document.forms[0].submit();
}
}, 100);
</script>
</head>
<body>
#{form}
</body>
</html>"
end
end

Expand Down

0 comments on commit 973eb80

Please sign in to comment.