Fix some JS issues

Brought up by Krinkle in Icebfe86b (PS4):
    * 'ok' and 'err' properties of Api are deprecated, use promise interface
    * Use 'api' instead of 'Api'
    * $( '<a>' ) instead of $( '<a/>' )
    * Expected space after 'function' keyword

Change-Id: I0199db902174551bcf9269edafb1fef1df118b13
Merge "Fix some JS issues"