Rev 999 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 999 | Rev 1299 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | ServiceManager.Services = new Array(); |
4 | ServiceManager.Services = new Array(); |
| - | 5 | ServiceManager.Callbacks = new Array(); |
|
| 5 | 6 | ||
| - | 7 | ServiceManager.addCallback = function(callback) |
|
| - | 8 | { |
|
| - | 9 | ServiceManager.Callbacks[ServiceManager.Callbacks.length] = callback; |
|
| - | 10 | } |
|
| - | 11 | ||
| 6 | ServiceManager.getService = function(type, name, id) |
12 | ServiceManager.getService = function(type, name, id) |
| 7 | { |
13 | { |
| 8 | var fullId = name + id; |
14 | var fullId = name + id; |
| 9 | 15 | ||
| 10 | if (!ServiceManager.Services[fullId]) |
16 | if (!ServiceManager.Services[fullId]) |
| 11 | { |
17 | { |
| 12 | if (eval("typeof " + name + " != 'function'"))///FIXME: eval = evil! |
18 | if (eval("typeof " + name + " != 'function'"))///FIXME: eval = evil! |
| 13 | { |
19 | { |
| 14 | if (!loadScript(type + "/" + name + ".js")) |
20 | if (!loadScript(type + "/" + name + ".js")) |
| 15 | { |
21 | { |
| 16 | //log("Could not load " + name + ".js\n"); |
22 | //log("Could not load " + name + ".js\n"); |
| 17 | return null; |
23 | return null; |
| 18 | } |
24 | } |
| 19 | } |
25 | } |
| 20 | 26 | ||
| 21 | ServiceManager.Services[fullId] = eval("(new " + name + "('" + type + "', '" + name + "', " + id + "))");///FIXME: Can we do this without eval?? |
27 | ServiceManager.Services[fullId] = eval("(new " + name + "('" + type + "', '" + name + "', " + id + "))");///FIXME: Can we do this without eval?? |
| - | 28 | ||
| - | 29 | for (var n in ServiceManager.Callbacks) |
|
| - | 30 | { |
|
| - | 31 | ServiceManager.Callbacks[n](ServiceManager.Services[fullId]); |
|
| - | 32 | } |
|
| 22 | } |
33 | } |
| 23 | 34 | ||
| 24 | return ServiceManager.Services[fullId]; |
35 | return ServiceManager.Services[fullId]; |
| 25 | } |
36 | } |
| 26 | 37 | ||