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

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-instalacion
Last change on this file since 3673737 was 7082c6f, checked in by Irina Gómez <irinagomez@…>, 6 years ago

#872 Mejora en el log en tiempo real del asistente de particionado.

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