Added a basic plugin/hook framework for Javascript
authorDan
Thu, 26 Feb 2009 01:03:22 -0500
changeset 840 6b99e02ad577
parent 839 1b4bd31fe01d
child 841 83bb60402f51
Added a basic plugin/hook framework for Javascript
includes/clientside/static/enano-lib-basic.js
--- a/includes/clientside/static/enano-lib-basic.js	Thu Feb 26 01:02:50 2009 -0500
+++ b/includes/clientside/static/enano-lib-basic.js	Thu Feb 26 01:03:22 2009 -0500
@@ -212,6 +212,24 @@
   }
 }
 
+var enano_hooks = {};
+function setHook(hook_name)
+{
+  if ( enano_hooks[hook_name] )
+  {
+    return enano_hooks[hook_name];
+  }
+  return 'void(0);';
+}
+
+function attachHook(hook_name, code)
+{
+  if ( !enano_hooks[hook_name] )
+    enano_hooks[hook_name] = '';
+  
+  enano_hooks[hook_name] += code;
+}
+
 var loaded_components = {};
 var _load_component_running = false;
 function load_component(file)