source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 09b8452

configure-oglivelgromero-new-oglivemainmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineoglive-ipv6test-python-scriptsticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
Last change on this file since 09b8452 was b391e9a, checked in by Irina Gómez <irinagomez@…>, 3 years ago

#1066 #1072 The partitioning command or wizard deletes the partition table only when the partition table type is different from the one defined in the parameter.

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