-
Notifications
You must be signed in to change notification settings - Fork 0
/
metexploreviz.js
101 lines (79 loc) · 2.67 KB
/
metexploreviz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var MetExploreViz = {
initFrame:function(panel){
var iframe = document.createElement('iframe');
iframe.id = "iFrameMetExploreViz",
iframe.height = '100%',
iframe.width = '100%',
iframe.border = 0,
iframe.setAttribute("style", "border: none;top: 0; right: 0;bottom: 0; left: 0; width: 100%;height: 100%;");
var scripts = document.getElementsByTagName("script");
var libSrc;
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src.search("metExploreViz/metexploreviz.js") != -1) {
libSrc = scripts[i].src;
}
};
var locationSrc = document.location.href;
var index=0;
while (libSrc[index]==locationSrc[index]
&& index != locationSrc.length
&& index != libSrc.length) {
index++;
}
var libSrc = libSrc.substr(index, libSrc.length-1);
libSrc = libSrc.split("/metexploreviz.js");
res = locationSrc.substr(index, locationSrc.length-1);
res = res.split('/');
var headString = "";
for (var i = 0; i < res.length-1; i++) {
headString+="../";
};
var source = headString + libSrc[0] + "/index.html";
document.getElementById(panel).insertBefore(iframe, document.getElementById(panel).firstChild);
iframe.src = source;
},
initFrameInElement:function(elmt){
var iframe = document.createElement('iframe');
iframe.id = "iFrameMetExploreViz",
iframe.height = '100%',
iframe.width = '100%',
iframe.border = 0,
iframe.setAttribute("style", "border: none;top: 0; right: 0;bottom: 0; left: 0; width: 100%;height: 100%;");
var scripts = document.getElementsByTagName("script");
var libSrc;
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src.search("metExploreViz/metexploreviz.js") != -1) {
libSrc = scripts[i].src;
}
};
var locationSrc = document.location.href;
var index=0;
while (libSrc[index]==locationSrc[index]
&& index != locationSrc.length
&& index != libSrc.length) {
index++;
}
var libSrc = libSrc.substr(index, libSrc.length-1);
libSrc = libSrc.split("/metexploreviz.js");
res = locationSrc.substr(index, locationSrc.length-1);
res = res.split('/');
var headString = "";
for (var i = 0; i < res.length-1; i++) {
headString+="../";
};
var source = headString + libSrc[0] + "/index.html";
elmt.insertBefore(iframe, elmt.firstChild);
iframe.src = source;
},
launchMetexploreFunction:function(func) {
if (typeof metExploreViz !== 'undefined') {
// the variable is defined
func();
return;
}
var that = this;
setTimeout(function(){that.launchMetexploreFunction(func);}, 100); },
onloadMetExploreViz : function(func){
this.launchMetexploreFunction(func);
}
};