source: admin/WebConsole/asistentes/jscripts/asistentes.js @ d81fc6a

Last change on this file since d81fc6a was fac0b87, checked in by ramon <ramongomez@…>, 8 years ago

#754: Integrar los cambios de la versión de mantenimiento OpenGnSys 1.0.6b a la rama principal.

git-svn-id: https://opengnsys.es/svn/trunk@5143 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 23.1 KB
Line 
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// version 1.0.6b y 1.1: codeDeployImage: Compone atributo para el comando restaurar imagen (ticket #757)
10// autor: Irina Gomez, ETSII Universidad de Sevilla
11// fecha: 2016-10-27
12// versión 1.0.6b: Si existe Cache al crear las particiones reservamos la cuarta libre (ticket #753)
13// autor: Irina Gomez, ETSII Universidad de Sevilla
14// fecha: 2016-12-15
15// ***********************************************************************************************************
16
17function codeCloneRemotePartition(form){
18var command ;
19switch (form.idmetodo.value)
20{
21        case "MULTICAST":
22                protocol="MULTICAST " + form.mcastpuerto.value  + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " ";
23                break;
24        case "UNICAST":
25                protocol="UNICAST " +  form.ucastport.value + ":" + form.ucastclient.value + " ";
26                break;
27}
28//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;
29command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + "  " + protocol  + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value;
30form.codigo.value="\
31ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \
32ogExecAndLog command " + command + " \n ";
33}
34
35// disableDirect(form): En Deploy de imagenes si se elige updateCache se impide elegir multicast-direct o unicast-direct
36function disableDirect(form){
37        // MULTICAST-DIRECT
38        form.idmetodo.options[2].disabled=true;
39        // UNICAST-DIRECT
40        form.idmetodo.options[4].disabled=true;
41}
42// enableDirect(form): En Deploy de imagenes si se elige deployCache se permite elegir multicast-direct o unicast-direct
43function enableDirect(form){
44        // MULTICAST-DIRECT
45        form.idmetodo.options[2].disabled=false;
46        // UNICAST-DIRECT
47        form.idmetodo.options[4].disabled=false;
48}
49
50
51function codeDeployImage(form){
52switch (form.idmetodo.value)
53{
54        case "MULTICAST":
55                protocol="MULTICAST " + form.mcastpuerto.value  + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " ";
56                break;
57        case "MULTICAST-DIRECT":
58                protocol="MULTICAST-DIRECT " + form.mcastpuerto.value  + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " ";
59                break;
60        case "TORRENT":
61                protocol="TORRENT " +  form.modp2p.value + ":" + form.timep2p.value;
62                break;
63        case "UNICAST":
64                protocol="UNICAST";
65                break;
66        case "UNICAST-DIRECT":
67                protocol="UNICAST-DIRECT";
68                break;
69}
70// Datos imagen
71var imagen = form.idimagen.value.split("_");
72//form.codigo.value="deployImage REPO /";
73if (form.modo[0].checked)
74{
75        // UHU - Distinguimos entre disco y particion, el valor de idparticion sera disco;particion. eje. 1;1
76        var diskPart = form.idparticion.value.split(";");
77        command="deployImage " + imagen[0] + " /" + imagen[1] + " "+diskPart[0]+" " + diskPart[1] + " " + protocol  ;
78        form.codigo.value="\
79ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ " +
80command + " \n";
81
82        // Atributos para comando RestaurarImagen
83        form.atrib_restore.value = "dsk=" + diskPart[0] + "@par="+ diskPart[1] +"@idi=" +imagen[2] +
84                                   "@nci="+imagen[1] + "@ipr="+ imagen[0] +"@ifs=" +imagen[3] +
85                                   "@ptc="+protocol +"@";       
86}
87else
88{
89        command="updateCache REPO /" + imagen[1]  + ".img" + " " + protocol  ;
90        form.codigo.value="\
91ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command +"\"\n \ " +
92command + " \n";
93        //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol  ;
94}
95
96}
97
98// Activa el área de texto del código, permitiendo modificarlo.
99function modificarCodigo() {
100        document.getElementById("codigo").disabled = false;
101}
102
103function codeParticionado(form){
104        var errorMsg = "¡El espacio libre en disco no puede ser menor que 0!";
105        var n_disk = form.n_disk.value;
106        var tipo_part_table = form.tipo_part_table.value;
107        // Comprobamos si la opcion elejida es GPT o MSDOS para llamar a una funcion u otra
108        if(tipo_part_table == "GPT"){
109                // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso
110                if(parseInt(document.getElementById("freediskGPT").value) < 0){
111                        alert(errorMsg);
112                }
113                else{
114                        codeParticionadoGPT(form);
115                }
116        }
117        else{
118                // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso
119                if(parseInt(document.getElementById("freedisk").value) < 0){
120                        alert(errorMsg);
121                }
122                else{
123                        codeParticionadoMSDOS(form);
124                }
125        }
126       
127}
128
129
130function codeParticionadoMSDOS (form) {
131        var partCode="";
132        var logicalCode="";
133        var sizecacheCode="";
134        // cacheCode: codigo para preparar la particion cache
135        var cacheCode="";
136        // cacheInit: codigo para crear la particion cache, al final de todo el proceso
137        var cacheInit="";
138        var cacheSize;
139        var extended=false;
140        var n_disk = form.n_disk.value;
141        var tipo_part_table = form.tipo_part_table.value;
142        var maxParts = 4;
143        var emptyCache = "";
144       
145        // Comprobamos si esta seleccionada la cuarta particion y no es CACHE
146        if(form.check4.checked) {
147                if (form.part4.value == "CACHE") {
148                        // Si existe Cache al crear las particiones reservamos la cuarta libre
149                         emptyCache = " EMPTY:0";
150                } else {
151                        maxParts = 5;
152                }
153        }
154
155        for (var nPart=1; nPart<maxParts; nPart++) {
156                var partCheck=eval("form.check"+nPart);
157                if (partCheck.checked) {
158                        var partType=eval("form.part"+nPart);
159                        if (partType.value == "CUSTOM" ) {
160                                var partTypeCustom=eval("form.part"+nPart+"custom");
161                                partCode += " " + partTypeCustom.value;
162                                if (partTypeCustom.value == "EXTENDED") {
163                                        extended=true;
164                                }
165                        } else {
166                                partCode += " " + partType.value;
167                                if (partType.value == "EXTENDED") {
168                                        extended=true;
169                                }
170                        }
171                        var partSize=eval("form.size"+nPart);
172                        if (partSize.value == "CUSTOM" ) {
173                                var partSizeCustom=eval("form.size"+nPart+"custom");
174                                partCode += ":" + partSizeCustom.value;
175                        } else {
176                                partCode += ":" + partSize.value;
177                        }
178                        // En la partición 4 dejo espacio libre para la Cache
179                        if (nPart == 3)  partCode += emptyCache;
180                } else {
181                        partCode += " EMPTY:0";
182                }
183        }
184
185        // Si se selecciono la particion 4 y es CACHE
186        if(form.part4.value == "CACHE"){
187                if (form.check4.checked) {
188                        if (form.size4.value == "0") {
189                                sizecacheCode="\
190ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \
191sizecache=`ogGetCacheSize` \n";
192                                cacheInit="initCache "+n_disk+" $sizecache  &>/dev/null  | tee -a $OGLOGCOMMAND \n ";
193                                cacheCode="\
194ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
195ogDeletePartitionTable "+n_disk+" \n \
196ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \ ";
197                        } else {
198                                if (form.size4.value == "CUSTOM") {
199                                        cacheSize = form.size4custom.value;
200                                } else {
201                                        cacheSize = form.size4.value;
202                                }
203                                cacheInit="initCache " + n_disk + " " + cacheSize + " &>/dev/null  | tee -a $OGLOGCOMMAND \n ";
204                                cacheCode="\
205ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
206ogDeletePartitionTable "+n_disk+" \n \
207ogUpdatePartitionTable "+n_disk+" \n \ ";
208                        }
209                } else {
210                        cacheCode="\
211ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
212ogDeletePartitionTable "+n_disk+" \n \
213ogUpdatePartitionTable "+n_disk+" \n \ ";
214partCode += " EMPTY:0";
215                }
216        }
217
218        if (extended) {
219                var lastLogical=5;
220                for (var nPart=9; nPart>5; nPart--) {
221                        if (eval ("form.check"+nPart+".checked")) {
222                                lastLogical = nPart;
223                                break;
224                        }
225                }
226                for (var nPart=5; nPart<=lastLogical; nPart++) {
227                        var partCheck=eval("form.check"+nPart);
228                        if (partCheck.checked) {
229                                var partType=eval("form.part"+nPart);
230                                if (partType.value == "CUSTOM" ) {
231                                        var partTypeCustom=eval("form.part"+nPart+"custom");
232                                        logicalCode += " " + partTypeCustom.value;
233                                } else {
234                                        logicalCode += " " + partType.value;
235                                }
236                                var partSize=eval("form.size"+nPart);
237                                if (partSize.value == "CUSTOM" ) {
238                                        var partSizeCustom=eval("form.size"+nPart+"custom");
239                                        logicalCode += ":" + partSizeCustom.value;
240                                } else {
241                                        logicalCode += ":" + partSize.value;
242                                }
243                        } else {
244                                logicalCode += " EMPTY:0";
245                        }
246                }
247                partCode += logicalCode;
248        }
249
250        form.codigo.value="\
251" + sizecacheCode + " \
252ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
253ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions \"\n \
254ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
255ogUnmountAll "+n_disk+" 2>/dev/null\n  \
256ogUnmountCache \n \
257" + cacheCode + " \
258ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
259ogExecAndLog command session ogListPartitions "+n_disk+" \n \
260ogEcho session \"[70] $MSG_HELP_ogCreatePartitions  " + partCode + "\"\n \
261ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
262ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
263ogSetPartitionActive "+n_disk+" 1 \n \
264ogEcho log session \"[100] $MSG_HELP_ogListPartitions  "+n_disk+"\"\n \
265ogUpdatePartitionTable "+n_disk+" \n \
266ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
267" + cacheInit + " \
268ogExecAndLog command session log ogListPartitions "+n_disk+" \n";
269}
270
271
272function codeParticionadoGPT (form) {
273        var partCode="";
274        var logicalCode="";
275        var sizecacheCode="";
276        var cacheCode="";
277        var cacheSize;
278        var extended=false;
279        var n_disk = form.n_disk.value;
280        var tipo_part_table = form.tipo_part_table.value;
281                numParts=document.getElementById("numGPTpartitions").value;
282               
283        for (var nPart=1; nPart <= numParts; nPart++) {
284                var partCheck=eval("form.checkGPT"+nPart);
285                if (partCheck.checked) {
286                        // Distinguimos entre cache y el resto de particiones
287                        // Solo tratamos la particion 4 como cache, si se selecciono este tipo
288                        if(nPart == 4 && form.partGPT4.value == "CACHE") {
289                                if (form.sizeGPT4.value == "0") {
290                                        sizecacheCode="\
291ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \
292sizecache=`ogGetCacheSize` \n";
293                                        cacheCode="\
294ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
295ogDeletePartitionTable "+n_disk+"  \n \
296ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \
297ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
298initCache "+ n_disk +" $sizecache &>/dev/null \n ";
299                                } else {
300                                        if (form.sizeGPT4.value == "CUSTOM") {
301                                                cacheSize = form.sizeGPT4custom.value;
302                                        } else {
303                                                cacheSize = form.sizeGPT4.value;
304                                        }
305                                        cacheCode="\
306ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
307ogDeletePartitionTable "+n_disk+" \n \
308ogUpdatePartitionTable "+n_disk+" \n \
309ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
310initCache "  + n_disk +" "+ cacheSize + " &>/dev/null";
311                                }
312                        } else{
313                                var partType=eval("form.partGPT"+nPart);
314                                if (partType.value == "CUSTOM" ) {
315                                        var partTypeCustom=eval("form.partGPT"+nPart+"custom");
316                                        partCode += " " + partTypeCustom.value;
317                                } else {
318                                        partCode += " " + partType.value;
319                                }
320                                var partSize=eval("form.sizeGPT"+nPart);
321                                if (partSize.value == "CUSTOM" ) {
322                                        var partSizeCustom=eval("form.sizeGPT"+nPart+"custom");
323                                        partCode += ":" + partSizeCustom.value;
324                                } else {
325                                        partCode += ":" + partSize.value;
326                                }
327                        }
328                } else {
329                        if(nPart == 4){
330                                cacheCode="\
331ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
332ogDeletePartitionTable "+n_disk+" \n \
333ogUpdatePartitionTable "+n_disk+" \n";
334partCode += " EMPTY:0";
335                        } else{
336                                partCode += " EMPTY:0";
337                        }
338                }
339        }
340        form.codigo.value="\
341" + sizecacheCode + " \n \
342ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
343ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \
344ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
345ogUnmountAll "+n_disk+" \n  \
346ogUnmountCache \n \
347" + cacheCode + " \n \
348ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
349ogExecAndLog command session ogListPartitions "+n_disk+" \n \
350ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \
351ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
352ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
353ogSetPartitionActive "+n_disk+" 1 \n \
354ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
355ogUpdatePartitionTable "+n_disk+" \n \
356ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
357ogExecAndLog command session log ogListPartitions "+n_disk+" \n";
358}
359
360
361function showPartitionForm (tipo_table_part) {
362        document.getElementById("form"+tipo_table_part).style.display="inline";
363        if(tipo_table_part == "MSDOS"){
364                // De los dos tipos, se oculta el otro
365                document.getElementById("formGPT").style.display="none";
366        } else{
367                document.getElementById("formMSDOS").style.display="none";
368        }
369}
370
371
372// Código de pulsación de selección de partición.
373function clickPartitionCheckbox (form, npart, isGPT) {
374        // Si el parametro no esta definido, se toma como false
375        isGPT = (isGPT)?isGPT:"false";
376        if(isGPT == true){
377                prefix="GPT";
378        } else {
379                prefix="";
380        }
381        var partCheck=eval("form.check"+prefix+npart);
382        var partType=eval("form.part"+prefix+npart);
383        var partSize=eval("form.size"+prefix+npart);
384        var partTypeCustom=eval("form.part"+prefix+npart+"custom");
385        var partSizeCustom=eval("form.size"+prefix+npart+"custom");
386        var freeDisk=document.getElementById("freedisk"+prefix);
387        //var logical=document.getElementById("logicas"+prefix);
388        if (partCheck.checked) {
389                partType.disabled=false;
390                partSize.disabled=false;
391                if(npart != 4){
392                        if (partType.options[partType.selectedIndex].value == "CUSTOM") {
393                                partTypeCustom.disabled=false;
394                        }
395                }
396                if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
397                        partSizeCustom.disabled=false;
398                } else {
399                        partSizeCustom.disabled=true;
400                }
401        } else {
402                partType.disabled=true;
403                partSize.disabled=true;
404                // El campo TypeCustom no existe para la particion 4
405                if(npart != 4)
406                        partTypeCustom.disabled=true;
407                partSizeCustom.disabled=true;
408        }
409        if (npart <= 4) {
410                // Si el formulario es GPT no hay extendidas
411                if(isGPT != true){
412                        checkExtendedPartition(form);
413                }
414                calculateFreeDisk(form);
415        }
416}
417
418/**
419 * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco"
420 * y devuelve el de menor valor
421 */
422function getMinDiskSize(disk){
423        var diskSizeArray = document.getElementsByName("disksize_"+disk);
424        var minSize = diskSizeArray[0].value;
425        for(var i= 1; i < diskSizeArray.length; i++){
426                if(diskSizeArray[i].value < minSize)
427                        minSize = diskSizeArray[i].value;
428        }
429        // Restar sectores iniciales del disco al tamaño total (1 MB).
430        return (minSize > 1024 ? minSize - 1024 : minSize)
431}
432
433// Código para calcular el espacio libre del disco.
434function calculateFreeDisk(form) {
435        // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente
436        if(document.getElementById("tipo_part_table").value == "GPT"){
437                calculateFreeGPTDisk(form);
438        }
439        // Capturamos el disco seleccionado
440        var disk = document.getElementById("n_disk").value;
441        // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor
442        var diskSize = getMinDiskSize(disk);
443       
444               
445        var freeDisk=document.getElementById("freedisk");
446        freeDisk.value=diskSize;
447        for (var npart=1; npart<=4; npart++) {
448                var partCheck=eval("form.check"+npart);
449                var partSize=eval("form.size"+npart);
450                var partSizeCustom=eval("form.size"+npart+"custom");
451                if (partCheck.checked) {
452                        if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
453                                freeDisk.value -= parseInt(partSizeCustom.value);
454                        } else {
455                                freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
456                        }
457                }
458        }
459        if (parseInt(freeDisk.value) < 0) {
460                freeDisk.style.fontWeight = "bold";
461                freeDisk.style.fontStyle = "italic";
462        } else {
463                freeDisk.style.fontWeight = "normal";
464                freeDisk.style.fontStyle = "normal";
465        }
466        if (form.size4.value == 0) {
467                freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
468        }
469}
470
471// Código para calcular el espacio libre del disco. en el formulario GPT
472function calculateFreeGPTDisk(form) {
473        // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente
474    if(document.getElementById("tipo_part_table").value == "MSDOS"){
475            calculateFreeDisk(form);
476    }
477    // Capturamos el disco seleccionado
478        var disk = document.getElementById("n_disk").value;
479        // Buscamos el input hidden para el disco seleccionado
480        var diskSize = getMinDiskSize(disk);
481        document.getElementById('freediskGPT').value=diskSize;
482       
483        var freeDisk=document.getElementById("freediskGPT");
484        // Capturamos el numero de particiones que hay hechas
485        numParts=document.getElementById("numGPTpartitions").value;
486    for (npart=1; npart<=numParts; npart++) {
487            var partCheck=eval("form.checkGPT"+npart);
488            var partSize=eval("form.sizeGPT"+npart);
489            var partSizeCustom=eval("form.sizeGPT"+npart+"custom");
490            if (partCheck.checked) {
491                    if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
492                            freeDisk.value -= parseInt(partSizeCustom.value);
493                    } else {
494                            freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
495                    }
496            }
497    }
498    if (parseInt(freeDisk.value) < 0) {
499            freeDisk.style.fontWeight = "bold";
500            freeDisk.style.fontStyle = "italic";
501    } else {
502            freeDisk.style.fontWeight = "normal";
503            freeDisk.style.fontStyle = "normal";
504    }
505    if (form.size4.value == 0) {
506            freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
507    }
508}
509
510// Agrega una nueva fila a la tabla de particiones con una nueva particion
511function addGPTPartition(){
512        var partitionTypes = "";
513        partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>';
514        partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>';
515        partitionTypes+='<OPTION value="LINUX"> Linux </OTION>';
516        partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>';
517        partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>';
518        partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>';
519        partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>';
520        partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>';
521        partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>';
522        partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>';
523        partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>';
524        partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>';
525        partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>';
526        partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>';
527        partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>';
528        partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>';
529        partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>';
530        partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>';
531        partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>';
532        partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>';
533        partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>';
534        partitionTypes+='<OPTION value="EFI"> EFI </OPTION>';
535        partitionTypes+='<OPTION value="MBR"> MBR </OPTION>';
536        partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>';
537
538
539        table = document.getElementById("particionesGPT");
540        // Capturamos el numero de particiones, antes incrementamos
541        document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1
542        numPart=document.getElementById("numGPTpartitions").value;
543        partitionRow = table.insertRow(-1);
544        partitionRow.id = "trPartition"+numPart;
545        partitionRow.innerHTML="<td> \
546<input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partici&oacute;n "+numPart+"</td> \
547<td>\
548<select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
549        if (this.options[this.selectedIndex].value == \'CUSTOM\') { \
550                this.form.partGPT"+numPart+"custom.disabled=false; \
551        } else { \
552                this.form.partGPT"+numPart+"custom.disabled=true; \
553        }'><option value='CUSTOM'> Personalizar </option> \
554</select> \
555<br> \
556<select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \
557</td> \
558<td> \
559<select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
560        if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \
561                this.form.sizeGPT"+numPart+"custom.disabled=false; \
562        } else { \
563                this.form.sizeGPT"+numPart+"custom.disabled=true; \
564        } \
565' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \
566</select> \
567<br /> \
568<input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \
569</td>"
570
571}
572
573// Agrega una nueva fila a la tabla de particiones con una nueva particion
574function deleteGPTPartition(){
575        table = document.getElementById("particionesGPT");
576        // Capturamos el numero de particiones
577        numPart=document.getElementById("numGPTpartitions").value;
578        // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador
579        if(numPart > 4){
580                partitionRow = document.getElementById("trPartition"+numPart);
581                table.deleteRow(partitionRow.rowIndex);
582                // Decrementamos el numero de particiones
583                document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1;
584        }
585}
586
587// Código para comprobar si hay partición extendida activa para mostrar las lógicas.
588function checkExtendedPartition(form) {
589        var logical=document.getElementById("logicas");
590        var visible=false;
591        for (npart=1; npart<=4; npart++) {
592                var partCheck=eval("form.check"+npart);
593                var partType=eval("form.part"+npart);
594                var partTypeCustom=eval("form.part"+npart+"custom");
595                if (partCheck.checked) {
596                        partType.style.fontWeight = "normal";
597
598                        if (partType.value == "EXTENDED") {
599                                visible=true;
600                                partType.style.fontWeight = "bold";
601                        }
602                        // La particion 4 no tiene partTypeCustom
603                        if(npart != 4){
604                                partTypeCustom.style.fontWeight = "normal";
605                                if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") {
606                                        visible=true;
607                                        partTypeCustom.style.fontWeight = "bold";
608                                }
609                        }
610                }
611        }
612        if (visible) {
613                logical.style.visibility="visible";
614        } else {
615                logical.style.visibility="hidden";
616        }
617}
618
Note: See TracBrowser for help on using the repository browser.