source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 822d4f5

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 822d4f5 was 1a2fa9d8, checked in by ramon <ramongomez@…>, 10 years ago

#673: Actualizar código incluido en OepnGnSys? 1.0.6 sobre la rama version1.1 para desarrollar la nueva versión.

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

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