This repository was archived by the owner on Sep 10, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change 1
- var json
1
+ var json ;
2
2
var itemselected = false ;
3
+ var midas = midas || { } ;
4
+
5
+ // Create the callbacks data structure
6
+ midas . callbacks = midas . callbacks || { } ;
7
+
8
+ /**
9
+ * Register a callback function from a module
10
+ * @param name The name of the callback
11
+ * @param module The module name registering the callback
12
+ * @param fn The callback function
13
+ */
14
+ midas . registerCallback = function ( name , module , fn )
15
+ {
16
+ if ( midas . callbacks [ name ] == undefined )
17
+ {
18
+ midas . callbacks [ name ] = { } ;
19
+ }
20
+ midas . callbacks [ name ] [ module ] = fn ;
21
+ }
22
+
23
+ /**
24
+ * Perform a callback.
25
+ * @param name The name of the callback to run.
26
+ * @param args A json object that will be passed to the registered callbacks.
27
+ * @return A json object whose keys are the module names and whose values are
28
+ * the return value for that module's registered callback.
29
+ */
30
+ midas . doCallback = function ( name , args )
31
+ {
32
+ if ( midas . callbacks [ name ] == undefined )
33
+ {
34
+ return { } ;
35
+ }
36
+ var retVal = { } ;
37
+ $ . each ( midas . callbacks [ name ] , function ( index , value ) {
38
+ retVal [ index ] = value ( args ) ;
39
+ } ) ;
40
+ return retVal ;
41
+ }
3
42
4
43
// Prevent error if console.log is called
5
44
if ( typeof console != "object" ) {
You can’t perform that action at this time.
0 commit comments