/library/pygwt.py
Python | 40 lines | 38 code | 2 blank | 0 comment | 0 complexity | 660df516f3a34d2cde49c344f05fd3b7 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
- sNextHashId = 0
- def getNextHashId():
- global sNextHashId
- sNextHashId += 1
- return sNextHashId
- def getHashCode(o):
- JS("""
- return (o == null) ? 0 :
- (o.$H ? o.$H : (o.$H = pygwt_getNextHashId()));
- """)
- def getModuleName():
- JS("""
- return $moduleName;
- """)
- def getModuleBaseURL():
- JS("""
- // this is intentionally not using $doc, because we want the module's own url
- var s = document.location.href;
-
- // Pull off any hash.
- var i = s.indexOf('#');
- if (i != -1)
- s = s.substring(0, i);
-
- // Pull off any query string.
- i = s.indexOf('?');
- if (i != -1)
- s = s.substring(0, i);
-
- // Rip off everything after the last slash.
- i = s.lastIndexOf('/');
- if (i != -1)
- s = s.substring(0, i);
- return (s.length > 0) ? s + "/" : "";
- """)