source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 426ca26

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 426ca26 was dd14ed2, checked in by irina <irinagomez@…>, 8 years ago

#767 Asistente de particionado: comprueba que la cache 'Sin modificar tamaño' cabe en el espacio libre del disco duro

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

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