1 | // *********************************************************************************************************** |
---|
2 | // Libreria de scripts de Javascript |
---|
3 | // Autor: |
---|
4 | // Fecha Creación: 2011 |
---|
5 | // Fecha Ãltima modificación: enero-2011 |
---|
6 | // Nombre del fichero: asistentes.js |
---|
7 | // Descripción : |
---|
8 | // Este fichero implementa las funciones javascript del fichero AsistentesEjecutarScripts.php (Comandos) |
---|
9 | // *********************************************************************************************************** |
---|
10 | |
---|
11 | function codeCloneRemotePartition(form){ |
---|
12 | switch (form.idmetodo.value) |
---|
13 | { |
---|
14 | case "MULTICAST": |
---|
15 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
16 | break; |
---|
17 | case "UNICAST": |
---|
18 | protocol="UNICAST " + form.ucastport.value + ":" + form.ucastclient.value + " "; |
---|
19 | break; |
---|
20 | } |
---|
21 | //form.codigo.value="cloneRemoteFromMaster " + form.ipMaster.value + " 1 " + form.PartOrigen.value + " " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " 1 " + form.PartOrigen.value + " " + form.tool.value + " " + form.compresor.value; |
---|
22 | form.codigo.value="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
23 | |
---|
24 | } |
---|
25 | |
---|
26 | function codeDeployImage(form){ |
---|
27 | switch (form.idmetodo.value) |
---|
28 | { |
---|
29 | case "MULTICAST": |
---|
30 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
31 | break; |
---|
32 | case "TORRENT": |
---|
33 | protocol=" TORRENT " + form.modp2p.value + ":" + form.timep2p.value; |
---|
34 | break; |
---|
35 | case "UNICAST": |
---|
36 | protocol=" UNICAST"; |
---|
37 | break; |
---|
38 | } |
---|
39 | //form.codigo.value="deployImage REPO /"; |
---|
40 | if (form.modo[0].checked) |
---|
41 | { |
---|
42 | form.codigo.value="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol ; |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
47 | } |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | function codeParticionado (form) { |
---|
52 | var partCode=""; |
---|
53 | var logicalCode=""; |
---|
54 | var cacheCode; |
---|
55 | var cacheSize; |
---|
56 | var extended=false; |
---|
57 | |
---|
58 | for (var nPart=1; nPart<4; nPart++) { |
---|
59 | var partCheck=eval("form.check"+nPart); |
---|
60 | if (partCheck.checked) { |
---|
61 | var partType=eval("form.part"+nPart); |
---|
62 | if (partType.value == "CUSTOM" ) { |
---|
63 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
64 | partCode += " " + partTypeCustom.value; |
---|
65 | if (partTypeCustom.value == "EXTENDED") { |
---|
66 | extended=true; |
---|
67 | } |
---|
68 | } else { |
---|
69 | partCode += " " + partType.value; |
---|
70 | if (partType.value == "EXTENDED") { |
---|
71 | extended=true; |
---|
72 | } |
---|
73 | } |
---|
74 | var partSize=eval("form.size"+nPart); |
---|
75 | if (partSize.value == "CUSTOM" ) { |
---|
76 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
77 | partCode += ":" + partSizeCustom.value; |
---|
78 | } else { |
---|
79 | partCode += ":" + partSize.value; |
---|
80 | } |
---|
81 | } else { |
---|
82 | partCode += " EMPTY:0"; |
---|
83 | } |
---|
84 | } |
---|
85 | if (form.check4.checked) { |
---|
86 | if (form.size4.value == "0") { |
---|
87 | cacheCode = " ogUnmountCache \n ogUnmountAll 1 \n sizecache=`ogGetPartitionSize 1 4` \n ogDeletePartitionTable 1 \n ogUpdatePartitionTable 1 \n initCache $sizecache "; |
---|
88 | } else { |
---|
89 | if (form.size4.value == "CUSTOM") { |
---|
90 | cacheSize = form.size4custom.value; |
---|
91 | } else { |
---|
92 | cacheSize = form.size4.value; |
---|
93 | } |
---|
94 | cacheCode = " ogUnmountCache \n ogUnmountAll 1 \n ogDeletePartitionTable 1 \n ogUpdatePartitionTable 1 \n initCache " + cacheSize; |
---|
95 | } |
---|
96 | } else { |
---|
97 | cacheCode = " ogUnmountCache \n ogUnmountAll 1 \n ogDeletePartitionTable 1 \n ogUpdatePartitionTable 1 "; |
---|
98 | partCode += " EMPTY:0"; |
---|
99 | } |
---|
100 | if (extended) { |
---|
101 | var lastLogical=5; |
---|
102 | for (var nPart=9; nPart>5; nPart--) { |
---|
103 | if (eval ("form.check"+nPart+".checked")) { |
---|
104 | lastLogical = nPart; |
---|
105 | break; |
---|
106 | } |
---|
107 | } |
---|
108 | for (var nPart=5; nPart<=lastLogical; nPart++) { |
---|
109 | var partCheck=eval("form.check"+nPart); |
---|
110 | if (partCheck.checked) { |
---|
111 | var partType=eval("form.part"+nPart); |
---|
112 | if (partType.value == "CUSTOM" ) { |
---|
113 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
114 | logicalCode += " " + partTypeCustom.value; |
---|
115 | } else { |
---|
116 | logicalCode += " " + partType.value; |
---|
117 | } |
---|
118 | var partSize=eval("form.size"+nPart); |
---|
119 | if (partSize.value == "CUSTOM" ) { |
---|
120 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
121 | logicalCode += ":" + partSizeCustom.value; |
---|
122 | } else { |
---|
123 | logicalCode += ":" + partSize.value; |
---|
124 | } |
---|
125 | } else { |
---|
126 | logicalCode += " EMPTY:0"; |
---|
127 | } |
---|
128 | } |
---|
129 | partCode += logicalCode; |
---|
130 | } |
---|
131 | |
---|
132 | form.codigo.value="\ |
---|
133 | " + cacheCode + " \n \ |
---|
134 | ogListPartitions 1 \n \ |
---|
135 | ogCreatePartitions 1 " + partCode + " \n \ |
---|
136 | ogSetPartitionActive 1 1 \n \ |
---|
137 | ogUpdatePartitionTable 1 \n \ |
---|
138 | ogListPartitions 1 \n"; |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | // Código de pulsación de selección de partición. |
---|
143 | function clickPartitionCheckbox(form, npart) { |
---|
144 | var partCheck=eval("form.check"+npart); |
---|
145 | var partType=eval("form.part"+npart); |
---|
146 | var partSize=eval("form.size"+npart); |
---|
147 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
148 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
149 | var freeDisk=document.getElementById("freedisk"); |
---|
150 | var logical=document.getElementById("logicas"); |
---|
151 | if (partCheck.checked) { |
---|
152 | partType.disabled=false; |
---|
153 | partSize.disabled=false; |
---|
154 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
155 | partTypeCustom.disabled=false; |
---|
156 | } |
---|
157 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
158 | partSizeCustom.disabled=false; |
---|
159 | } else { |
---|
160 | partSizeCustom.disabled=true; |
---|
161 | } |
---|
162 | } else { |
---|
163 | partType.disabled=true; |
---|
164 | partSize.disabled=true; |
---|
165 | partTypeCustom.disabled=true; |
---|
166 | partSizeCustom.disabled=true; |
---|
167 | } |
---|
168 | if (npart <= 4) { |
---|
169 | checkExtendedPartition(form); |
---|
170 | calculateFreeDisk(form); |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | |
---|
175 | // Código para calcular el espacio libre del disco. |
---|
176 | function calculateFreeDisk(form) { |
---|
177 | var freeDisk=document.getElementById("freedisk"); |
---|
178 | freeDisk.value=form.minsize.value; |
---|
179 | for (npart=1; npart<=4; npart++) { |
---|
180 | var partCheck=eval("form.check"+npart); |
---|
181 | var partSize=eval("form.size"+npart); |
---|
182 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
183 | if (partCheck.checked) { |
---|
184 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
185 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
186 | } else { |
---|
187 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | if (parseInt(freeDisk.value) < 0) { |
---|
192 | freeDisk.style.fontWeight = "bold"; |
---|
193 | freeDisk.style.fontStyle = "italic"; |
---|
194 | } else { |
---|
195 | freeDisk.style.fontWeight = "normal"; |
---|
196 | freeDisk.style.fontStyle = "normal"; |
---|
197 | } |
---|
198 | if (form.size4.value == 0) { |
---|
199 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | // Código para comprobar si hay partición extendida activa para mostrar las lógicas. |
---|
204 | function checkExtendedPartition(form) { |
---|
205 | var logical=document.getElementById("logicas"); |
---|
206 | var visible=false; |
---|
207 | for (npart=1; npart<4; npart++) { |
---|
208 | var partCheck=eval("form.check"+npart); |
---|
209 | var partType=eval("form.part"+npart); |
---|
210 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
211 | if (partCheck.checked) { |
---|
212 | partType.style.fontWeight = "normal"; |
---|
213 | partTypeCustom.style.fontWeight = "normal"; |
---|
214 | if (partType.value == "EXTENDED") { |
---|
215 | visible=true; |
---|
216 | partType.style.fontWeight = "bold"; |
---|
217 | } |
---|
218 | if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") { |
---|
219 | visible=true; |
---|
220 | partTypeCustom.style.fontWeight = "bold"; |
---|
221 | } |
---|
222 | } |
---|
223 | } |
---|
224 | if (visible) { |
---|
225 | logical.style.visibility="visible"; |
---|
226 | } else { |
---|
227 | logical.style.visibility="hidden"; |
---|
228 | } |
---|
229 | } |
---|
230 | |
---|