Code standards updates
This commit is contained in:
parent
a11103a3a7
commit
b54d1b708a
1 changed files with 11 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
||||||
* @brief Provide a way for add-ons to register a JavaScript hook
|
* @brief Provide a way for add-ons to register a JavaScript hook
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var addon_hooks={};
|
var addon_hooks = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Register a JavaScript hook to be called from other Javascript files
|
* @brief Register a JavaScript hook to be called from other Javascript files
|
||||||
|
@ -11,27 +11,30 @@ var addon_hooks={};
|
||||||
* @param type which type of hook i.e. where should it be called along with other hooks of the same type
|
* @param type which type of hook i.e. where should it be called along with other hooks of the same type
|
||||||
* @param hookfnstr name of the JavaScript function name that needs to be called
|
* @param hookfnstr name of the JavaScript function name that needs to be called
|
||||||
*/
|
*/
|
||||||
function Addon_registerHook( type, hookfnstr )
|
function Addon_registerHook(type, hookfnstr)
|
||||||
{
|
{
|
||||||
if (!addon_hooks.hasOwnProperty(type)) {
|
if (!addon_hooks.hasOwnProperty(type)) {
|
||||||
addon_hooks[type]=[];
|
addon_hooks[type] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
addon_hooks[type].push( hookfnstr );
|
addon_hooks[type].push(hookfnstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Call all registered hooks of a certain type, i.e. at the same point of the JavaScript code execution
|
* @brief Call all registered hooks of a certain type, i.e. at the same point of the JavaScript code execution
|
||||||
* @param typeOfHook string indicating which type of hooks to be called among the registered hooks
|
* @param typeOfHook string indicating which type of hooks to be called among the registered hooks
|
||||||
*/
|
*/
|
||||||
function callAddonHooks( typeOfHook ) {
|
function callAddonHooks(typeOfHook)
|
||||||
|
{
|
||||||
if (typeof addon_hooks !== 'undefined') {
|
if (typeof addon_hooks !== 'undefined') {
|
||||||
var myTypeOfHooks = addon_hooks[typeOfHook];
|
var myTypeOfHooks = addon_hooks[typeOfHook];
|
||||||
if (typeof myTypeOfHooks !== 'undefined') {
|
if (typeof myTypeOfHooks !== 'undefined') {
|
||||||
for (addon_hook_idx = 0; addon_hook_idx < myTypeOfHooks.length; addon_hook_idx++) {
|
for (addon_hook_idx = 0; addon_hook_idx < myTypeOfHooks.length; addon_hook_idx++) {
|
||||||
var hookfnstr = myTypeOfHooks[addon_hook_idx];
|
var hookfnstr = myTypeOfHooks[addon_hook_idx];
|
||||||
var hookfn = window[hookfnstr];
|
var hookfn = window[hookfnstr];
|
||||||
if (typeof hookfn === "function") hookfn();
|
if (typeof hookfn === "function") {
|
||||||
|
hookfn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue