-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
71 lines (49 loc) · 1.96 KB
/
code.js
File metadata and controls
71 lines (49 loc) · 1.96 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
function convertir(){
var array = document.getElementById("input1").value.split('\n');
var array_chemical = document.getElementById("input2").value.split('\n');
var elements = array.length;
var chemical_elements = array_chemical.length;
var temporal2;
var temporal3;
var temporal2_2;
var array_chemical1;
var array_chemical2;
var temp_chemical_value;
const chec_elemt = new Map();
var nums = 0;
var array3;
for(var i = 0; i<chemical_elements; i++){
array_chemical1 = array_chemical[i].replace(/\s+/g, '&');
array_chemical2 = array_chemical1.split('&');
chec_elemt.set(array_chemical2[1],array_chemical2[0]);
}
for(var j = 0; j<elements; j++){
temporal2 = array[j].replace(/\s+/g, '&');
temporal3 = temporal2.split('&');
temporal3[4] = j+1;
if(j==0){
for (let [key, value] of chec_elemt) {
if(key == temporal3[0]){
temporal3[5] = value;
}
}
array3 = temporal3[1]+" "+temporal3[2]+" "+temporal3[3]+" "+temporal3[5]+" "+temporal3[4]+" "+temporal3[0]+'\n';
}
else{
for (let [key, value] of chec_elemt) {
if(key == temporal3[0]){
temporal3[5] = value;
}
}
array3 = array3 + temporal3[1]+" "+temporal3[2]+" "+temporal3[3]+" "+temporal3[5]+" "+temporal3[4]+" "+temporal3[0]+'\n';
}
}
document.getElementById("input3").value = array3;
}
function borrar_datos(){
document.getElementById("input1").value = "";
document.getElementById("input2").value = "";
document.getElementById("input3").value = "";
}
document.getElementById("boton1").onclick = convertir;
document.getElementById("boton2").onclick = borrar_datos;