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

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 b584da5 was 0285a39, checked in by irina <irinagomez@…>, 10 years ago

#679 Varios repos: cambios en consola web en el comando restaurar imagen y el asistente de deploy de imágenes para permitan restaurar las imágenes de todos los repositorios de la UO.

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

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