Adapt JS to work in PolyGerrit

* Gerrit commit 172acf7e183d3c6ff2994a8ddf00847f4dbd6d34
  (plugin.deprecated.onAction partial support, 2017-10-23) added
  support to PolyGerrit for the JS APIs this plugin needs.  Make use
  of that support.

* Use context.refresh and self.on instead of Gerrit.refresh and
  Gerrit.on, since PolyGerrit implements the former.

Feature: Issue 6145
Change-Id: I12ef2d0df88ee8b953c64cc07ab27a8872ca9f2b
diff --git a/src/main/resources/static/automerger.js b/src/main/resources/static/automerger.js
index d8995d5..8c0f4d8 100644
--- a/src/main/resources/static/automerger.js
+++ b/src/main/resources/static/automerger.js
@@ -52,7 +52,7 @@
             });
             // gerrit converts to camelcase on the java end
             c.call({'branch_map': branchMap},
-                function(r){ Gerrit.refresh(); });
+                function(r){ c.refresh(); });
         }});
     }
 
@@ -88,6 +88,10 @@
         getDownstreamConfigMap();
     }
 
+    if (window.Polymer) {
+        self.deprecated.install();
+    }
+
     self.onAction('revision', 'automerge-change', onAutomergeChange);
-    Gerrit.on('showchange', onShowChange);
-});
\ No newline at end of file
+    self.on('showchange', onShowChange);
+});