diff --git a/tpl/footer.tpl b/tpl/footer.tpl index a1ed2f5..dbc2d57 100644 --- a/tpl/footer.tpl +++ b/tpl/footer.tpl @@ -1 +1,15 @@ -{if:waiting}<script>refreshTimeout = setTimeout(function() { window.location = window.location.href; }, 5000);</script>{endif}</body></html> +{if:waiting}<script> + var checkTimeout; + function check() { + checkTimeout = setTimeout(check, 1000); + var r = new XMLHttpRequest(); + r.onreadystatechange = function() { + if (r.readyState != 4 || r.status != 200) return; + s = JSON.parse(r.responseText); + if (!s["waiting"]) window.location = "{:prefix}/{:me.id}"; + } + r.open("GET", "{:prefix}/{:me.id}.json", true); + r.send(null); + } + check(); +</script>{endif}</body></html>