| OLD | NEW |
| 1 // Hide body content initially to minimize flashing. | 1 // Regenerate page if we are passed the "?regenerate" search param |
| 2 document.write('<style id="hider" type="text/css">'); | 2 // or if the user-agent is chrome AND the document is being served |
| 3 document.write('body { display:none!important; }'); | 3 // from the file:/// scheme. |
| 4 document.write('</style>'); | 4 if (window.location.search == "?regenerate" || |
| 5 (navigator.userAgent.indexOf("Chrome") > -1) && |
| 6 (window.location.href.match("^file:"))) { |
| 7 |
| 8 // Hide body content initially to minimize flashing. |
| 9 document.write('<style id="hider" type="text/css">'); |
| 10 document.write('body { display:none!important; }'); |
| 11 document.write('</style>'); |
| 5 | 12 |
| 6 window.onload = function() { | 13 window.onload = window.renderPage; |
| 7 // Regenerate page if we are passed the "?regenerate" search param | 14 |
| 8 // or if the user-agent is chrome AND the document is being served | 15 window.postRender = function() { |
| 9 // from the file:/// scheme. | 16 var elm = document.getElementById("hider"); |
| 10 if (window.location.search == "?regenerate" || | 17 elm.parentNode.removeChild(elm); |
| 11 navigator.userAgent.indexOf("Chrome") > -1) { | 18 |
| 12 window.renderPage(); | 19 // Since populating the page is done asynchronously, the DOM doesn't exist |
| 13 } else { | 20 // when the browser tries to resolve any #anchors in the URL. So we reset |
| 14 postRender(); | 21 // the URL once we're done, which forces the browser to scroll to the anchor |
| 22 // as it normally would. |
| 23 if (location.hash.length > 1) |
| 24 location.href = location.href; |
| 15 } | 25 } |
| 16 } | 26 } |
| 17 | |
| 18 function postRender() { | |
| 19 var elm = document.getElementById("hider"); | |
| 20 elm.parentNode.removeChild(elm); | |
| 21 | |
| 22 // Since populating the page is done asynchronously, the DOM doesn't exist | |
| 23 // when the browser tries to resolve any #anchors in the URL. So we reset the | |
| 24 // URL once we're done, which forces the browser to scroll to the anchor as it | |
| 25 // normally would. | |
| 26 if (location.hash.length > 1) | |
| 27 location.href = location.href; | |
| 28 } | |
| OLD | NEW |