Subversion Repositories HomeAutomation

Rev

Rev 972 | Rev 999 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 972 Rev 977
1
 
1
 
2
function ServiceManager() {}
2
function ServiceManager() {}
3
 
3
 
4
ServiceManager.Services = new Array();
4
ServiceManager.Services = new Array();
5
 
5
 
6
ServiceManager.getService = function(type, name, id)
6
ServiceManager.getService = function(type, name, id)
7
{
7
{
8
    var fullId = name + id;
8
    var fullId = name + id;
9
 
9
 
10
    if (!ServiceManager.Services[fullId])
10
    if (!ServiceManager.Services[fullId])
11
    {
11
    {
12
        if (eval("typeof " + name + " != 'function'"))///FIXME: eval = evil!
12
        if (eval("typeof " + name + " != 'function'"))///FIXME: eval = evil!
13
        {
13
        {
14
            if (!loadScript(type + "/" + name + ".js"))
14
            if (!loadScript(type + "/" + name + ".js"))
15
            {
15
            {
16
                //log("Could not load " + name + ".js\n");
16
                //log("Could not load " + name + ".js\n");
17
                return null;
17
                return null;
18
            }
-
 
19
            else
-
 
20
            {
-
 
21
                log("Successfully loaded " + name + ".js\n");
-
 
22
            }
18
            }
23
        }
19
        }
24
       
20
       
25
        ServiceManager.Services[fullId] = eval("(new " + name + "('" + name + "', " + id + "))");///FIXME: Can we do this without eval??
21
        ServiceManager.Services[fullId] = eval("(new " + name + "('" + name + "', " + id + "))");///FIXME: Can we do this without eval??
26
    }
22
    }
27
   
23
   
28
    return ServiceManager.Services[fullId];
24
    return ServiceManager.Services[fullId];
29
}
25
}
30
 
26
 
31
ServiceManager.startService = function(type, name, id, args)
27
ServiceManager.startService = function(type, name, id, args)
32
{
28
{
33
    var service = ServiceManager.getService(type, name, id);
29
    var service = ServiceManager.getService(type, name, id);
34
    if (service != null)
30
    if (service != null)
35
    {
31
    {
36
        service.initialize(args);
32
        service.initialize(args);
37
    }
33
    }
38
}
34
}
39
 
35