From 0d8f850effd1a0d0460160d8bbe4dccb8f5f1462 Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Thu, 17 Feb 2011 13:40:13 -0800 Subject: After submitting changes, redirect to a GET link to allow reloads, session restores, better titles in tab list --- data/js/bug-page-mod.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'data/js/bug-page-mod.js') diff --git a/data/js/bug-page-mod.js b/data/js/bug-page-mod.js index 1e4341a..f800b0a 100644 --- a/data/js/bug-page-mod.js +++ b/data/js/bug-page-mod.js @@ -50,6 +50,19 @@ function tweakBugzilla(d) { if (/^Bug /.test(d.title)) d.title = d.title.slice(4); + // After POSTing, redirect with a GET back to the same bug + if (/\/(process_bug|attachment).cgi$/.test(d.location.href)) { + var bug = getBugId(d); + if (bug) { + d.body.innerHTML = "Changes submitted; reloading bug " + bug; + var url = d.location.href; + url = url.replace("process_bug.cgi", "show_bug.cgi"); + url = url.replace("attachment.cgi", "show_bug.cgi"); + url += "?id=" + bug; + d.location.href = url; + } + } + // Make the comment box bigger var commentBox = d.querySelector("#comment"); if (commentBox) @@ -430,6 +443,15 @@ function transformType(str, doc, old, new_) { return str; } +function getBugId(d) { + var classes = d.body.classList; + for (var i = 0; i < classes.length; i++) { + var m = /^bz_bug_(\d+)$/.exec(classes[i]); + return m[1]; + } + return undefined; +} + // new is a keyword, which makes this function uglier than I'd like function formatTransition(old, new_, type, doc, histDoc) { if (old.length) { -- cgit