-
Notifications
You must be signed in to change notification settings - Fork 702
/
canvas.js
47 lines (39 loc) · 1.07 KB
/
canvas.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
class Canvas {
constructor(id, parent, width, height) {
this.id = id;
this.listId = null;
this.parent = parent;
this.width = width;
this.height = height;
this.ctx = null;
}
// new class stuff above here
create() {
if(this.ctx !== null) {
console.log('Canvas already created!');
return;
} else {
let divWrapper = document.createElement('div');
let canvasElem = document.createElement('canvas');
this.parent.appendChild(divWrapper);
divWrapper.appendChild(canvasElem);
divWrapper.id = this.id;
canvasElem.width = this.width;
canvasElem.height = this.height;
this.ctx = canvasElem.getContext('2d');
}
}
createReportList() {
if(this.listId !== null) {
console.log('Report list already created!');
return;
} else {
let list = document.createElement('ul');
list.id = this.id + '-reporter';
let canvasWrapper = document.getElementById(this.id);
canvasWrapper.appendChild(list);
this.listId = list.id;
}
}
}
export { Canvas };