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 | command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
23 | form.codigo.value="\ |
---|
24 | echo \"[0] $MSG_SCRIPTS_TASK_START " + command + " \" | tee -a $OGLOGFILE $OGLOGSESSION \n " + |
---|
25 | command + " | tee -a $OGLOGCOMMAND \n "; |
---|
26 | //cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value + " | tee -a $OGLOGCOMMAND \n"; |
---|
27 | //form.codigo.value="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
28 | } |
---|
29 | |
---|
30 | function codeDeployImage(form){ |
---|
31 | switch (form.idmetodo.value) |
---|
32 | { |
---|
33 | case "MULTICAST": |
---|
34 | protocol="MULTICAST " + form.mcastpuerto.value + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " "; |
---|
35 | break; |
---|
36 | case "TORRENT": |
---|
37 | protocol=" TORRENT " + form.modp2p.value + ":" + form.timep2p.value; |
---|
38 | break; |
---|
39 | case "UNICAST": |
---|
40 | protocol=" UNICAST"; |
---|
41 | break; |
---|
42 | } |
---|
43 | //form.codigo.value="deployImage REPO /"; |
---|
44 | if (form.modo[0].checked) |
---|
45 | { |
---|
46 | // UHU - Distinguimos entre disco y particion, el valor de idparticion sera disco;particion. eje. 1;1 |
---|
47 | var diskPart = form.idparticion.value.split(";"); |
---|
48 | command="deployImage REPO /" + form.idimagen.value + " "+diskPart[0]+" " + diskPart[1] + " " + protocol ; |
---|
49 | form.codigo.value="\ |
---|
50 | echo [0] $MSG_SCRIPTS_TASK_START " + command +" | tee -a $OGLOGSESSION \n \ " + |
---|
51 | command + " | tee -a $OGLOGCOMMAND"; |
---|
52 | //form.codigo.value="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol ; |
---|
53 | } |
---|
54 | else |
---|
55 | { |
---|
56 | command="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
57 | form.codigo.value="\ |
---|
58 | echo [0] $MSG_SCRIPTS_TASK_START " + command +" | tee -a $OGLOGSESSION \n \ " + |
---|
59 | command + " | tee -a $OGLOGCOMMAND"; |
---|
60 | //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
61 | } |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | function codeParticionado(form){ |
---|
66 | var n_disk = form.n_disk.value; |
---|
67 | var tipo_part_table = form.tipo_part_table.value; |
---|
68 | // Comprobamos si la opcion elejida es GPT o MSDOS para llamar a una funcion u otra |
---|
69 | if(tipo_part_table == "GPT"){ |
---|
70 | codeParticionadoGPT(form); |
---|
71 | } |
---|
72 | else{ |
---|
73 | codeParticionadoMSDOS(form); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | function codeParticionadoMSDOS (form) { |
---|
79 | var partCode=""; |
---|
80 | var logicalCode=""; |
---|
81 | var cacheCode; |
---|
82 | var cacheSize; |
---|
83 | var extended=false; |
---|
84 | var n_disk = form.n_disk.value; |
---|
85 | var tipo_part_table = form.tipo_part_table.value; |
---|
86 | var maxParts = 4; |
---|
87 | |
---|
88 | // Comprobamos si esta seleccionada la cuarta particion y no es CACHE |
---|
89 | if(form.check4.checked && form.part4.value != "CACHE") |
---|
90 | maxParts = 5; |
---|
91 | |
---|
92 | for (var nPart=1; nPart<maxParts; nPart++) { |
---|
93 | var partCheck=eval("form.check"+nPart); |
---|
94 | if (partCheck.checked) { |
---|
95 | var partType=eval("form.part"+nPart); |
---|
96 | if (partType.value == "CUSTOM" ) { |
---|
97 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
98 | partCode += " " + partTypeCustom.value; |
---|
99 | if (partTypeCustom.value == "EXTENDED") { |
---|
100 | extended=true; |
---|
101 | } |
---|
102 | } else { |
---|
103 | partCode += " " + partType.value; |
---|
104 | if (partType.value == "EXTENDED") { |
---|
105 | extended=true; |
---|
106 | } |
---|
107 | } |
---|
108 | var partSize=eval("form.size"+nPart); |
---|
109 | if (partSize.value == "CUSTOM" ) { |
---|
110 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
111 | partCode += ":" + partSizeCustom.value; |
---|
112 | } else { |
---|
113 | partCode += ":" + partSize.value; |
---|
114 | } |
---|
115 | } else { |
---|
116 | partCode += " EMPTY:0"; |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | var cacheCode=""; |
---|
121 | |
---|
122 | // Si se selecciono la particion 4 y es CACHE |
---|
123 | if(form.part4.value == "CACHE"){ |
---|
124 | if (form.check4.checked) { |
---|
125 | if (form.size4.value == "0") { |
---|
126 | cacheCode="\ |
---|
127 | echo \"[20] $MSG_HELP_ogGetPartitionSize CACHE\" | tee -a $OGLOGSESSION \n \ |
---|
128 | sizecache=`ogGetCacheSize` \n \ |
---|
129 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
130 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
131 | ogUpdatePartitionTable "+n_disk+" | tee -a $OGLOGCOMMAND \n \ |
---|
132 | echo \"[50] $MSG_HELP_ogCreateCache \" | tee -a $OGLOGSESSION \n \ |
---|
133 | initCache "+n_disk+" $sizecache &>/dev/null | tee -a $OGLOGCOMMAND \n "; |
---|
134 | } else { |
---|
135 | if (form.size4.value == "CUSTOM") { |
---|
136 | cacheSize = form.size4custom.value; |
---|
137 | } else { |
---|
138 | cacheSize = form.size4.value; |
---|
139 | } |
---|
140 | cacheCode="\ |
---|
141 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
142 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
143 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
144 | echo \"[50] $MSG_HELP_ogCreateCache \" | tee -a $OGLOGSESSION \n \ |
---|
145 | initCache " + n_disk + " " + cacheSize + " &>/dev/null | tee -a $OGLOGCOMMAND"; |
---|
146 | } |
---|
147 | } else { |
---|
148 | cacheCode="\ |
---|
149 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
150 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
151 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
152 | partCode += " EMPTY:0"; |
---|
153 | } |
---|
154 | } |
---|
155 | |
---|
156 | if (extended) { |
---|
157 | var lastLogical=5; |
---|
158 | for (var nPart=9; nPart>5; nPart--) { |
---|
159 | if (eval ("form.check"+nPart+".checked")) { |
---|
160 | lastLogical = nPart; |
---|
161 | break; |
---|
162 | } |
---|
163 | } |
---|
164 | for (var nPart=5; nPart<=lastLogical; nPart++) { |
---|
165 | var partCheck=eval("form.check"+nPart); |
---|
166 | if (partCheck.checked) { |
---|
167 | var partType=eval("form.part"+nPart); |
---|
168 | if (partType.value == "CUSTOM" ) { |
---|
169 | var partTypeCustom=eval("form.part"+nPart+"custom"); |
---|
170 | logicalCode += " " + partTypeCustom.value; |
---|
171 | } else { |
---|
172 | logicalCode += " " + partType.value; |
---|
173 | } |
---|
174 | var partSize=eval("form.size"+nPart); |
---|
175 | if (partSize.value == "CUSTOM" ) { |
---|
176 | var partSizeCustom=eval("form.size"+nPart+"custom"); |
---|
177 | logicalCode += ":" + partSizeCustom.value; |
---|
178 | } else { |
---|
179 | logicalCode += ":" + partSize.value; |
---|
180 | } |
---|
181 | } else { |
---|
182 | logicalCode += " EMPTY:0"; |
---|
183 | } |
---|
184 | } |
---|
185 | partCode += logicalCode; |
---|
186 | } |
---|
187 | |
---|
188 | form.codigo.value="\ |
---|
189 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
190 | echo \"[0] $MSG_HELP_ogCreatePartitions \" | tee -a $OGLOGSESSION $OGLOGFILE \n \ |
---|
191 | echo \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\" | tee -a $OGLOGSESSION \n \ |
---|
192 | ogUnmountCache \n \ |
---|
193 | ogUnmountAll "+n_disk+" \n \ |
---|
194 | " + cacheCode + " \n \ |
---|
195 | echo \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\" | tee -a $OGLOGSESSION \n \ |
---|
196 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION \n \ |
---|
197 | echo \"[70] $MSG_HELP_ogCreatePartitions " + partCode + " \" | tee -a $OGLOGSESSION \n \ |
---|
198 | ogCreatePartitions "+n_disk+" " + partCode + " | tee -a $OGLOGCOMMAND \n \ |
---|
199 | echo \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\" | tee -a $OGLOGSESSION \n \ |
---|
200 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
201 | echo \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\" | tee -a $OGLOGSESSION $OGLOGFILE \n \ |
---|
202 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
203 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
204 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION $OGLOGFILE \n \ |
---|
205 | reboot \n"; |
---|
206 | } |
---|
207 | |
---|
208 | |
---|
209 | function codeParticionadoGPT (form) { |
---|
210 | var partCode=""; |
---|
211 | var logicalCode=""; |
---|
212 | var cacheCode=""; |
---|
213 | var cacheSize; |
---|
214 | var extended=false; |
---|
215 | var n_disk = form.n_disk.value; |
---|
216 | var tipo_part_table = form.tipo_part_table.value; |
---|
217 | numParts=document.getElementById("numGPTpartitions").value; |
---|
218 | |
---|
219 | for (var nPart=1; nPart <= numParts; nPart++) { |
---|
220 | var partCheck=eval("form.checkGPT"+nPart); |
---|
221 | if (partCheck.checked) { |
---|
222 | // Distinguimos entre cache y el resto de particiones |
---|
223 | // Solo tratamos la particion 4 como cache, si se selecciono este tipo |
---|
224 | if(nPart == 4 && form.partGPT4.value == "CACHE") { |
---|
225 | if (form.sizeGPT4.value == "0") { |
---|
226 | cacheCode="\ |
---|
227 | echo \"[20] $MSG_HELP_ogGetPartitionSize CACHE\" | tee -a $OGLOGSESSION \n \ |
---|
228 | sizecache=`ogGetCacheSize` \n \ |
---|
229 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
230 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
231 | ogUpdatePartitionTable "+n_disk+" | tee -a $OGLOGCOMMAND \n \ |
---|
232 | echo \"[50] $MSG_HELP_ogCreateCache \" | tee -a $OGLOGSESSION \n \ |
---|
233 | initCache "+ n_disk +" $sizecache &>/dev/null | tee -a $OGLOGCOMMAND \n "; |
---|
234 | } else { |
---|
235 | if (form.sizeGPT4.value == "CUSTOM") { |
---|
236 | cacheSize = form.sizeGPT4custom.value; |
---|
237 | } else { |
---|
238 | cacheSize = form.sizeGPT4.value; |
---|
239 | } |
---|
240 | cacheCode="\ |
---|
241 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
242 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
243 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
244 | echo \"[50] $MSG_HELP_ogCreateCache \" | tee -a $OGLOGSESSION \n \ |
---|
245 | initCache " + n_disk +" "+ cacheSize + " &>/dev/null | tee -a $OGLOGCOMMAND"; |
---|
246 | } |
---|
247 | } else{ |
---|
248 | var partType=eval("form.partGPT"+nPart); |
---|
249 | if (partType.value == "CUSTOM" ) { |
---|
250 | var partTypeCustom=eval("form.partGPT"+nPart+"custom"); |
---|
251 | partCode += " " + partTypeCustom.value; |
---|
252 | } else { |
---|
253 | partCode += " " + partType.value; |
---|
254 | } |
---|
255 | var partSize=eval("form.sizeGPT"+nPart); |
---|
256 | if (partSize.value == "CUSTOM" ) { |
---|
257 | var partSizeCustom=eval("form.sizeGPT"+nPart+"custom"); |
---|
258 | partCode += ":" + partSizeCustom.value; |
---|
259 | } else { |
---|
260 | partCode += ":" + partSize.value; |
---|
261 | } |
---|
262 | } |
---|
263 | } else { |
---|
264 | if(nPart == 4){ |
---|
265 | cacheCode="\ |
---|
266 | echo \"[30] $MSG_HELP_ogDeletePartitionTable - $MSG_HELP_ogUpdatePartitionTable 1\" | tee -a $OGLOGSESSION \n \ |
---|
267 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
268 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
269 | partCode += " EMPTY:0"; |
---|
270 | } else{ |
---|
271 | partCode += " EMPTY:0"; |
---|
272 | } |
---|
273 | } |
---|
274 | } |
---|
275 | form.codigo.value="\ |
---|
276 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
277 | echo \"[0] $MSG_HELP_ogCreatePartitions \" | tee -a $OGLOGSESSION $OGLOGFILE \n \ |
---|
278 | echo \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\" | tee -a $OGLOGSESSION \n \ |
---|
279 | ogUnmountCache \n \ |
---|
280 | ogUnmountAll "+n_disk+" \n \ |
---|
281 | " + cacheCode + " \n \ |
---|
282 | echo \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\" | tee -a $OGLOGSESSION \n \ |
---|
283 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION \n \ |
---|
284 | echo \"[70] $MSG_HELP_ogCreatePartitions " + partCode + " \" | tee -a $OGLOGSESSION \n \ |
---|
285 | ogCreatePartitions "+n_disk+" " + partCode + " | tee -a $OGLOGCOMMAND \n \ |
---|
286 | echo \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\" | tee -a $OGLOGSESSION \n \ |
---|
287 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
288 | echo \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\" | tee -a $OGLOGSESSION $OGLOGFILE \n \ |
---|
289 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
290 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
291 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION $OGLOGFILE \n \ |
---|
292 | reboot \n"; |
---|
293 | } |
---|
294 | |
---|
295 | |
---|
296 | function showPartitionForm (tipo_table_part) { |
---|
297 | document.getElementById("form"+tipo_table_part).style.display="inline"; |
---|
298 | if(tipo_table_part == "MSDOS"){ |
---|
299 | // De los dos tipos, se oculta el otro |
---|
300 | document.getElementById("formGPT").style.display="none"; |
---|
301 | } else{ |
---|
302 | document.getElementById("formMSDOS").style.display="none"; |
---|
303 | } |
---|
304 | } |
---|
305 | |
---|
306 | |
---|
307 | // Código de pulsación de selección de partición. |
---|
308 | function clickPartitionCheckbox (form, npart, isGPT) { |
---|
309 | // Si el parametro no esta definido, se toma como false |
---|
310 | isGPT = (isGPT)?isGPT:"false"; |
---|
311 | if(isGPT == true){ |
---|
312 | prefix="GPT"; |
---|
313 | } else { |
---|
314 | prefix=""; |
---|
315 | } |
---|
316 | var partCheck=eval("form.check"+prefix+npart); |
---|
317 | var partType=eval("form.part"+prefix+npart); |
---|
318 | var partSize=eval("form.size"+prefix+npart); |
---|
319 | var partTypeCustom=eval("form.part"+prefix+npart+"custom"); |
---|
320 | var partSizeCustom=eval("form.size"+prefix+npart+"custom"); |
---|
321 | var freeDisk=document.getElementById("freedisk"+prefix); |
---|
322 | //var logical=document.getElementById("logicas"+prefix); |
---|
323 | if (partCheck.checked) { |
---|
324 | partType.disabled=false; |
---|
325 | partSize.disabled=false; |
---|
326 | if(npart != 4){ |
---|
327 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
328 | partTypeCustom.disabled=false; |
---|
329 | } |
---|
330 | } |
---|
331 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
332 | partSizeCustom.disabled=false; |
---|
333 | } else { |
---|
334 | partSizeCustom.disabled=true; |
---|
335 | } |
---|
336 | } else { |
---|
337 | partType.disabled=true; |
---|
338 | partSize.disabled=true; |
---|
339 | // El campo TypeCustom no existe para la particion 4 |
---|
340 | if(npart != 4) |
---|
341 | partTypeCustom.disabled=true; |
---|
342 | partSizeCustom.disabled=true; |
---|
343 | } |
---|
344 | if (npart <= 4) { |
---|
345 | // Si el formulario es GPT no hay extendidas |
---|
346 | if(isGPT != true){ |
---|
347 | checkExtendedPartition(form); |
---|
348 | } |
---|
349 | calculateFreeDisk(form); |
---|
350 | } |
---|
351 | } |
---|
352 | |
---|
353 | |
---|
354 | // Código para calcular el espacio libre del disco. |
---|
355 | function calculateFreeDisk(form) { |
---|
356 | // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente |
---|
357 | if(document.getElementById("tipo_part_table").value == "GPT"){ |
---|
358 | calculateFreeGPTDisk(form); |
---|
359 | } |
---|
360 | var freeDisk=document.getElementById("freedisk"); |
---|
361 | freeDisk.value=form.minsize.value; |
---|
362 | for (npart=1; npart<=4; npart++) { |
---|
363 | var partCheck=eval("form.check"+npart); |
---|
364 | var partSize=eval("form.size"+npart); |
---|
365 | var partSizeCustom=eval("form.size"+npart+"custom"); |
---|
366 | if (partCheck.checked) { |
---|
367 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
368 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
369 | } else { |
---|
370 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
371 | } |
---|
372 | } |
---|
373 | } |
---|
374 | if (parseInt(freeDisk.value) < 0) { |
---|
375 | freeDisk.style.fontWeight = "bold"; |
---|
376 | freeDisk.style.fontStyle = "italic"; |
---|
377 | } else { |
---|
378 | freeDisk.style.fontWeight = "normal"; |
---|
379 | freeDisk.style.fontStyle = "normal"; |
---|
380 | } |
---|
381 | if (form.size4.value == 0) { |
---|
382 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
383 | } |
---|
384 | } |
---|
385 | |
---|
386 | // Código para calcular el espacio libre del disco. en el formulario GPT |
---|
387 | function calculateFreeGPTDisk(form) { |
---|
388 | // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente |
---|
389 | if(document.getElementById("tipo_part_table").value == "MSDOS"){ |
---|
390 | calculateFreeDisk(form); |
---|
391 | } |
---|
392 | |
---|
393 | var freeDisk=document.getElementById("freediskGPT"); |
---|
394 | freeDisk.value=form.minsize.value; |
---|
395 | // Capturamos el numero de particiones que hay hechas |
---|
396 | numParts=document.getElementById("numGPTpartitions").value; |
---|
397 | for (npart=1; npart<=numParts; npart++) { |
---|
398 | var partCheck=eval("form.checkGPT"+npart); |
---|
399 | var partSize=eval("form.sizeGPT"+npart); |
---|
400 | var partSizeCustom=eval("form.sizeGPT"+npart+"custom"); |
---|
401 | if (partCheck.checked) { |
---|
402 | if (partSize.options[partSize.selectedIndex].value == "CUSTOM") { |
---|
403 | freeDisk.value -= parseInt(partSizeCustom.value); |
---|
404 | } else { |
---|
405 | freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value); |
---|
406 | } |
---|
407 | } |
---|
408 | } |
---|
409 | if (parseInt(freeDisk.value) < 0) { |
---|
410 | freeDisk.style.fontWeight = "bold"; |
---|
411 | freeDisk.style.fontStyle = "italic"; |
---|
412 | } else { |
---|
413 | freeDisk.style.fontWeight = "normal"; |
---|
414 | freeDisk.style.fontStyle = "normal"; |
---|
415 | } |
---|
416 | if (form.size4.value == 0) { |
---|
417 | freeDisk.value += " (- cache)"; // Aviso de caché sin modificar. |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
422 | function addGPTPartition(){ |
---|
423 | var partitionTypes = ""; |
---|
424 | partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>'; |
---|
425 | partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>'; |
---|
426 | partitionTypes+='<OPTION value="LINUX"> Linux </OTION>'; |
---|
427 | partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>'; |
---|
428 | partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>'; |
---|
429 | partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>'; |
---|
430 | partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>'; |
---|
431 | partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>'; |
---|
432 | partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>'; |
---|
433 | partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>'; |
---|
434 | partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>'; |
---|
435 | partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>'; |
---|
436 | partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>'; |
---|
437 | partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>'; |
---|
438 | partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>'; |
---|
439 | partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>'; |
---|
440 | partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>'; |
---|
441 | partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>'; |
---|
442 | partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>'; |
---|
443 | partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>'; |
---|
444 | partitionTypes+='<OPTION value="EFI"> EFI </OPTION>'; |
---|
445 | partitionTypes+='<OPTION value="MBR"> MBR </OPTION>'; |
---|
446 | partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>'; |
---|
447 | |
---|
448 | |
---|
449 | table = document.getElementById("particionesGPT"); |
---|
450 | // Capturamos el numero de particiones, antes incrementamos |
---|
451 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1 |
---|
452 | numPart=document.getElementById("numGPTpartitions").value; |
---|
453 | partitionRow = table.insertRow(-1); |
---|
454 | partitionRow.id = "trPartition"+numPart; |
---|
455 | partitionRow.innerHTML="<td> \ |
---|
456 | <input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partición "+numPart+"</td> \ |
---|
457 | <td>\ |
---|
458 | <select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \ |
---|
459 | if (this.options[this.selectedIndex].value == \'CUSTOM\') { \ |
---|
460 | this.form.partGPT"+numPart+"custom.disabled=false; \ |
---|
461 | } else { \ |
---|
462 | this.form.partGPT"+numPart+"custom.disabled=true; \ |
---|
463 | }'><option value='CUSTOM'> Personalizar </option> \ |
---|
464 | </select> \ |
---|
465 | <br> \ |
---|
466 | <select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \ |
---|
467 | </td> \ |
---|
468 | <td> \ |
---|
469 | <select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \ |
---|
470 | if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \ |
---|
471 | this.form.sizeGPT"+numPart+"custom.disabled=false; \ |
---|
472 | } else { \ |
---|
473 | this.form.sizeGPT"+numPart+"custom.disabled=true; \ |
---|
474 | } \ |
---|
475 | ' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \ |
---|
476 | </select> \ |
---|
477 | <br /> \ |
---|
478 | <input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \ |
---|
479 | </td>" |
---|
480 | |
---|
481 | } |
---|
482 | |
---|
483 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
484 | function deleteGPTPartition(){ |
---|
485 | table = document.getElementById("particionesGPT"); |
---|
486 | // Capturamos el numero de particiones |
---|
487 | numPart=document.getElementById("numGPTpartitions").value; |
---|
488 | // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador |
---|
489 | if(numPart > 4){ |
---|
490 | partitionRow = document.getElementById("trPartition"+numPart); |
---|
491 | table.deleteRow(partitionRow.rowIndex); |
---|
492 | // Decrementamos el numero de particiones |
---|
493 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1; |
---|
494 | } |
---|
495 | } |
---|
496 | |
---|
497 | // Código para comprobar si hay partición extendida activa para mostrar las lógicas. |
---|
498 | function checkExtendedPartition(form) { |
---|
499 | var logical=document.getElementById("logicas"); |
---|
500 | var visible=false; |
---|
501 | for (npart=1; npart<=4; npart++) { |
---|
502 | var partCheck=eval("form.check"+npart); |
---|
503 | var partType=eval("form.part"+npart); |
---|
504 | var partTypeCustom=eval("form.part"+npart+"custom"); |
---|
505 | if (partCheck.checked) { |
---|
506 | partType.style.fontWeight = "normal"; |
---|
507 | |
---|
508 | if (partType.value == "EXTENDED") { |
---|
509 | visible=true; |
---|
510 | partType.style.fontWeight = "bold"; |
---|
511 | } |
---|
512 | // La particion 4 no tiene partTypeCustom |
---|
513 | if(npart != 4){ |
---|
514 | partTypeCustom.style.fontWeight = "normal"; |
---|
515 | if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") { |
---|
516 | visible=true; |
---|
517 | partTypeCustom.style.fontWeight = "bold"; |
---|
518 | } |
---|
519 | } |
---|
520 | } |
---|
521 | } |
---|
522 | if (visible) { |
---|
523 | logical.style.visibility="visible"; |
---|
524 | } else { |
---|
525 | logical.style.visibility="hidden"; |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|