Repository navigation
Expand file tree
/
Copy pathviz.js
More file actions
243 lines (225 loc) · 7.4 KB
/
Copy pathviz.js
File metadata and controls
243 lines (225 loc) · 7.4 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
var mode="exploration";
var codetraceColor = 'white';
//codetrace highlight
function highlightLine(lineNumbers) { /* lineNumbers can be an array or a single number. Yay overloading! */
$('#codetrace p').css('background-color', colourTheThird).css('color',codetraceColor);
if (lineNumbers instanceof Array) {
for(var i=0; i<lineNumbers.length; i++) {
if(lineNumbers[i] != 0) {
$('#code'+lineNumbers[i]).css('background-color', 'black').css('color','white');
}
}
} else {
$('#code'+lineNumbers).css('background-color', 'black').css('color','white');
}
}
var isPlaying = false;
//Opening and closing panels
var isActionsOpen = true;
var isStatusOpen = false;
var isCodetraceOpen = false;
//vars actionsWidth and statusCodetraceWidth must be defined in the specific vizname_actions.js file
function showActionsPanel() {
if(!isActionsOpen) {
$('#actions-hide img').removeClass('rotateLeft').addClass('rotateRight');
$('#actions').animate({
width: "+="+actionsWidth,
});
isActionsOpen = true;
}
}
function hideActionsPanel() {
if(isActionsOpen) {
$('#actions-hide img').removeClass('rotateRight').addClass('rotateLeft');
$('#actions').animate({
width: "-="+actionsWidth,
});
isActionsOpen = false;
}
}
function showStatusPanel() {
if(!isStatusOpen) {
$('#status-hide img').removeClass('rotateLeft').addClass('rotateRight');
$('#current-action').show();
$('#status').animate({
width: "+="+statusCodetraceWidth,
});
isStatusOpen = true;
}
}
function hideStatusPanel() {
if(isStatusOpen) {
$('#status-hide img').removeClass('rotateRight').addClass('rotateLeft');
$('#current-action').hide();
$('#status').animate({
width: "-="+statusCodetraceWidth,
});
isStatusOpen = false;
}
}
function showCodetracePanel() {
if(!isCodetraceOpen) {
$('#codetrace-hide img').removeClass('rotateLeft').addClass('rotateRight');
$('#codetrace').animate({
width: "+="+statusCodetraceWidth,
});
isCodetraceOpen = true;
}
}
function hideCodetracePanel() {
if(isCodetraceOpen) {
$('#codetrace-hide img').removeClass('rotateRight').addClass('rotateLeft');
$('#codetrace').animate({
width: "-="+statusCodetraceWidth,
});
isCodetraceOpen = false;
}
}
function triggerRightPanels() {
hideEntireActionsPanel();
showStatusPanel();
showCodetracePanel();
}
function extractQnGraph(graph) {
var vList = graph.internalAdjList;
var eList = graph.internalEdgeList;
for(var key in vList) {
var temp;
var v = vList[key];
temp = v.cxPercentage;
v.cxPercentage = v.cx;
v.cx = (temp/100)*MAIN_SVG_WIDTH;
temp = v.cyPercentage;
v.cyPercentage = v.cy;
v.cy = (temp/100)*MAIN_SVG_HEIGHT;
}
return graph;
}
$( document ).ready(function() {
var actionsHeight = ($('#actions p').length)*27 + 10;
$('#actions').css('height', actionsHeight);
$('#actions').css('width', actionsWidth);
var actionsHideTop = Math.floor((actionsHeight - 16)/2);
var actionsHideBottom = (actionsHeight - 16) - actionsHideTop;
$('#actions-hide').css('padding-top', actionsHideTop);
$('#actions-hide').css('padding-bottom', actionsHideBottom);
$('#current-action').hide();
$('#actions-hide img').addClass('rotateRight');
//surpriseColour stuff
$('.tutorial-next').css("background-color", surpriseColour);
if(surpriseColour == "#fec515" || surpriseColour == '#a7d41e') {
$('.tutorial-next').css("color", "black");
$('.tutorial-next img').attr("src", "img/arrow_black_right.png");
}
$('#progress-bar .ui-slider-range').css("background-color", surpriseColour);
$('#actions').css("background-color", colourTheSecond);
$('#actions-hide').css("background-color", colourTheSecond);
$('.action-menu-pullout').css('left', actionsWidth+43+'px');
$('.action-menu-pullout').children().css('float','left');
$('.coloured-menu-option').css("background-color", colourTheSecond).css('color','white');
if(colourTheSecond == '#fec515' || colourTheSecond == '#a7d41e') {
$('#actions p').css('color', 'black');
$('#actions p').hover(function() { $(this).css('color', 'white');}, function() {$(this).css('color', 'black');});
$('.coloured-menu-option').css('color', 'black');
$('.coloured-menu-option').hover(function() { $(this).css('color', 'white');}, function() {$(this).css('color', 'black');});
$('#actions-hide img').attr('src', 'img/arrow_black_right.png');
}
$('#codetrace').css("background-color", colourTheThird);
$('#codetrace-hide').css("background-color", colourTheThird);
if(colourTheThird == '#fec515' || colourTheThird == '#a7d41e') {
$('#codetrace').css('color', 'black');
$('#codetrace-hide img').attr('src', 'img/arrow_black_right.png');
codetraceColor = 'black';
}
$('#status').css("background-color", colourTheFourth);
$('#status-hide').css("background-color", colourTheFourth);
if(colourTheFourth == '#fec515' || colourTheFourth == '#a7d41e') {
$('#status').css('color', 'black');
$('#status-hide img').attr('src', 'img/arrow_black_right.png');
}
//mmode menu
$('#mode-button').click(function() {
$('#other-modes').toggle();
});
$('#mode-menu').hover(function() {
$('#other-modes').toggle();
});
$('#mode-menu a').hover(function() {
$(this).css("background", surpriseColour);
}, function() {
$(this).css("background", "black");
});
$('#mode-menu a').click(function() {
var currentMode = $('#mode-button').html().split("<")[0];
var newMode = $(this).html();
$(this).html(currentMode);
$('#mode-button').html(newMode + '<img src="img/arrow_white.png"/>');
if(newMode=="Exploration Mode") {
mode = "exploration";
$('#status-hide').show();
$('#codetrace-hide').show();
$('#actions-hide').show();
$('#status').show();
$('#codetrace').show();
$('#actions').show();
$('.tutorial-dialog').hide();
hideStatusPanel();
hideCodetracePanel();
showActionsPanel();
/*} else if(newMode=="Training Mode") {
mode = "training";
$('#status').hide();
$('#codetrace').hide();
$('#actions').hide();
$('#status-hide').hide();
$('#codetrace-hide').hide();
$('#actions-hide').hide();
*/
} else if (newMode=="Tutorial Mode") {
mode = "tutorial";
$('#status-hide').show();
$('#codetrace-hide').show();
$('#actions-hide').show();
$('#current-action').html("");
$('#status').show();
$('#codetrace').show();
$('#actions').show();
if(isPlaying) { stop(); }
hideEntireActionsPanel();
hideStatusPanel();
hideCodetracePanel();
$('.tutorial-dialog').first().fadeIn(500);
}
});
//arrow buttons to show/hide panels
$('#status-hide').click(function() {
if(isStatusOpen) {
hideStatusPanel();
} else {
showStatusPanel();
}
});
$('#codetrace-hide').click(function() {
if(isCodetraceOpen) {
hideCodetracePanel();
} else {
showCodetracePanel();
}
});
$('#actions-hide').click(function() {
if(isActionsOpen) {
hideEntireActionsPanel(); //must define hideEntireActionsPanel() function in vizname_actions.js file
} else {
showActionsPanel();
}
});
//tutorial mode
$('.tutorial-dialog .tutorial-next').click(function() {
var vizname = $(this).parent().attr('id').split('-')[0];
var nextNo = parseInt($(this).parent().attr('id').slice(-1))+1;
var nextId = vizname+'-tutorial-'+nextNo;
$(this).parent().fadeOut(500, function() {
$('#'+nextId).fadeIn(500);
});
});
});