-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.js
63 lines (63 loc) · 1.92 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function numVertices1(btn) {
var text = btn.textContent;
if(Number(text) === 9)
{
alert("Error, too many number"); return;
}
text = Number(text) + 1;
btn.innerHTML=(text);
}
function numVertices0(btn) {
var text = btn.textContent;
if(Number(text) === 3)
{
alert("Error, too small number"); return;
}
text = Number(text) - 1;
btn.innerHTML=(text);
}
function add_xn(index, width, id) {
d3.select("#btns").append("div")
.attr("class", "btn btn-success")
.attr("id", id)
.attr("onclick","setStart(this)")
.style("width", width + "%")
.style("height", width + "%")
.style("vertical-align", "middle")
.style("font-size", "17px")
.text('x' + index);
}
function add0(index,width) {
d3.select("#btns").append("div")
.attr("class", "btn btn-warning")
.attr("onclick", "setBtnText1(this)")
.attr("oncontextmenu","setBtnText0(this); return false")
.attr("id", index)
.style("width", width + "%")
.style("height", width + "%")
.style("vertical-align", "middle")
.style("font-size", "17px")
.text(0);
}
function del_but() {
for(var i = 0; i < 250; i++)
{
d3.select("#btns").select("div").remove();
}
}
function setBtnText1(btn) {
var id = btn.id;
var text = document.getElementById(id).textContent;
if(text == -1) document.getElementById(id).className="btn btn-warning"
else document.getElementById(id).className="btn btn-danger";
text = Number(text) + 1;
document.getElementById(id).innerHTML=(text);
}
function setBtnText0(btn) {
var id = btn.id;
var text = document.getElementById(id).textContent;
if(text == 1) document.getElementById(id).className="btn btn-warning"
else document.getElementById(id).className="btn btn-danger";
text = Number(text) - 1;
document.getElementById(id).innerHTML=(text);
}