-
Notifications
You must be signed in to change notification settings - Fork 1
/
infobox.js
150 lines (128 loc) · 5.93 KB
/
infobox.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
function fillInfoBox(element) {
var type = element.data('type');
infoboxElement = element;
// Fill in all information before showing div
document.getElementById('type-info').innerHTML = type.toUpperCase();
document.getElementById('element-id').innerHTML = element.data('id');
if (type == DftTypes.BE) {
if (element.data('rate') < 0.0000001) {
var num = new Number(element.data('rate'));
document.getElementById('failure-rate').innerHTML = num.toExponential();
} else {
document.getElementById('failure-rate').innerHTML = element.data('rate');
}
var repair = 0;
if (element.data('repair')) {
repair = element.data('repair');
}
if (repair > 0 && (repair < 0.0000001 || repair.length > 10)) {
var num = new Number(element.data('repair'));
document.getElementById('repair-rate').innerHTML = num.toExponential();
} else {
document.getElementById('repair-rate').innerHTML = repair;
}
document.getElementById('dorm-rate').innerHTML = element.data('dorm');
if (repair > 0) {
document.getElementById('repairable-bool').innerHTML = 'True';
} else document.getElementById('repairable-bool').innerHTML = 'False';
document.getElementById('childrens-count').innerHTML = '-';
document.getElementById('parents-count').innerHTML = '-';
document.getElementById('parents-count').innerHTML = element.incomers('node').length;
// Name and Pic
$('#pic').css('background-image', 'url("img/beInv.png")');
$('#pic').css('background-size', '42px 42px');
$('#pic').css('left', '90px');
document.getElementById('name-div').innerHTML = element.data('name');
} else if (type != DftTypes.BOT && type != DftTypes.BE) {
document.getElementById('failure-rate').innerHTML = '-';
document.getElementById('repair-rate').innerHTML = '-';
document.getElementById('dorm-rate').innerHTML = '-';
// Parents and children
document.getElementById('childrens-count').innerHTML = element.data('children').length;
document.getElementById('parents-count').innerHTML = element.incomers('node').length;
if (element.data('repairable')) {
document.getElementById('repairable-bool').innerHTML = 'True';
} else document.getElementById('repairable-bool').innerHTML = 'False';
}
if (type == DftTypes.VOT) {
document.getElementById('threshold-value').innerHTML = element.data('voting');
// Name and Pic
$('#pic').css('background-image', 'url("img/votInv.png")');
$('#pic').css('background-size', '37.5px 49.98px');
$('#pic').css('left', '92px');
document.getElementById('name-div').innerHTML = element.data('name');
} else document.getElementById('threshold-value').innerHTML = '-';
if (type == DftTypes.PDEP) {
document.getElementById('probability-value').innerHTML = element.data('probability');
// Name and Pic
$('#pic').css('background-image', 'url("img/pdep.png")');
$('#pic').css('background-size', '100px 50px');
$('#pic').css('left', '62.5px');
document.getElementById('name-div').innerHTML = element.data('name');
} else document.getElementById('probability-value').innerHTML = '-';
if (type == DftTypes.BOT) {
document.getElementById('childrens-count').innerHTML = '-';
document.getElementById('parents-count').innerHTML = element.incomers('node').length;
// Name and Pic
$('#pic').css('background-image', 'url("img/bot.png")');
$('#pic').css('background-size', '42px 42px');
$('#pic').css('left', '90px');
document.getElementById('name-div').innerHTML = element.data('name');
} else if (type == DftTypes.AND || type == DftTypes.OR || type == DftTypes.PAND || type == DftTypes.POR) {
// Name and Pic
$('#pic').css('background-size', '37.5px 49.98px');
$('#pic').css('left', '92px');
if (type == DftTypes.AND) {
$('#pic').css('background-image', 'url("img/andInv.png")');
document.getElementById('name-div').innerHTML = element.data('name');
} else if (type == DftTypes.OR) {
$('#pic').css('background-image', 'url("img/orInv.png")');
document.getElementById('name-div').innerHTML = element.data('name');
} else if (type == DftTypes.PAND) {
$('#pic').css('background-image', 'url("img/pandInv.png")');
document.getElementById('name-div').innerHTML = element.data('name');
} else {
$('#pic').css('background-image', 'url("img/porInv.png")');
document.getElementById('name-div').innerHTML = element.data('name');
}
} else if (type == DftTypes.SPARE) {
// Name and Pic
$('#pic').css('background-image', 'url("img/spare.png")');
$('#pic').css('background-size', '100px 50px');
$('#pic').css('left', '62.5px');
document.getElementById('name-div').innerHTML = element.data('name');
} else if (type == DftTypes.FDEP) {
// Name and Pic
$('#pic').css('background-image', 'url("img/fdep.png")');
$('#pic').css('background-size', '100px 50px');
$('#pic').css('left', '62.5px');
document.getElementById('name-div').innerHTML = element.data('name');
} else if (type == DftTypes.SEQ) {
// Name and Pic
$('#pic').css('background-image', 'url("img/seqInv.png")');
$('#pic').css('background-size', '100px 50px');
$('#pic').css('left', '62.5px');
document.getElementById('name-div').innerHTML = element.data('name');
}
$('#box').dialog('open');
}
function prepareParents(elem) {
document.getElementById('scroll-type').innerHTML = 'Parents';
var parents = createParentStrings(elem);
var string = '<select id="selectMenu">';
for (var i = parents.length - 1; i >= 0; i--) {
string += '<option value="' + parents[i].id + '">' + parents[i].name + '</option>';
}
string += '</select>';
document.getElementById('select-menu').innerHTML = string;
}
function prepareChildren(elem) {
document.getElementById('scroll-type').innerHTML = 'Children';
var children = elem.data('children');
var string = '<select id="selectMenu">';
for (var i = children.length - 1; i >= 0; i--) {
string += '<option value="' + cy.getElementById(children[i]).data('id') + '">' + cy.getElementById(children[i]).data('name') + '</option>';
}
string += '</select>';
document.getElementById('select-menu').innerHTML = string;
}