-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
46 lines (44 loc) · 1.32 KB
/
api.js
File metadata and controls
46 lines (44 loc) · 1.32 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
table_elem = document.getElementById("main");
navbar_elem = document.getElementById("toolbar");
table = {
get_data_at : function (x,y){
return table_elem.rows[x].cells[y].innerText;
},
set_data_at : function (x,y,z){
table_elem.rows[x].cells[y].innerText = z;
},
set_style_at : function (x,y,bg,fg){
table_elem.rows[x].cells[y].style.color = fg ? fg : getRandomHexColor();
table_elem.rows[x].cells[y].style.backgroundColor = bg ? bg : getRandomHexColor();
},
get_size: function(){
return [table_elem.rows.length,table_elem.rows[0].cells.length]
}
}
navbar = {
add_button : function(x,y){
a = document.createElement("button");
a.innerText = x;
a.onclick = y;
navbar_elem.appendChild(a);
return a;
},
add_textfield : function(x,y,search){
a = document.createElement("input");
a.innerText = x;
if (!search){
navbar_elem.appendChild(a);
a.addEventListener('change', e => y(e.target.value));
}else{
this.add_button(">>>",y);
navbar_elem.appendChild(a);
}
return a;
},
add_label : function(x){
a = document.createElement("label");
a.innerText = x;
navbar_elem.appendChild(a);
return a;
}
}