3 * @brief Provide a way for add-ons to register a JavaScript hook
9 * @brief Register a JavaScript hook to be called from other Javascript files
10 * @pre the .js file from which the hook will be called is included in the document response
11 * @param type which type of hook i.e. where should it be called along with other hooks of the same type
12 * @param hookfnstr name of the JavaScript function name that needs to be called
14 function Addon_registerHook(type, hookfnstr)
16 if (!addon_hooks.hasOwnProperty(type)) {
17 addon_hooks[type] = [];
20 addon_hooks[type].push(hookfnstr);
24 * @brief Call all registered hooks of a certain type, i.e. at the same point of the JavaScript code execution
25 * @param typeOfHook string indicating which type of hooks to be called among the registered hooks
27 function callAddonHooks(typeOfHook)
29 if (typeof addon_hooks !== 'undefined') {
30 var myTypeOfHooks = addon_hooks[typeOfHook];
31 if (typeof myTypeOfHooks !== 'undefined') {
32 for (addon_hook_idx = 0; addon_hook_idx < myTypeOfHooks.length; addon_hook_idx++) {
33 var hookfnstr = myTypeOfHooks[addon_hook_idx];
34 var hookfn = window[hookfnstr];
35 if (typeof hookfn === "function") {