source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 26c54b6

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 26c54b6 was 26c54b6, checked in by irina <irinagomez@…>, 9 years ago

#757 #763 Asistente DeployImage?: se corrige otra errata en el nombre de la imagen

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

  • Property mode set to 100644
File size: 23.4 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        return minSize;
438}
439
440// Código para calcular el espacio libre del disco.
441function calculateFreeDisk(form) {
442        // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente
443        if(document.getElementById("tipo_part_table").value == "GPT"){
444                calculateFreeGPTDisk(form);
445        }
446        // Capturamos el disco seleccionado
447        var disk = document.getElementById("n_disk").value;
448        // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor
449        var diskSize = getMinDiskSize(disk);
450       
451               
452        var freeDisk=document.getElementById("freedisk");
453        freeDisk.value=diskSize;
454        for (var npart=1; npart<=4; npart++) {
455                var partCheck=eval("form.check"+npart);
456                var partSize=eval("form.size"+npart);
457                var partSizeCustom=eval("form.size"+npart+"custom");
458                if (partCheck.checked) {
459                        if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
460                                freeDisk.value -= parseInt(partSizeCustom.value);
461                        } else {
462                                freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
463                        }
464                }
465        }
466        if (parseInt(freeDisk.value) < 0) {
467                freeDisk.style.fontWeight = "bold";
468                freeDisk.style.fontStyle = "italic";
469        } else {
470                freeDisk.style.fontWeight = "normal";
471                freeDisk.style.fontStyle = "normal";
472        }
473        if (form.size4.value == 0) {
474                freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
475        }
476}
477
478// Código para calcular el espacio libre del disco. en el formulario GPT
479function calculateFreeGPTDisk(form) {
480        // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente
481    if(document.getElementById("tipo_part_table").value == "MSDOS"){
482            calculateFreeDisk(form);
483    }
484    // Capturamos el disco seleccionado
485        var disk = document.getElementById("n_disk").value;
486        // Buscamos el input hidden para el disco seleccionado
487        var diskSize = getMinDiskSize(disk);
488        document.getElementById('freediskGPT').value=diskSize;
489       
490        var freeDisk=document.getElementById("freediskGPT");
491        // Capturamos el numero de particiones que hay hechas
492        numParts=document.getElementById("numGPTpartitions").value;
493    for (npart=1; npart<=numParts; npart++) {
494            var partCheck=eval("form.checkGPT"+npart);
495            var partSize=eval("form.sizeGPT"+npart);
496            var partSizeCustom=eval("form.sizeGPT"+npart+"custom");
497            if (partCheck.checked) {
498                    if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
499                            freeDisk.value -= parseInt(partSizeCustom.value);
500                    } else {
501                            freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
502                    }
503            }
504    }
505    if (parseInt(freeDisk.value) < 0) {
506            freeDisk.style.fontWeight = "bold";
507            freeDisk.style.fontStyle = "italic";
508    } else {
509            freeDisk.style.fontWeight = "normal";
510            freeDisk.style.fontStyle = "normal";
511    }
512    if (form.size4.value == 0) {
513            freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
514    }
515}
516
517// Agrega una nueva fila a la tabla de particiones con una nueva particion
518function addGPTPartition(){
519        var partitionTypes = "";
520        partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>';
521        partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>';
522        partitionTypes+='<OPTION value="LINUX"> Linux </OTION>';
523        partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>';
524        partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>';
525        partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>';
526        partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>';
527        partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>';
528        partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>';
529        partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>';
530        partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>';
531        partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>';
532        partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>';
533        partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>';
534        partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>';
535        partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>';
536        partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>';
537        partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>';
538        partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>';
539        partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>';
540        partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>';
541        partitionTypes+='<OPTION value="EFI"> EFI </OPTION>';
542        partitionTypes+='<OPTION value="MBR"> MBR </OPTION>';
543        partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>';
544
545
546        table = document.getElementById("particionesGPT");
547        // Capturamos el numero de particiones, antes incrementamos
548        document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1
549        numPart=document.getElementById("numGPTpartitions").value;
550        partitionRow = table.insertRow(-1);
551        partitionRow.id = "trPartition"+numPart;
552        partitionRow.innerHTML="<td> \
553<input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partici&oacute;n "+numPart+"</td> \
554<td>\
555<select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
556        if (this.options[this.selectedIndex].value == \'CUSTOM\') { \
557                this.form.partGPT"+numPart+"custom.disabled=false; \
558        } else { \
559                this.form.partGPT"+numPart+"custom.disabled=true; \
560        }'><option value='CUSTOM'> Personalizar </option> \
561</select> \
562<br> \
563<select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \
564</td> \
565<td> \
566<select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
567        if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \
568                this.form.sizeGPT"+numPart+"custom.disabled=false; \
569        } else { \
570                this.form.sizeGPT"+numPart+"custom.disabled=true; \
571        } \
572' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \
573</select> \
574<br /> \
575<input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \
576</td>"
577
578}
579
580// Agrega una nueva fila a la tabla de particiones con una nueva particion
581function deleteGPTPartition(){
582        table = document.getElementById("particionesGPT");
583        // Capturamos el numero de particiones
584        numPart=document.getElementById("numGPTpartitions").value;
585        // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador
586        if(numPart > 4){
587                partitionRow = document.getElementById("trPartition"+numPart);
588                table.deleteRow(partitionRow.rowIndex);
589                // Decrementamos el numero de particiones
590                document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1;
591        }
592}
593
594// Código para comprobar si hay partición extendida activa para mostrar las lógicas.
595function checkExtendedPartition(form) {
596        var logical=document.getElementById("logicas");
597        var visible=false;
598        for (npart=1; npart<=4; npart++) {
599                var partCheck=eval("form.check"+npart);
600                var partType=eval("form.part"+npart);
601                var partTypeCustom=eval("form.part"+npart+"custom");
602                if (partCheck.checked) {
603                        partType.style.fontWeight = "normal";
604
605                        if (partType.value == "EXTENDED") {
606                                visible=true;
607                                partType.style.fontWeight = "bold";
608                        }
609                        // La particion 4 no tiene partTypeCustom
610                        if(npart != 4){
611                                partTypeCustom.style.fontWeight = "normal";
612                                if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") {
613                                        visible=true;
614                                        partTypeCustom.style.fontWeight = "bold";
615                                }
616                        }
617                }
618        }
619        if (visible) {
620                logical.style.visibility="visible";
621        } else {
622                logical.style.visibility="hidden";
623        }
624}
625
Note: See TracBrowser for help on using the repository browser.