source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 90ac583

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 90ac583 was 90ac583, checked in by irina <irinagomez@…>, 7 years ago

#767 El asistente de particionado si se definen particiones como LINUX-SWAP las formatea.

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

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