Fix patch js hack for Chrome

Chrome doesn't handle window.onload in the same way as other browsers, this compensates (and cleans up the JS a little)

Change-Id: If629155a6f305e5079f70db6d4045896fb43b483
This commit is contained in:
Andrew Hutchings 2012-03-29 17:17:06 +01:00
parent d4b851b171
commit 5b32163857

View File

@ -5,14 +5,11 @@
var hash = window.location.hash; var hash = window.location.hash;
return hash.substring(1); // remove # return hash.substring(1); // remove #
} }
window.onload = function() {
var hash_arr= getHash().split(","); window.onload = setTimeout(add_patch_tag, 1000)
if (hash_arr[0] == 'patch') { window.onhashchange = add_patch_tag
var elem = document.getElementById("gerrit_body");
elem.className = elem.className + ' patch'; function add_patch_tag() {
}
};
window.onhashchange = function() {
var hash_arr= getHash().split(","); var hash_arr= getHash().split(",");
var elem = document.getElementById("gerrit_body"); var elem = document.getElementById("gerrit_body");
if (hash_arr[0] == 'patch') { if (hash_arr[0] == 'patch') {
@ -20,7 +17,7 @@
} else { } else {
elem.className = elem.className.replace(' patch', ''); elem.className = elem.className.replace(' patch', '');
} }
}; }
</script> </script>
</div> </div>