source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 812496d

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 812496d was fe06132, checked in by ramon <ramongomez@…>, 8 years ago

#753: Asistente Particionado: restar 1 MB de los sectores iniciales del disco al tamaño disponible para formatear para reducir el impacto de error al apurar al máximo el espacio del disco.

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

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