-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.js
41 lines (32 loc) · 978 Bytes
/
Button.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
class Button{
constructor(text, parent, displayClass, endFunction){
this.text = text;
this.parent = parent;
this.displayClass = displayClass;
this.endFunction = endFunction;
this.id = IdManager.getID();
}
randInt(min, max) {
return Math.random() * (max - min) + min;
}
show(){
let button = document.createElement(this.displayClass);
button.innerHTML = this.text;
button.onclick = this.endFunction
button.id = this.id;
document.getElementById(this.parent).appendChild(button);
}
export(){
let button = document.createElement(this.displayClass);
button.innerHTML = this.text;
button.onclick = this.endFunction
button.id = this.id;
return button;
}
hide(){
var elem = document.getElementById(this.id);
if(elem != null){
elem.parentNode.removeChild(elem);
}
}
}