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

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 e32794a was 62eba32, checked in by Irina Gómez <irinagomez@…>, 6 years ago

#895 Fixs the partitioning wizard: can change partition table from MSDOS to GPT whithout reboot. Fixs fake error in ogCreateGptPartitions when there isn't cache.

  • Property mode set to 100644
File size: 25.6 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` \n ";
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 ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \
274ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
275ogUnmountAll "+n_disk+" 2>/dev/null \n \
276ogUnmountCache \n \
277" + sizecacheCode + "\
278ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
279ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
280ogDeletePartitionTable "+n_disk+" \n \
281ogUpdatePartitionTable "+n_disk+" \n \
282" + cacheCode + "\
283ogEcho session \"[70] $MSG_HELP_ogCreatePartitions  " + partCode + "\"\n \
284ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
285EVAL=$? \n \
286if [ $EVAL -eq 0 ]; then \n \
287  ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
288  ogSetPartitionActive "+n_disk+" 1 \n \
289  ogEcho log session \"[90] $MSG_HELP_ogListPartitions  "+n_disk+"\"\n \
290  ogUpdatePartitionTable "+n_disk+" \n \
291  ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
292  ogExecAndLog command session log ogListPartitions "+n_disk+" \n\
293  "+ swapCode +"\
294else \n \
295  ogEcho session log \"[100] ERROR: $MSG_HELP_ogCreatePartitions\" \n \
296  return $EVAL \n \
297fi";
298}
299
300
301function codeParticionadoGPT (form) {
302        var partCode="";
303        var logicalCode="";
304        var sizecacheCode="";
305        var cacheCode="";
306        var cacheSize;
307        var extended=false;
308        var n_disk = form.n_disk.value;
309        var tipo_part_table = form.tipo_part_table.value;
310        var swapPart = new Array();
311        var swapCode = "";
312
313                numParts=document.getElementById("numGPTpartitions").value;
314               
315        for (var nPart=1; nPart <= numParts; nPart++) {
316                var partCheck=eval("form.checkGPT"+nPart);
317                if (partCheck.checked) {
318                        // Distinguimos entre cache y el resto de particiones
319                        // Solo tratamos la particion 4 como cache, si se selecciono este tipo
320                        if(nPart == 4 && form.partGPT4.value == "CACHE") {
321                                if (form.sizeGPT4.value == "0") {
322                                        sizecacheCode="\
323ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\" \n \
324sizecache=`ogGetCacheSize` \n ";
325                                        cacheCode="\
326ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
327initCache "+ n_disk +" $sizecache NOMOUNT &>/dev/null \n ";
328                                } else {
329                                        if (form.sizeGPT4.value == "CUSTOM") {
330                                                cacheSize = form.sizeGPT4custom.value;
331                                        } else {
332                                                cacheSize = form.sizeGPT4.value;
333                                        }
334                                        cacheCode="\
335ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
336initCache "  + n_disk +" "+ cacheSize + " NOMOUNT &>/dev/null \n ";
337                                }
338                                cacheCode += "ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n ";
339                                cacheCode += "ogExecAndLog command session ogListPartitions "+n_disk+" \n ";
340                        } else{
341                                var partType=eval("form.partGPT"+nPart);
342                                if (partType.value == "CUSTOM" ) {
343                                        var partTypeCustom=eval("form.partGPT"+nPart+"custom");
344                                        partCode += " " + partTypeCustom.value;
345                                        // Partición swap
346                                        if (partTypeCustom.value == "LINUX-SWAP")
347                                                swapPart.push(nPart);
348                                } else {
349                                        partCode += " " + partType.value;
350                                        // Partición swap
351                                        if (partType.value == "LINUX-SWAP")
352                                                swapPart.push(nPart);
353                                }
354                                var partSize=eval("form.sizeGPT"+nPart);
355                                if (partSize.value == "CUSTOM" ) {
356                                        var partSizeCustom=eval("form.sizeGPT"+nPart+"custom");
357                                        partCode += ":" + partSizeCustom.value;
358                                } else {
359                                        partCode += ":" + partSize.value;
360                                }
361                        }
362                } else {
363                        partCode += " EMPTY:0";
364                }
365        }
366        // Formateo de la partición swap
367        if (swapPart.length > 0) {
368            for (var i=0; i < swapPart.length; i++) {
369                swapCode += " ogEcho session log \"[95] $MSG_HELP_ogFormat "+n_disk+" "+swapPart[i]+" LINUX-SWAP \" \n" ;
370                swapCode += " ogExecAndLog command ogFormat "+n_disk+" "+swapPart[i]+" LINUX-SWAP \n";
371            }
372        }
373           
374        form.codigo.value="\
375 ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \
376ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
377ogUnmountAll "+n_disk+" \n \
378ogUnmountCache \n \
379" + sizecacheCode + "\
380ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
381ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
382ogDeletePartitionTable "+n_disk+" \n \
383ogUpdatePartitionTable "+n_disk+" \n \
384" + cacheCode + "\
385ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \
386ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + "\n \
387EVAL=$? \n \
388if [ $EVAL -eq 0 ]; then \n \
389    ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
390    ogSetPartitionActive "+n_disk+" 1 \n \
391    ogEcho log session \"[90] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
392    ogUpdatePartitionTable "+n_disk+" \n \
393    ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
394    ogExecAndLog command session log ogListPartitions "+n_disk+" \n \
395else \n \
396    ogEcho session log \"[100] ERROR: $MSG_HELP_ogCreatePartitions\" \n \
397    return $EVAL \n \
398fi \n ";
399
400// Formateo de la swap
401form.codigo.value += swapCode;
402}
403
404
405function showPartitionForm (tipo_table_part) {
406        document.getElementById("form"+tipo_table_part).style.display="inline";
407        if(tipo_table_part == "MSDOS"){
408                // De los dos tipos, se oculta el otro
409                document.getElementById("formGPT").style.display="none";
410                document.getElementById("warngpt").style.display="none";
411        } else{
412                document.getElementById("formMSDOS").style.display="none";
413                // Para GPT obliga que primera partición sea EFI
414                document.getElementById("checkGPT1").checked=true;
415                document.getElementById("checkGPT1").disabled=true;
416                document.getElementById("partGPT1").value="CUSTOM";
417                document.getElementById("partGPT1custom").value="EFI";
418                document.getElementById("sizeGPT1").value="CUSTOM";
419                document.getElementById("sizeGPT1").disabled=false;
420                document.getElementById("sizeGPT1custom").value="512000";
421                document.getElementById("sizeGPT1custom").disabled=false;
422                document.getElementById("warngpt").style.display="table-row";
423        }
424}
425
426
427// Código de pulsación de selección de partición.
428function clickPartitionCheckbox (form, npart, isGPT) {
429        // Si el parametro no esta definido, se toma como false
430        isGPT = (isGPT)?isGPT:"false";
431        if(isGPT == true){
432                prefix="GPT";
433        } else {
434                prefix="";
435        }
436        var partCheck=eval("form.check"+prefix+npart);
437        var partType=eval("form.part"+prefix+npart);
438        var partSize=eval("form.size"+prefix+npart);
439        var partTypeCustom=eval("form.part"+prefix+npart+"custom");
440        var partSizeCustom=eval("form.size"+prefix+npart+"custom");
441        var freeDisk=document.getElementById("freedisk"+prefix);
442        //var logical=document.getElementById("logicas"+prefix);
443        if (partCheck.checked) {
444                partType.disabled=false;
445                partSize.disabled=false;
446                if(npart != 4){
447                        if (partType.options[partType.selectedIndex].value == "CUSTOM") {
448                                partTypeCustom.disabled=false;
449                        }
450                }
451                if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
452                        partSizeCustom.disabled=false;
453                } else {
454                        partSizeCustom.disabled=true;
455                }
456        } else {
457                partType.disabled=true;
458                partSize.disabled=true;
459                // El campo TypeCustom no existe para la particion 4
460                if(npart != 4)
461                        partTypeCustom.disabled=true;
462                partSizeCustom.disabled=true;
463        }
464        if (npart <= 4) {
465                // Si el formulario es GPT no hay extendidas
466                if(isGPT != true){
467                        checkExtendedPartition(form);
468                }
469                calculateFreeDisk(form);
470        }
471}
472
473/**
474 * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco"
475 * y devuelve el de menor valor
476 */
477function getMinDiskSize(disk){
478        var diskSizeArray = document.getElementsByName("disksize_"+disk);
479        var minSize = diskSizeArray[0].value;
480        for(var i= 1; i < diskSizeArray.length; i++){
481                if(diskSizeArray[i].value < minSize)
482                        minSize = diskSizeArray[i].value;
483        }
484        // Restar sectores iniciales del disco al tamaño total (1 MB).
485        return (minSize > 1024 ? minSize - 1024 : minSize)
486}
487
488// Calcula el tamaño de la mayor cache y lo guarda en un campo oculto
489function getMaxCacheSize() {
490        var cacheSizeArray = document.getElementsByName("cachesize");
491        // Si no existe cache el valor es cero.
492        if (cacheSizeArray[0]) {
493            var maxSize = cacheSizeArray[0].value;
494            for(var i= 1; i < cacheSizeArray.length; i++){
495                if(maxSize < cacheSizeArray[i].value)
496                        maxSize = cacheSizeArray[i].value;
497            }
498            document.getElementById("maxcachesize").value = maxSize;
499        } else {
500            document.getElementById("maxcachesize").value = 0;
501        }
502}
503
504
505// Comprueba que la cache quepa en el espacio libre del disco
506function validaCache (freedisk) {
507        var form = document.fdatos;
508        var maxcachesize = parseInt(document.getElementById("maxcachesize").value);
509        if(form.part4.value === "CACHE" && form.check4.checked && form.size4.value == 0 ){
510            return ((freedisk - maxcachesize) > 0);
511        }
512        return true;
513}
514
515// Código para calcular el espacio libre del disco.
516function calculateFreeDisk(form) {
517        // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente
518        if(document.getElementById("tipo_part_table").value == "GPT"){
519                calculateFreeGPTDisk(form);
520        }
521        // Capturamos el disco seleccionado
522        var disk = document.getElementById("n_disk").value;
523        // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor
524        var diskSize = getMinDiskSize(disk);
525       
526               
527        var freeDisk=document.getElementById("freedisk");
528        freeDisk.value=diskSize;
529        for (var npart=1; npart<=4; npart++) {
530                var partCheck=eval("form.check"+npart);
531                var partSize=eval("form.size"+npart);
532                var partSizeCustom=eval("form.size"+npart+"custom");
533                if (partCheck.checked) {
534                        if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
535                                freeDisk.value -= parseInt(partSizeCustom.value);
536                        } else {
537                                freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
538                        }
539                }
540        }
541        if (parseInt(freeDisk.value) < 0) {
542                freeDisk.style.fontWeight = "bold";
543                freeDisk.style.fontStyle = "italic";
544        } else {
545                freeDisk.style.fontWeight = "normal";
546                freeDisk.style.fontStyle = "normal";
547        }
548        if (form.size4.value == 0) {
549                freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
550        }
551}
552
553// Código para calcular el espacio libre del disco. en el formulario GPT
554function calculateFreeGPTDisk(form) {
555        // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente
556        if(document.getElementById("tipo_part_table").value == "MSDOS"){
557                calculateFreeDisk(form);
558        }
559        // Capturamos el disco seleccionado
560        var disk = document.getElementById("n_disk").value;
561        // Buscamos el input hidden para el disco seleccionado
562        document.getElementById('freediskGPT').value=getMinDiskSize(disk);
563       
564        var freeDisk=document.getElementById("freediskGPT");
565        // Capturamos el numero de particiones que hay hechas
566        numParts=document.getElementById("numGPTpartitions").value;
567        for (npart=1; npart<=numParts; npart++) {
568            var partCheck=eval("form.checkGPT"+npart);
569            var partSize=eval("form.sizeGPT"+npart);
570            var partSizeCustom=eval("form.sizeGPT"+npart+"custom");
571            if (partCheck.checked) {
572                    if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
573                            freeDisk.value -= parseInt(partSizeCustom.value);
574                    } else {
575                            freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
576                    }
577            }
578    }
579    if (parseInt(freeDisk.value) < 0) {
580            freeDisk.style.fontWeight = "bold";
581            freeDisk.style.fontStyle = "italic";
582    } else {
583            freeDisk.style.fontWeight = "normal";
584            freeDisk.style.fontStyle = "normal";
585    }
586    if (form.size4.value == 0) {
587            freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
588    }
589}
590
591// Agrega una nueva fila a la tabla de particiones con una nueva particion
592function addGPTPartition(){
593        var partitionTypes = "";
594        partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>';
595        partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>';
596        partitionTypes+='<OPTION value="LINUX"> Linux </OTION>';
597        partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>';
598        partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>';
599        partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>';
600        partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>';
601        partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>';
602        partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>';
603        partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>';
604        partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>';
605        partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>';
606        partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>';
607        partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>';
608        partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>';
609        partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>';
610        partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>';
611        partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>';
612        partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>';
613        partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>';
614        partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>';
615        partitionTypes+='<OPTION value="EFI"> EFI </OPTION>';
616        partitionTypes+='<OPTION value="MBR"> MBR </OPTION>';
617        partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>';
618
619
620        table = document.getElementById("particionesGPT");
621        // Capturamos el numero de particiones, antes incrementamos
622        document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1;
623        numPart=document.getElementById("numGPTpartitions").value;
624        partitionRow = table.insertRow(-1);
625        partitionRow.id = "trPartition"+numPart;
626        partitionRow.innerHTML="<td> \
627<input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partici&oacute;n "+numPart+"</td> \
628<td>\
629<select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
630        if (this.options[this.selectedIndex].value == \'CUSTOM\') { \
631                this.form.partGPT"+numPart+"custom.disabled=false; \
632        } else { \
633                this.form.partGPT"+numPart+"custom.disabled=true; \
634        }'><option value='CUSTOM'> Personalizar </option> \
635</select> \
636<br> \
637<select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \
638</td> \
639<td> \
640<select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
641        if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \
642                this.form.sizeGPT"+numPart+"custom.disabled=false; \
643        } else { \
644                this.form.sizeGPT"+numPart+"custom.disabled=true; \
645        } \
646' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \
647</select> \
648<br /> \
649<input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \
650</td>"
651
652}
653
654// Agrega una nueva fila a la tabla de particiones con una nueva particion
655function deleteGPTPartition(){
656        table = document.getElementById("particionesGPT");
657        // Capturamos el numero de particiones
658        numPart=document.getElementById("numGPTpartitions").value;
659        // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador
660        if(numPart > 4){
661                partitionRow = document.getElementById("trPartition"+numPart);
662                table.deleteRow(partitionRow.rowIndex);
663                // Decrementamos el numero de particiones
664                document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1;
665        }
666}
667
668// Código para comprobar si hay partición extendida activa para mostrar las lógicas.
669function checkExtendedPartition(form) {
670        var logical=document.getElementById("logicas");
671        var visible=false;
672        for (npart=1; npart<=4; npart++) {
673                var partCheck=eval("form.check"+npart);
674                var partType=eval("form.part"+npart);
675                var partTypeCustom=eval("form.part"+npart+"custom");
676                if (partCheck.checked) {
677                        partType.style.fontWeight = "normal";
678
679                        if (partType.value == "EXTENDED") {
680                                visible=true;
681                                partType.style.fontWeight = "bold";
682                        }
683                        // La particion 4 no tiene partTypeCustom
684                        if(npart != 4){
685                                partTypeCustom.style.fontWeight = "normal";
686                                if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") {
687                                        visible=true;
688                                        partTypeCustom.style.fontWeight = "bold";
689                                }
690                        }
691                }
692        }
693        if (visible) {
694                logical.style.visibility="visible";
695        } else {
696                logical.style.visibility="hidden";
697        }
698}
Note: See TracBrowser for help on using the repository browser.