Disable button after click in UI.

This is to prevent users from accidentally sending multiple requests to
the server, causing race issues. It won't completely solve the problem,
as multiple users could still potentially hit the button at the same
time, but should mitigate it in the vast majority of cases.

Change-Id: Icd0bdf4a92aad2b28ab3333c7e0eb06f6291b262
diff --git a/src/main/resources/static/automerger.js b/src/main/resources/static/automerger.js
index 8c0f4d8..1c83a8d 100644
--- a/src/main/resources/static/automerger.js
+++ b/src/main/resources/static/automerger.js
@@ -31,7 +31,7 @@
             branchToCheckbox[branch] = c.label(checkbox, branch);
         });
 
-        //Add checkboxes to box for each downstream branch
+        // Add checkboxes to box for each downstream branch
         var checkboxes = [];
         Object.keys(branchToCheckbox).forEach(function(branch) {
             checkboxes.push(branchToCheckbox[branch])
@@ -45,7 +45,7 @@
     }
 
     function createMergeButton(c, branchToCheckbox) {
-        return c.button('Merge', {onclick: function(){
+        return c.button('Merge', {onclick: function(e){
             var branchMap = {};
             Object.keys(branchToCheckbox).forEach(function(key){
                 branchMap[key] = branchToCheckbox[key].firstChild.checked;
@@ -53,6 +53,7 @@
             // gerrit converts to camelcase on the java end
             c.call({'branch_map': branchMap},
                 function(r){ c.refresh(); });
+            e.currentTarget.setAttribute("disabled", true);
         }});
     }