source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 1bc24fb

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

#757 Asistente DeployImagen?: para la opción deployImagen se envía al comando RestaurarImagen? del ogAdmClient (sólo si no se modifica el código)

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

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