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

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

#767: Solucionar errata y evitar problema al crear tabla MSDOS en discos nuevos.

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

  • Property mode set to 100644
File size: 23.7 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 \
190ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
191ogDeletePartitionTable "+n_disk+" \n \
192ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \
193ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
194initCache "+n_disk+" $sizecache NOMOUNT  &>/dev/null \n ";             
195                        } else {
196                                if (form.size4.value == "CUSTOM") {
197                                        cacheSize = form.size4custom.value;
198                                } else {
199                                        cacheSize = form.size4.value;
200                                }
201                                cacheCode="\
202ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
203ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
204ogDeletePartitionTable "+n_disk+" \n \
205ogUpdatePartitionTable "+n_disk+" \n \
206ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
207initCache " + n_disk + " " + cacheSize + " NOMOUNT &>/dev/null";       
208                        }
209                } else {
210                        cacheCode="\
211ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
212ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
213ogDeletePartitionTable "+n_disk+" \n \
214ogUpdatePartitionTable "+n_disk+" \n";
215partCode += " EMPTY:0";
216                }
217        }
218
219        if (extended) {
220                var lastLogical=5;
221                for (var nPart=9; nPart>5; nPart--) {
222                        if (eval ("form.check"+nPart+".checked")) {
223                                lastLogical = nPart;
224                                break;
225                        }
226                }
227                for (var nPart=5; nPart<=lastLogical; nPart++) {
228                        var partCheck=eval("form.check"+nPart);
229                        if (partCheck.checked) {
230                                var partType=eval("form.part"+nPart);
231                                if (partType.value == "CUSTOM" ) {
232                                        var partTypeCustom=eval("form.part"+nPart+"custom");
233                                        logicalCode += " " + partTypeCustom.value;
234                                } else {
235                                        logicalCode += " " + partType.value;
236                                }
237                                var partSize=eval("form.size"+nPart);
238                                if (partSize.value == "CUSTOM" ) {
239                                        var partSizeCustom=eval("form.size"+nPart+"custom");
240                                        logicalCode += ":" + partSizeCustom.value;
241                                } else {
242                                        logicalCode += ":" + partSize.value;
243                                }
244                        } else {
245                                logicalCode += " EMPTY:0";
246                        }
247                }
248                partCode += logicalCode;
249        }
250
251        form.codigo.value="\
252" + sizecacheCode + " \n \
253ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
254ogUnmountAll "+n_disk+" 2>/dev/null \n \
255ogUnmountCache \n \
256" + cacheCode + " \n \
257ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
258ogExecAndLog command session ogListPartitions "+n_disk+" \n \
259ogEcho session \"[70] $MSG_HELP_ogCreatePartitions  " + partCode + "\"\n \
260if ogExecAndLog command session ogCreatePartitions "+n_disk+" " + partCode + "; then \n \
261  ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
262  ogSetPartitionActive "+n_disk+" 1 \n \
263  ogEcho log session \"[100] $MSG_HELP_ogListPartitions  "+n_disk+"\"\n \
264  ogUpdatePartitionTable "+n_disk+" \n \
265  ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
266  ogExecAndLog command session log ogListPartitions "+n_disk+" \n \
267else \n \
268  ogEcho session log \"[100] ERROR: $MSG_HELP_ogCreatePartitions\" \n \
269  sleep 5 \n \
270fi";
271}
272
273
274function codeParticionadoGPT (form) {
275        var partCode="";
276        var logicalCode="";
277        var sizecacheCode="";
278        var cacheCode="";
279        var cacheSize;
280        var extended=false;
281        var n_disk = form.n_disk.value;
282        var tipo_part_table = form.tipo_part_table.value;
283                numParts=document.getElementById("numGPTpartitions").value;
284               
285        for (var nPart=1; nPart <= numParts; nPart++) {
286                var partCheck=eval("form.checkGPT"+nPart);
287                if (partCheck.checked) {
288                        // Distinguimos entre cache y el resto de particiones
289                        // Solo tratamos la particion 4 como cache, si se selecciono este tipo
290                        if(nPart == 4 && form.partGPT4.value == "CACHE") {
291                                if (form.sizeGPT4.value == "0") {
292                                        sizecacheCode="\
293ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \
294sizecache=`ogGetCacheSize` \n ";
295                                        cacheCode="\
296ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
297ogDeletePartitionTable "+n_disk+"  \n \
298ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \
299ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
300initCache "+ n_disk +" $sizecache NOMOUNT &>/dev/null \n ";
301                                } else {
302                                        if (form.sizeGPT4.value == "CUSTOM") {
303                                                cacheSize = form.sizeGPT4custom.value;
304                                        } else {
305                                                cacheSize = form.sizeGPT4.value;
306                                        }
307                                        cacheCode="\
308ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
309ogDeletePartitionTable "+n_disk+" \n \
310ogUpdatePartitionTable "+n_disk+" \n \
311ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
312initCache "  + n_disk +" "+ cacheSize + " NOMOUNT &>/dev/null";
313                                }
314                        } else{
315                                var partType=eval("form.partGPT"+nPart);
316                                if (partType.value == "CUSTOM" ) {
317                                        var partTypeCustom=eval("form.partGPT"+nPart+"custom");
318                                        partCode += " " + partTypeCustom.value;
319                                } else {
320                                        partCode += " " + partType.value;
321                                }
322                                var partSize=eval("form.sizeGPT"+nPart);
323                                if (partSize.value == "CUSTOM" ) {
324                                        var partSizeCustom=eval("form.sizeGPT"+nPart+"custom");
325                                        partCode += ":" + partSizeCustom.value;
326                                } else {
327                                        partCode += ":" + partSize.value;
328                                }
329                        }
330                } else {
331                        if(nPart == 4){
332                                cacheCode="\
333ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
334ogDeletePartitionTable "+n_disk+" \n \
335ogUpdatePartitionTable "+n_disk+" \n";
336partCode += " EMPTY:0";
337                        } else{
338                                partCode += " EMPTY:0";
339                        }
340                }
341        }
342        form.codigo.value="\
343" + sizecacheCode + " \n \
344ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
345ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \
346ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
347ogUnmountAll "+n_disk+" \n  \
348ogUnmountCache \n \
349" + cacheCode + " \n \
350ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
351ogExecAndLog command session ogListPartitions "+n_disk+" \n \
352ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \
353ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
354ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
355ogSetPartitionActive "+n_disk+" 1 \n \
356ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
357ogUpdatePartitionTable "+n_disk+" \n \
358ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
359ogExecAndLog command session log ogListPartitions "+n_disk+" \n";
360}
361
362
363function showPartitionForm (tipo_table_part) {
364        document.getElementById("form"+tipo_table_part).style.display="inline";
365        if(tipo_table_part == "MSDOS"){
366                // De los dos tipos, se oculta el otro
367                document.getElementById("formGPT").style.display="none";
368                document.getElementById("warngpt").style.display="none";
369        } else{
370                document.getElementById("formMSDOS").style.display="none";
371                // Para GPT obliga que primera partición sea EFI
372                document.getElementById("checkGPT1").checked=true;
373                document.getElementById("checkGPT1").disabled=true;
374                document.getElementById("partGPT1").value="CUSTOM";
375                document.getElementById("partGPT1custom").value="EFI";
376                document.getElementById("sizeGPT1").value="CUSTOM";
377                document.getElementById("sizeGPT1").disabled=false;
378                document.getElementById("sizeGPT1custom").value="512000";
379                document.getElementById("sizeGPT1custom").disabled=false;
380                document.getElementById("warngpt").style.display="table-row";
381        }
382}
383
384
385// Código de pulsación de selección de partición.
386function clickPartitionCheckbox (form, npart, isGPT) {
387        // Si el parametro no esta definido, se toma como false
388        isGPT = (isGPT)?isGPT:"false";
389        if(isGPT == true){
390                prefix="GPT";
391        } else {
392                prefix="";
393        }
394        var partCheck=eval("form.check"+prefix+npart);
395        var partType=eval("form.part"+prefix+npart);
396        var partSize=eval("form.size"+prefix+npart);
397        var partTypeCustom=eval("form.part"+prefix+npart+"custom");
398        var partSizeCustom=eval("form.size"+prefix+npart+"custom");
399        var freeDisk=document.getElementById("freedisk"+prefix);
400        //var logical=document.getElementById("logicas"+prefix);
401        if (partCheck.checked) {
402                partType.disabled=false;
403                partSize.disabled=false;
404                if(npart != 4){
405                        if (partType.options[partType.selectedIndex].value == "CUSTOM") {
406                                partTypeCustom.disabled=false;
407                        }
408                }
409                if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
410                        partSizeCustom.disabled=false;
411                } else {
412                        partSizeCustom.disabled=true;
413                }
414        } else {
415                partType.disabled=true;
416                partSize.disabled=true;
417                // El campo TypeCustom no existe para la particion 4
418                if(npart != 4)
419                        partTypeCustom.disabled=true;
420                partSizeCustom.disabled=true;
421        }
422        if (npart <= 4) {
423                // Si el formulario es GPT no hay extendidas
424                if(isGPT != true){
425                        checkExtendedPartition(form);
426                }
427                calculateFreeDisk(form);
428        }
429}
430
431/**
432 * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco"
433 * y devuelve el de menor valor
434 */
435function getMinDiskSize(disk){
436        var diskSizeArray = document.getElementsByName("disksize_"+disk);
437        var minSize = diskSizeArray[0].value;
438        for(var i= 1; i < diskSizeArray.length; i++){
439                if(diskSizeArray[i].value < minSize)
440                        minSize = diskSizeArray[i].value;
441        }
442        // Restar sectores iniciales del disco al tamaño total (1 MB).
443        return (minSize > 1024 ? minSize - 1024 : minSize)
444}
445
446// Código para calcular el espacio libre del disco.
447function calculateFreeDisk(form) {
448        // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente
449        if(document.getElementById("tipo_part_table").value == "GPT"){
450                calculateFreeGPTDisk(form);
451        }
452        // Capturamos el disco seleccionado
453        var disk = document.getElementById("n_disk").value;
454        // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor
455        var diskSize = getMinDiskSize(disk);
456       
457               
458        var freeDisk=document.getElementById("freedisk");
459        freeDisk.value=diskSize;
460        for (var npart=1; npart<=4; npart++) {
461                var partCheck=eval("form.check"+npart);
462                var partSize=eval("form.size"+npart);
463                var partSizeCustom=eval("form.size"+npart+"custom");
464                if (partCheck.checked) {
465                        if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
466                                freeDisk.value -= parseInt(partSizeCustom.value);
467                        } else {
468                                freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
469                        }
470                }
471        }
472        if (parseInt(freeDisk.value) < 0) {
473                freeDisk.style.fontWeight = "bold";
474                freeDisk.style.fontStyle = "italic";
475        } else {
476                freeDisk.style.fontWeight = "normal";
477                freeDisk.style.fontStyle = "normal";
478        }
479        if (form.size4.value == 0) {
480                freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
481        }
482}
483
484// Código para calcular el espacio libre del disco. en el formulario GPT
485function calculateFreeGPTDisk(form) {
486        // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente
487    if(document.getElementById("tipo_part_table").value == "MSDOS"){
488            calculateFreeDisk(form);
489    }
490    // Capturamos el disco seleccionado
491        var disk = document.getElementById("n_disk").value;
492        // Buscamos el input hidden para el disco seleccionado
493        var diskSize = getMinDiskSize(disk);
494        document.getElementById('freediskGPT').value=diskSize;
495       
496        var freeDisk=document.getElementById("freediskGPT");
497        // Capturamos el numero de particiones que hay hechas
498        numParts=document.getElementById("numGPTpartitions").value;
499    for (npart=1; npart<=numParts; npart++) {
500            var partCheck=eval("form.checkGPT"+npart);
501            var partSize=eval("form.sizeGPT"+npart);
502            var partSizeCustom=eval("form.sizeGPT"+npart+"custom");
503            if (partCheck.checked) {
504                    if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
505                            freeDisk.value -= parseInt(partSizeCustom.value);
506                    } else {
507                            freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
508                    }
509            }
510    }
511    if (parseInt(freeDisk.value) < 0) {
512            freeDisk.style.fontWeight = "bold";
513            freeDisk.style.fontStyle = "italic";
514    } else {
515            freeDisk.style.fontWeight = "normal";
516            freeDisk.style.fontStyle = "normal";
517    }
518    if (form.size4.value == 0) {
519            freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
520    }
521}
522
523// Agrega una nueva fila a la tabla de particiones con una nueva particion
524function addGPTPartition(){
525        var partitionTypes = "";
526        partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>';
527        partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>';
528        partitionTypes+='<OPTION value="LINUX"> Linux </OTION>';
529        partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>';
530        partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>';
531        partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>';
532        partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>';
533        partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>';
534        partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>';
535        partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>';
536        partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>';
537        partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>';
538        partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>';
539        partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>';
540        partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>';
541        partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>';
542        partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>';
543        partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>';
544        partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>';
545        partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>';
546        partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>';
547        partitionTypes+='<OPTION value="EFI"> EFI </OPTION>';
548        partitionTypes+='<OPTION value="MBR"> MBR </OPTION>';
549        partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>';
550
551
552        table = document.getElementById("particionesGPT");
553        // Capturamos el numero de particiones, antes incrementamos
554        document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1
555        numPart=document.getElementById("numGPTpartitions").value;
556        partitionRow = table.insertRow(-1);
557        partitionRow.id = "trPartition"+numPart;
558        partitionRow.innerHTML="<td> \
559<input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partici&oacute;n "+numPart+"</td> \
560<td>\
561<select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
562        if (this.options[this.selectedIndex].value == \'CUSTOM\') { \
563                this.form.partGPT"+numPart+"custom.disabled=false; \
564        } else { \
565                this.form.partGPT"+numPart+"custom.disabled=true; \
566        }'><option value='CUSTOM'> Personalizar </option> \
567</select> \
568<br> \
569<select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \
570</td> \
571<td> \
572<select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
573        if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \
574                this.form.sizeGPT"+numPart+"custom.disabled=false; \
575        } else { \
576                this.form.sizeGPT"+numPart+"custom.disabled=true; \
577        } \
578' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \
579</select> \
580<br /> \
581<input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \
582</td>"
583
584}
585
586// Agrega una nueva fila a la tabla de particiones con una nueva particion
587function deleteGPTPartition(){
588        table = document.getElementById("particionesGPT");
589        // Capturamos el numero de particiones
590        numPart=document.getElementById("numGPTpartitions").value;
591        // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador
592        if(numPart > 4){
593                partitionRow = document.getElementById("trPartition"+numPart);
594                table.deleteRow(partitionRow.rowIndex);
595                // Decrementamos el numero de particiones
596                document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1;
597        }
598}
599
600// Código para comprobar si hay partición extendida activa para mostrar las lógicas.
601function checkExtendedPartition(form) {
602        var logical=document.getElementById("logicas");
603        var visible=false;
604        for (npart=1; npart<=4; npart++) {
605                var partCheck=eval("form.check"+npart);
606                var partType=eval("form.part"+npart);
607                var partTypeCustom=eval("form.part"+npart+"custom");
608                if (partCheck.checked) {
609                        partType.style.fontWeight = "normal";
610
611                        if (partType.value == "EXTENDED") {
612                                visible=true;
613                                partType.style.fontWeight = "bold";
614                        }
615                        // La particion 4 no tiene partTypeCustom
616                        if(npart != 4){
617                                partTypeCustom.style.fontWeight = "normal";
618                                if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") {
619                                        visible=true;
620                                        partTypeCustom.style.fontWeight = "bold";
621                                }
622                        }
623                }
624        }
625        if (visible) {
626                logical.style.visibility="visible";
627        } else {
628                logical.style.visibility="hidden";
629        }
630}
631
Note: See TracBrowser for help on using the repository browser.