1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * @param {Array<{event: string, id: string,
9 * fn: function(Event):void}>} actions Array of actions to register.
11 function registerEventListeners(actions
) {
12 for (var i
= 0; i
< actions
.length
; ++i
) {
13 var action
= actions
[i
];
14 registerEventListener(action
.id
, action
.event
, action
.fn
);
19 * Add an event listener to the specified element.
20 * @param {string} id Id of element.
21 * @param {string} eventname Event name.
22 * @param {function(Event):void} fn Event handler.
24 function registerEventListener(id
, eventname
, fn
) {
25 var element
= document
.getElementById(id
);
27 element
.addEventListener(eventname
, fn
, false);
29 console
.error('Could not set ' + eventname
+
30 ' event handler on element ' + id
+
31 ': element not found.');