Repository navigation
Expand file tree
/
Copy pathscript_old.js
More file actions
218 lines (204 loc) · 7.33 KB
/
Copy pathscript_old.js
File metadata and controls
218 lines (204 loc) · 7.33 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
var c = document.getElementById("myCanvas");
var c_context = c.getContext("2d");
var c_n_1_flag = 0;
var c_n_2_flag = 0;
var x_f = 10;
var y_f = 10;
var ex1 = [];
var ex2 = [];
var coe1 = [];
var coe2 = [];
var result_coe = [];
var result_ex = [];
function Node() {
var coeff = document.getElementById("Coefficients").value;
var expo = document.getElementById("Exponents").value;
coe1.push(coeff);
ex1.push(expo);
console.log(coe1);
console.log(ex1);
if(coeff.toString() == "" || expo.toString() == "" || expo<0){ alert("Enter a coefficient"); }
else{
if(c_n_1_flag!=0)
{
c_context.beginPath();
c_context.moveTo(x_f - 40,67.5);
c_context.lineTo(x_f +30, 67.5);
c_context.lineWidth = 2;
c_context.stroke();
}
else if(c_n_1_flag == 0)
{
c_context.strokeStyle = "#f00";
c_context.strokeRect(10, 10, 30, 30);
c_context.fillStyle = "#00f";
c_context.fillRect(10, 10, 30, 30);
c_context.fillStyle = "#FFFFFF"
c_context.font = "15px Arial";
c_context.fillText("p",20,30);
console.log(c_n_1_flag);
c_n_1_flag = 1
}
c_context.strokeStyle = "#f00";
c_context.strokeRect(x_f,50, 98, 35);
//c_context.strokeRect(10, 50, 98, 35);
c_context.fillStyle = "#00f";
c_context.fillRect(x_f + 2.5, 52.5, 30, 30);
c_context.fillStyle = "#00f";
c_context.fillRect(x_f + 34, 52.5, 30, 30);
c_context.fillStyle = "#00f";
c_context.fillRect(x_f+65.5, 52.5, 30, 30);
c_context.fillStyle = "#FFFFFF";
c_context.font = "15px Arial";
c_context.fillText(coeff.toString(),x_f + 5,75);
c_context.font = "15px Arial";
c_context.fillText(expo.toString(),x_f+34+5,75);
c_context.font = "15px Arial";
c_context.fillText(coeff.toString(),x_f + 5,75);
x_f = x_f + 128;
var s = document.getElementById("c_n_1");
s.style.cursor = "no-drop";
var p = document.getElementById("add_more");
p.style.cursor = "default";
var p = document.getElementById("finish");
p.style.cursor = "default";
document.getElementById("c_n_1").disabled = true;
document.getElementById("add_more").disabled = false;
document.getElementById("finish").disabled = false;
}
}
function Node2() {
var coeff2 = document.getElementById("Coefficients2").value;
var expo2 = document.getElementById("Exponents2").value;
coe2.push(coeff2);
ex2.push(expo2);
console.log(coeff2);
console.log(expo2);
if(coeff2.toString() == "" || expo2.toString() == "" || expo2<0){ alert("Enter a coefficient"); }
else{
if(c_n_2_flag!=0)
{
c_context.beginPath();
c_context.moveTo(y_f - 40, 150 + 67.5);
c_context.lineTo(y_f + 10, 150 + 67.5);
c_context.lineWidth = 2;
c_context.stroke();
}
else if(c_n_2_flag == 0)
{
c_context.strokeStyle = "#f00";
c_context.strokeRect(10, 150, 30, 30);
c_context.fillStyle = "#00f";
c_context.fillRect(10, 150, 30, 30);
c_context.fillStyle = "#FFFFFF"
c_context.font = "15px Arial";
c_context.fillText("q",20,165);
console.log(c_n_2_flag);
c_n_2_flag = 1
}
c_context.strokeStyle = "#f00";
c_context.strokeRect(y_f,200, 98, 35);
//c_context.strokeRect(10, 50, 98, 35);
c_context.fillStyle = "#00f";
c_context.fillRect(y_f + 2.5, 202.5, 30, 30);
c_context.fillStyle = "#00f";
c_context.fillRect(y_f + 34, 202.5, 30, 30);
c_context.fillStyle = "#00f";
c_context.fillRect(y_f+65.5, 202.5, 30, 30);
c_context.fillStyle = "#FFFFFF";
c_context.font = "15px Arial";
c_context.fillText(coeff2.toString(),y_f + 5,220);
c_context.font = "15px Arial";
c_context.fillText(expo2.toString(),y_f+34+5,220);
c_context.font = "15px Arial";
c_context.fillText(coeff2.toString(),y_f + 5,220);
y_f = y_f + 128;
var s = document.getElementById("c_n_2");
s.style.cursor = "no-drop";
var p = document.getElementById("add_more2");
p.style.cursor = "default";
var p = document.getElementById("finish2");
p.style.cursor = "default";
document.getElementById("c_n_2").disabled = true;
document.getElementById("add_more2").disabled = false;
document.getElementById("finish2").disabled = false;
}
}
function add_more(){
var s = document.getElementById("c_n_1");
s.style.cursor = "default";
var p = document.getElementById("add_more");
p.style.cursor = "no-drop";
var p = document.getElementById("finish");
p.style.cursor = "default";
document.getElementById("c_n_1").disabled = false;
document.getElementById("add_more").disabled = true;
document.getElementById("finish").disabled = false;
document.getElementById('Coefficients').value = '';
document.getElementById('Exponents').value = '';
}
function add_more2(){
var s = document.getElementById("c_n_2");
s.style.cursor = "default";
var p = document.getElementById("add_more2");
p.style.cursor = "no-drop";
var p = document.getElementById("finish2");
p.style.cursor = "default";
document.getElementById("c_n_2").disabled = false;
document.getElementById("add_more2").disabled = true;
document.getElementById("finish2").disabled = false;
document.getElementById('Coefficients2').value = '';
document.getElementById('Exponents2').value = '';
}
function finish_first(){
var s = document.getElementById("f_p_s");
s.style.display = "none";
var p = document.getElementById("s_p_s");
p.style.display = "block";
}
function finish_second(){
var s = document.getElementById("s_p_s");
s.style.display = "none";
var p = document.getElementById("d_s");
p.style.display = "block";
}
function start(){
var p = document.getElementById("starting");
p.style.display = "block";
var s = document.getElementById("start-button");
s.style.display = "none"
}
function addition(){
var l1 = coe1.length;
var l2 = coe2.length;
var r1 = ex1.length;
var r2 = ex2.length;
console.log(coe1);
console.log(ex1);
console.log(coe2);
console.log(ex2);
console.log(l1);
console.log(l2);
console.log(r1);
console.log(r2);
var large;
if (r1>r2){ large = r2; }
else{ large = r1; }
for(i=0; i<large; i++)
{
if(ex1[i]==ex2[i]){
result_coe.push(parseInt(coe1.pop())+parseInt(coe2.pop()));
result_ex.push(ex1[i]);
}
else if(ex1[i]>ex2[i]){
result_coe.push(parseInt(coe1[i]));
result_ex.push(parseInt(ex2[i]));
}
else if(ex1[i]<ex2[i]){
result_coe.push(parseInt(coe2[i]));
result_ex.push(parseInt(ex2[i]));
}
}
console.log(result_coe);
console.log(result_ex);
}