-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
84 lines (76 loc) · 2.68 KB
/
utils.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
function setWorkflow(workflow) {
return new Promise(function(resolve, reject) {
var interval = setInterval(function() {
var scope = angular.element(document.getElementById('sr-index')).scope();
if (scope) {
clearInterval(interval);
scope.$apply(function() { scope.template = workflow; });
resolve();
}
}, 100);
});
}
function changeToTab(tab) {
return new Promise(function(resolve, reject) {
if (tab === 'runTab') {
document.querySelector('#smartRPanel .heim-tab[aria-controls="fragment-_run-_analysis"] a').click();
}
var interval = setInterval(function() {
if (document.querySelector('run-button')) {
clearInterval(interval);
resolve();
}
}, 100);
});
}
function fetchData() {
return new Promise(function(resolve, reject) {
document.querySelector('#smartRPanel fetch-button input').click();
var interval = setInterval(function() {
if (document.querySelector('#smartRPanel fetch-button span').innerHTML.indexOf('Task complete!') !== -1) {
clearInterval(interval);
resolve();
}
}, 250);
});
}
function runAnalysis() {
document.querySelector('run-button input').click();
}
function waitForAngular() {
return new Promise(function(resolve, reject) {
var interval = setInterval(function() {
if (typeof angular !== 'undefined') {
clearInterval(interval);
resolve();
}
}, 100);
});
}
function waitForTemplate() {
return new Promise(function(resolve, reject) {
var interval = setInterval(function() {
if (document.querySelector('#smartRPanel concept-box')) {
clearInterval(interval);
resolve();
}
}, 100);
});
}
function setData(numData, catData, hdData) {
return new Promise(function(resolve, reject) {
if (numData) {
document.querySelector('#smartRPanel concept-box[type="LD-numerical"] .sr-drop-input').innerHTML += numData;
}
if (catData) {
document.querySelector('#smartRPanel concept-box[type="LD-categorical"] .sr-drop-input').innerHTML += catData;
}
if (hdData) {
document.querySelector('#smartRPanel concept-box[type="HD"] .sr-drop-input').innerHTML += hdData;
}
setTimeout(resolve, 250);
});
}
function getControllerScope(controllerName) {
return angular.element(document.querySelector('div[ng-controller="' + controllerName + 'Controller"]')).scope();
}