PageRenderTime 121ms CodeModel.GetById 91ms app.highlight 1ms RepoModel.GetById 19ms app.codeStats 0ms

/library/pygwt.py

http://pyjamas.googlecode.com/
Python | 40 lines | 38 code | 2 blank | 0 comment | 0 complexity | 660df516f3a34d2cde49c344f05fd3b7 MD5 | raw file
 1sNextHashId = 0
 2
 3def getNextHashId():
 4    global sNextHashId
 5    sNextHashId += 1
 6    return sNextHashId
 7
 8def getHashCode(o):
 9    JS("""
10    return (o == null) ? 0 :
11        (o.$H ? o.$H : (o.$H = pygwt_getNextHashId()));
12    """)
13
14def getModuleName():
15    JS("""
16    return $moduleName;
17    """)
18
19def getModuleBaseURL():
20    JS("""
21    // this is intentionally not using $doc, because we want the module's own url
22    var s = document.location.href;
23    
24    // Pull off any hash.
25    var i = s.indexOf('#');
26    if (i != -1)
27        s = s.substring(0, i);
28    
29    // Pull off any query string.
30    i = s.indexOf('?');
31    if (i != -1)
32        s = s.substring(0, i);
33    
34    // Rip off everything after the last slash.
35    i = s.lastIndexOf('/');
36    if (i != -1)
37        s = s.substring(0, i);
38
39    return (s.length > 0) ? s + "/" : "";
40    """)