source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 4a511f81

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 4a511f81 was 8a59a5f, checked in by irina <irinagomez@…>, 9 years ago

#619 Asistente de particionado. Se elimina el reinicio del cliente, no es necesario para que actualice la información de las particiones

git-svn-id: https://opengnsys.es/svn/branches/version1.1@4888 a21b9725-9963-47de-94b9-378ad31fedc9

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