-
Notifications
You must be signed in to change notification settings - Fork 5
/
common_primitives.js
53 lines (49 loc) · 1.4 KB
/
common_primitives.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
/**
* Created by Varun and the professor on 12/10/17.
* This file contains primitives common to all types of animations.
*/
const DEFAULT_DELAY = 2000;
const DEF_ELEM_HEIGHT = 60;
const DEF_ELEM_WIDTH = 60;
const PCT_FONT_BOX = .72;
const DEF_FONT = Math.floor(DEF_ELEM_HEIGHT * PCT_FONT_BOX);
const DEF_BG_COLOR = '#ffff99';
const DEF_HL_COLOR = '#99ccff';
const DEF_HLK_COLOR = '#0073e6';
const SWAP_COLOR = '#ffb380';
var delayTime = DEFAULT_DELAY;
async function delay (time) {
return new Promise(function (resolve) {
console.log("In delay with time of ", time);
setTimeout(resolve, time)
})
}
function create_legend() {
const legend = {
"data": [{
"title": "Item Swapped",
"color": SWAP_COLOR,
},
{
"title": "Item Being Compared",
"color": DEF_HL_COLOR,
},]
};
return legend;
}
function footer() {
var legend = create_legend();
return document.getElementById("footer").innerHTML =
"<table style = width:10%>" +
"<tr>" +
"<td style = background-color:" + legend.data[0].color + ">" +
legend.data[0].title +
"</td>" +
"</tr>" +
"<tr>" +
"<td style = background-color:" + legend.data[1].color + ">" +
legend.data[1].title +
"</td>" +
"</tr>" +
"</table>";
}