Add Gerrit.on('showchange', f) to JS plugin API
chromium-review.googlesource.com uses a chunk of JavaScript to monitor
the anchor, detect if the URL is #/c/... style, and then extracts the
project name out of a table cell. This is a horrible way to add web
UI logic based on the project.
Add an event to ChangeScreen2 that plugins can register against. Pass
the ChangeInfo so functions can use native properties like "project"
instead of scraping the displayed web interface.
Change-Id: Ie6daed2598d4e4f9c9fe0dee40ab2e36b81012bf
diff --git a/Documentation/js-api.txt b/Documentation/js-api.txt
index 7411026..cbccebf 100644
--- a/Documentation/js-api.txt
+++ b/Documentation/js-api.txt
@@ -129,6 +129,30 @@
function (r) {});
----
+[[self_on]]
+self.on()
+~~~~~~~~~
+Register a JavaScript callback to be invoked when events occur within
+the web interface.
+
+.Signature
+[source,javascript]
+----
+Gerrit.on(event, callback);
+----
+
+* event: A supported event type. See below for description.
+
+* callback: JavaScript function to be invoked when event happens.
+ Arguments may be passed to this function, depending on the event.
+
+Supported events:
+
+* `showchange`: Invoked when a change is made visible. A
+ link:rest-api-changes.html#change-info[ChangeInfo] and
+ link:rest-api-changes.html#revision-info[RevisionInfo]
+ are passed as arguments.
+
[[self_onAction]]
self.onAction()
~~~~~~~~~~~~~~~