Permalink
sugar-web/env.js
Newer
100644
54 lines (44 sloc)
1.48 KB
8
// FIXME: we assume this code runs on the same thread as the
9
// javascript executed from sugar-toolkit-gtk3 (python)
10
11
if (env.isStandalone()) {
13
callback(null, {});
16
var environmentCallback = function () {
17
callback(null, window.top.sugar.environment);
18
};
19
20
if (window.top.sugar) {
21
setTimeout(function () {
22
environmentCallback();
23
}, 0);
24
} else {
25
window.top.sugar = {};
26
window.top.sugar.onEnvironmentSet = function () {
27
environmentCallback();
33
env.getObjectId = function (callback) {
34
env.getEnvironment(function (error, environment) {
35
callback(environment.objectId);
36
});
37
};
38
40
return window.location.protocol;
41
};
42
44
var webActivityURLScheme = "activity:";
45
var currentURLScheme = env.getURLScheme();
46
47
// the control of hostname !== '0.0.0.0' is used
48
// for compatibility with F18 and webkit1
49
return currentURLScheme !== webActivityURLScheme &&
50
window.location.hostname !== '0.0.0.0';