source: admin/WebConsole/asistentes/jscripts/asistentes.js @ 4a511f81

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 4a511f81 was 8a59a5f, checked in by irina <irinagomez@…>, 9 years ago

#619 Asistente de particionado. Se elimina el reinicio del cliente, no es necesario para que actualice la información de las particiones

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

  • Property mode set to 100644
File size: 21.9 KB
RevLine 
[eb3e2b8]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)
[0285a39]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
[eb3e2b8]12// ***********************************************************************************************************
13
14function codeCloneRemotePartition(form){
[a710997]15var command ;
[62ccd9b]16switch (form.idmetodo.value)
17{
18        case "MULTICAST":
19                protocol="MULTICAST " + form.mcastpuerto.value  + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " ";
20                break;
21        case "UNICAST":
22                protocol="UNICAST " +  form.ucastport.value + ":" + form.ucastclient.value + " ";
23                break;
24}
25//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;
[f311787]26command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + "  " + protocol  + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value;
27form.codigo.value="\
[a710997]28ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \
[9a1df17]29ogExecAndLog command " + command + " \n ";
[eb3e2b8]30}
31
[1a2fa9d8]32// disableDirect(form): En Deploy de imagenes si se elige updateCache se impide elegir multicast-direct o unicast-direct
33function disableDirect(form){
34        // MULTICAST-DIRECT
35        form.idmetodo.options[2].disabled=true;
36        // UNICAST-DIRECT
37        form.idmetodo.options[4].disabled=true;
38}
39// enableDirect(form): En Deploy de imagenes si se elige deployCache se permite elegir multicast-direct o unicast-direct
40function enableDirect(form){
41        // MULTICAST-DIRECT
42        form.idmetodo.options[2].disabled=false;
43        // UNICAST-DIRECT
44        form.idmetodo.options[4].disabled=false;
45}
46
47
[eb3e2b8]48function codeDeployImage(form){
49switch (form.idmetodo.value)
50{
51        case "MULTICAST":
52                protocol="MULTICAST " + form.mcastpuerto.value  + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " ";
53                break;
[1a2fa9d8]54        case "MULTICAST-DIRECT":
55                protocol="MULTICAST-DIRECT " + form.mcastpuerto.value  + ":" + form.mcastmodo.value + ":" + form.mcastdireccion.value + ":" + form.mcastvelocidad.value + "M:" + form.mcastnclien.value + ":" + form.mcastseg.value + " ";
56                break;
[eb3e2b8]57        case "TORRENT":
58                protocol=" TORRENT " +  form.modp2p.value + ":" + form.timep2p.value;
59                break;
[3b3043b]60        case "UNICAST":
61                protocol=" UNICAST";
62                break;
[1a2fa9d8]63        case "UNICAST-DIRECT":
64                protocol=" UNICAST-DIRECT";
65                break;
[eb3e2b8]66}
67//form.codigo.value="deployImage REPO /";
[3b3043b]68if (form.modo[0].checked)
69{
[b2651a6]70        // UHU - Distinguimos entre disco y particion, el valor de idparticion sera disco;particion. eje. 1;1
71        var diskPart = form.idparticion.value.split(";");
[0285a39]72        command="deployImage " + form.idimagen.value + " "+diskPart[0]+" " + diskPart[1] + " " + protocol  ;
[f311787]73        form.codigo.value="\
[d1795da]74ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ " +
[4fcbcc8]75command + " \n";
[f311787]76        //form.codigo.value="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol  ;
[3b3043b]77}
78else
79{
[f311787]80        command="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol  ;
81        form.codigo.value="\
[d1795da]82ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command +"\"\n \ " +
83command + " \n";
[f311787]84        //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol  ;
[3b3043b]85}
86
[eb3e2b8]87}
88
[f5d9d43]89function codeParticionado(form){
[2e69949]90        var errorMsg = "¡El espacio libre en disco no puede ser menor que 0!";
[f5d9d43]91        var n_disk = form.n_disk.value;
92        var tipo_part_table = form.tipo_part_table.value;
93        // Comprobamos si la opcion elejida es GPT o MSDOS para llamar a una funcion u otra
94        if(tipo_part_table == "GPT"){
[2e69949]95                // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso
96                if(parseInt(document.getElementById("freediskGPT").value) < 0){
97                        alert(errorMsg);
98                }
99                else{
100                        codeParticionadoGPT(form);
101                }
[f5d9d43]102        }
103        else{
[2e69949]104                // Comprobamos que el espacio libre en el disco no sea negativo, si lo es, dar aviso
105                if(parseInt(document.getElementById("freedisk").value) < 0){
106                        alert(errorMsg);
107                }
108                else{
109                        codeParticionadoMSDOS(form);
110                }
[f5d9d43]111        }
[2e69949]112       
[f5d9d43]113}
114
115
116function codeParticionadoMSDOS (form) {
[66d40b0]117        var partCode="";
118        var logicalCode="";
119        var cacheCode;
120        var cacheSize;
121        var extended=false;
[f5d9d43]122        var n_disk = form.n_disk.value;
123        var tipo_part_table = form.tipo_part_table.value;
[b2651a6]124        var maxParts = 4;
125       
126        // Comprobamos si esta seleccionada la cuarta particion y no es CACHE
127        if(form.check4.checked && form.part4.value != "CACHE")
128                maxParts = 5;
[f5d9d43]129
[b2651a6]130        for (var nPart=1; nPart<maxParts; nPart++) {
[66d40b0]131                var partCheck=eval("form.check"+nPart);
132                if (partCheck.checked) {
133                        var partType=eval("form.part"+nPart);
134                        if (partType.value == "CUSTOM" ) {
135                                var partTypeCustom=eval("form.part"+nPart+"custom");
136                                partCode += " " + partTypeCustom.value;
137                                if (partTypeCustom.value == "EXTENDED") {
138                                        extended=true;
139                                }
140                        } else {
141                                partCode += " " + partType.value;
142                                if (partType.value == "EXTENDED") {
143                                        extended=true;
144                                }
145                        }
146                        var partSize=eval("form.size"+nPart);
147                        if (partSize.value == "CUSTOM" ) {
148                                var partSizeCustom=eval("form.size"+nPart+"custom");
149                                partCode += ":" + partSizeCustom.value;
150                        } else {
151                                partCode += ":" + partSize.value;
152                        }
153                } else {
154                        partCode += " EMPTY:0";
155                }
[1ec9b7a]156        }
[b2651a6]157
158        var cacheCode="";
159
160        // Si se selecciono la particion 4 y es CACHE
161        if(form.part4.value == "CACHE"){
162                if (form.check4.checked) {
163                        if (form.size4.value == "0") {
164                                cacheCode="\
[d1795da]165ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \
[b2651a6]166sizecache=`ogGetCacheSize` \n \
[d1795da]167ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
168ogDeletePartitionTable "+n_disk+" \n \
[9a1df17]169ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \
[d1795da]170ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
[9a1df17]171initCache "+n_disk+" $sizecache  &>/dev/null \n ";             
[09da038]172                        } else {
[b2651a6]173                                if (form.size4.value == "CUSTOM") {
174                                        cacheSize = form.size4custom.value;
175                                } else {
176                                        cacheSize = form.size4.value;
177                                }
178                                cacheCode="\
[d1795da]179ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
180ogDeletePartitionTable "+n_disk+" \n \
[523c8ac]181ogUpdatePartitionTable "+n_disk+" \n \
[d1795da]182ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
[9a1df17]183initCache " + n_disk + " " + cacheSize + " &>/dev/null";       
[b2651a6]184                        }
185                } else {
186                        cacheCode="\
[d1795da]187ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
[523c8ac]188ogDeletePartitionTable "+n_disk+" \n \
189ogUpdatePartitionTable "+n_disk+" \n";
190partCode += " EMPTY:0";
[b2651a6]191                }
[09da038]192        }
[b2651a6]193
[66d40b0]194        if (extended) {
195                var lastLogical=5;
196                for (var nPart=9; nPart>5; nPart--) {
197                        if (eval ("form.check"+nPart+".checked")) {
198                                lastLogical = nPart;
199                                break;
200                        }
201                }
202                for (var nPart=5; nPart<=lastLogical; nPart++) {
203                        var partCheck=eval("form.check"+nPart);
204                        if (partCheck.checked) {
205                                var partType=eval("form.part"+nPart);
206                                if (partType.value == "CUSTOM" ) {
207                                        var partTypeCustom=eval("form.part"+nPart+"custom");
208                                        logicalCode += " " + partTypeCustom.value;
209                                } else {
210                                        logicalCode += " " + partType.value;
211                                }
212                                var partSize=eval("form.size"+nPart);
213                                if (partSize.value == "CUSTOM" ) {
214                                        var partSizeCustom=eval("form.size"+nPart+"custom");
215                                        logicalCode += ":" + partSizeCustom.value;
216                                } else {
217                                        logicalCode += ":" + partSize.value;
218                                }
219                        } else {
220                                logicalCode += " EMPTY:0";
221                        }
222                }
223                partCode += logicalCode;
224        }
[eb3e2b8]225
[523c8ac]226        form.codigo.value="\
[f5d9d43]227ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
[d1795da]228ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions \"\n \
229ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
230ogUnmountAll "+n_disk+" 2>/dev/null\n  \
[1a2fa9d8]231ogUnmountCache \n \
[66d40b0]232" + cacheCode + " \n \
[d1795da]233ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
[9a1df17]234ogExecAndLog command session ogListPartitions "+n_disk+" \n \
[d1795da]235ogEcho session \"[70] $MSG_HELP_ogCreatePartitions  " + partCode + "\"\n \
[9a1df17]236ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
[d1795da]237ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
[f5d9d43]238ogSetPartitionActive "+n_disk+" 1 \n \
[d1795da]239ogEcho log session \"[100] $MSG_HELP_ogListPartitions  "+n_disk+"\"\n \
[f5d9d43]240ogUpdatePartitionTable "+n_disk+" \n \
[51f686c]241ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
[8a59a5f]242ogExecAndLog command session log ogListPartitions "+n_disk+" \n";
[eb3e2b8]243}
[a71cfe29]244
[523c8ac]245
[f5d9d43]246function codeParticionadoGPT (form) {
247        var partCode="";
248        var logicalCode="";
[b2651a6]249        var cacheCode="";
[f5d9d43]250        var cacheSize;
251        var extended=false;
252        var n_disk = form.n_disk.value;
253        var tipo_part_table = form.tipo_part_table.value;
254                numParts=document.getElementById("numGPTpartitions").value;
255               
256        for (var nPart=1; nPart <= numParts; nPart++) {
257                var partCheck=eval("form.checkGPT"+nPart);
258                if (partCheck.checked) {
[523c8ac]259                        // Distinguimos entre cache y el resto de particiones
[b2651a6]260                        // Solo tratamos la particion 4 como cache, si se selecciono este tipo
261                        if(nPart == 4 && form.partGPT4.value == "CACHE") {
[523c8ac]262                                if (form.sizeGPT4.value == "0") {
263                                        cacheCode="\
[d1795da]264ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \
[b2651a6]265sizecache=`ogGetCacheSize` \n \
[d1795da]266ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
[523c8ac]267ogDeletePartitionTable "+n_disk+"  \n \
[9a1df17]268ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \
[d1795da]269ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
[9a1df17]270initCache "+ n_disk +" $sizecache &>/dev/null \n ";
[523c8ac]271                                } else {
272                                        if (form.sizeGPT4.value == "CUSTOM") {
273                                                cacheSize = form.sizeGPT4custom.value;
274                                        } else {
275                                                cacheSize = form.sizeGPT4.value;
[f5d9d43]276                                        }
[523c8ac]277                                        cacheCode="\
[d1795da]278ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
279ogDeletePartitionTable "+n_disk+" \n \
[523c8ac]280ogUpdatePartitionTable "+n_disk+" \n \
[d1795da]281ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
[9a1df17]282initCache "  + n_disk +" "+ cacheSize + " &>/dev/null";
[523c8ac]283                                }
284                        } else{
285                                var partType=eval("form.partGPT"+nPart);
286                                if (partType.value == "CUSTOM" ) {
287                                        var partTypeCustom=eval("form.partGPT"+nPart+"custom");
288                                        partCode += " " + partTypeCustom.value;
289                                } else {
290                                        partCode += " " + partType.value;
291                                }
292                                var partSize=eval("form.sizeGPT"+nPart);
293                                if (partSize.value == "CUSTOM" ) {
294                                        var partSizeCustom=eval("form.sizeGPT"+nPart+"custom");
295                                        partCode += ":" + partSizeCustom.value;
296                                } else {
297                                        partCode += ":" + partSize.value;
298                                }
299                        }
300                } else {
301                        if(nPart == 4){
302                                cacheCode="\
[d1795da]303ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
[523c8ac]304ogDeletePartitionTable "+n_disk+" \n \
305ogUpdatePartitionTable "+n_disk+" \n";
306partCode += " EMPTY:0";
307                        } else{
308                                partCode += " EMPTY:0";
309                        }
[f5d9d43]310                }
311        }
[523c8ac]312        form.codigo.value="\
[f5d9d43]313ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
[d1795da]314ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \
315ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
[f5d9d43]316ogUnmountAll "+n_disk+" \n  \
[1a2fa9d8]317ogUnmountCache \n \
[f5d9d43]318" + cacheCode + " \n \
[d1795da]319ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
[9a1df17]320ogExecAndLog command session ogListPartitions "+n_disk+" \n \
[d1795da]321ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \
[9a1df17]322ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
[d1795da]323ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
[f5d9d43]324ogSetPartitionActive "+n_disk+" 1 \n \
[d1795da]325ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
[f5d9d43]326ogUpdatePartitionTable "+n_disk+" \n \
327ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
[8a59a5f]328ogExecAndLog command session log ogListPartitions "+n_disk+" \n";
[f5d9d43]329}
330
331
[523c8ac]332function showPartitionForm (tipo_table_part) {
[f5d9d43]333        document.getElementById("form"+tipo_table_part).style.display="inline";
334        if(tipo_table_part == "MSDOS"){
335                // De los dos tipos, se oculta el otro
336                document.getElementById("formGPT").style.display="none";
[523c8ac]337        } else{
[f5d9d43]338                document.getElementById("formMSDOS").style.display="none";
339        }
340}
341
[a71cfe29]342
343// Código de pulsación de selección de partición.
[523c8ac]344function clickPartitionCheckbox (form, npart, isGPT) {
[f5d9d43]345        // Si el parametro no esta definido, se toma como false
346        isGPT = (isGPT)?isGPT:"false";
347        if(isGPT == true){
348                prefix="GPT";
[523c8ac]349        } else {
[f5d9d43]350                prefix="";
351        }
352        var partCheck=eval("form.check"+prefix+npart);
353        var partType=eval("form.part"+prefix+npart);
354        var partSize=eval("form.size"+prefix+npart);
355        var partTypeCustom=eval("form.part"+prefix+npart+"custom");
356        var partSizeCustom=eval("form.size"+prefix+npart+"custom");
357        var freeDisk=document.getElementById("freedisk"+prefix);
358        //var logical=document.getElementById("logicas"+prefix);
[a71cfe29]359        if (partCheck.checked) {
360                partType.disabled=false;
361                partSize.disabled=false;
[f5d9d43]362                if(npart != 4){
363                        if (partType.options[partType.selectedIndex].value == "CUSTOM") {
364                                partTypeCustom.disabled=false;
365                        }
[a71cfe29]366                }
367                if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
368                        partSizeCustom.disabled=false;
369                } else {
370                        partSizeCustom.disabled=true;
371                }
372        } else {
373                partType.disabled=true;
374                partSize.disabled=true;
[b2651a6]375                // El campo TypeCustom no existe para la particion 4
376                if(npart != 4)
377                        partTypeCustom.disabled=true;
[a71cfe29]378                partSizeCustom.disabled=true;
379        }
[66d40b0]380        if (npart <= 4) {
[f5d9d43]381                // Si el formulario es GPT no hay extendidas
382                if(isGPT != true){
383                        checkExtendedPartition(form);
384                }
[66d40b0]385                calculateFreeDisk(form);
386        }
[a71cfe29]387}
388
[92cf666]389/**
390 * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco"
391 * y devuelve el de menor valor
392 */
393function getMinDiskSize(disk){
394        var diskSizeArray = document.getElementsByName("disksize_"+disk);
395        var minSize = diskSizeArray[0].value;
396        for(var i= 1; i < diskSizeArray.length; i++){
397                if(diskSizeArray[i].value < minSize)
398                        minSize = diskSizeArray[i].value;
399        }
400        return minSize;
401}
[a71cfe29]402
403// Código para calcular el espacio libre del disco.
[66d40b0]404function calculateFreeDisk(form) {
[f5d9d43]405        // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente
406        if(document.getElementById("tipo_part_table").value == "GPT"){
407                calculateFreeGPTDisk(form);
408        }
[2e69949]409        // Capturamos el disco seleccionado
410        var disk = document.getElementById("n_disk").value;
[92cf666]411        // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor
412        var diskSize = getMinDiskSize(disk);
413       
[2e69949]414               
[a71cfe29]415        var freeDisk=document.getElementById("freedisk");
[2e69949]416        freeDisk.value=diskSize;
[12603f8]417        for (var npart=1; npart<=4; npart++) {
[a71cfe29]418                var partCheck=eval("form.check"+npart);
419                var partSize=eval("form.size"+npart);
420                var partSizeCustom=eval("form.size"+npart+"custom");
421                if (partCheck.checked) {
422                        if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
423                                freeDisk.value -= parseInt(partSizeCustom.value);
424                        } else {
425                                freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
426                        }
427                }
428        }
429        if (parseInt(freeDisk.value) < 0) {
430                freeDisk.style.fontWeight = "bold";
431                freeDisk.style.fontStyle = "italic";
432        } else {
433                freeDisk.style.fontWeight = "normal";
434                freeDisk.style.fontStyle = "normal";
435        }
436        if (form.size4.value == 0) {
437                freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
438        }
439}
440
[f5d9d43]441// Código para calcular el espacio libre del disco. en el formulario GPT
442function calculateFreeGPTDisk(form) {
443        // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente
[2e69949]444    if(document.getElementById("tipo_part_table").value == "MSDOS"){
445            calculateFreeDisk(form);
446    }
447    // Capturamos el disco seleccionado
448        var disk = document.getElementById("n_disk").value;
449        // Buscamos el input hidden para el disco seleccionado
[92cf666]450        var diskSize = getMinDiskSize(disk);
[2e69949]451        document.getElementById('freediskGPT').value=diskSize;
452       
[f5d9d43]453        var freeDisk=document.getElementById("freediskGPT");
454        // Capturamos el numero de particiones que hay hechas
455        numParts=document.getElementById("numGPTpartitions").value;
[2e69949]456    for (npart=1; npart<=numParts; npart++) {
457            var partCheck=eval("form.checkGPT"+npart);
458            var partSize=eval("form.sizeGPT"+npart);
459            var partSizeCustom=eval("form.sizeGPT"+npart+"custom");
460            if (partCheck.checked) {
461                    if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
462                            freeDisk.value -= parseInt(partSizeCustom.value);
463                    } else {
464                            freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
465                    }
466            }
467    }
468    if (parseInt(freeDisk.value) < 0) {
469            freeDisk.style.fontWeight = "bold";
470            freeDisk.style.fontStyle = "italic";
471    } else {
472            freeDisk.style.fontWeight = "normal";
473            freeDisk.style.fontStyle = "normal";
474    }
475    if (form.size4.value == 0) {
476            freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
477    }
[f5d9d43]478}
479
480// Agrega una nueva fila a la tabla de particiones con una nueva particion
481function addGPTPartition(){
482        var partitionTypes = "";
[9f31169]483        partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>';
484        partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>';
485        partitionTypes+='<OPTION value="LINUX"> Linux </OTION>';
486        partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>';
487        partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>';
488        partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>';
489        partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>';
490        partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>';
491        partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>';
492        partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>';
493        partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>';
[fea9dfb]494        partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>';
[9f31169]495        partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>';
496        partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>';
497        partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>';
498        partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>';
499        partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>';
500        partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>';
501        partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>';
502        partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>';
503        partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>';
504        partitionTypes+='<OPTION value="EFI"> EFI </OPTION>';
505        partitionTypes+='<OPTION value="MBR"> MBR </OPTION>';
506        partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>';
[f5d9d43]507
508
509        table = document.getElementById("particionesGPT");
510        // Capturamos el numero de particiones, antes incrementamos
511        document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1
512        numPart=document.getElementById("numGPTpartitions").value;
513        partitionRow = table.insertRow(-1);
514        partitionRow.id = "trPartition"+numPart;
515        partitionRow.innerHTML="<td> \
516<input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partici&oacute;n "+numPart+"</td> \
517<td>\
518<select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
519        if (this.options[this.selectedIndex].value == \'CUSTOM\') { \
520                this.form.partGPT"+numPart+"custom.disabled=false; \
521        } else { \
522                this.form.partGPT"+numPart+"custom.disabled=true; \
523        }'><option value='CUSTOM'> Personalizar </option> \
524</select> \
525<br> \
526<select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \
527</td> \
528<td> \
529<select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
530        if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \
531                this.form.sizeGPT"+numPart+"custom.disabled=false; \
532        } else { \
533                this.form.sizeGPT"+numPart+"custom.disabled=true; \
534        } \
535' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \
536</select> \
537<br /> \
538<input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \
539</td>"
540
541}
542
543// Agrega una nueva fila a la tabla de particiones con una nueva particion
544function deleteGPTPartition(){
545        table = document.getElementById("particionesGPT");
546        // Capturamos el numero de particiones
547        numPart=document.getElementById("numGPTpartitions").value;
[c7b62bd]548        // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador
[f5d9d43]549        if(numPart > 4){
550                partitionRow = document.getElementById("trPartition"+numPart);
551                table.deleteRow(partitionRow.rowIndex);
[c7b62bd]552                // Decrementamos el numero de particiones
553                document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1;
[f5d9d43]554        }
555}
556
[66d40b0]557// Código para comprobar si hay partición extendida activa para mostrar las lógicas.
558function checkExtendedPartition(form) {
559        var logical=document.getElementById("logicas");
560        var visible=false;
[b2651a6]561        for (npart=1; npart<=4; npart++) {
[66d40b0]562                var partCheck=eval("form.check"+npart);
563                var partType=eval("form.part"+npart);
564                var partTypeCustom=eval("form.part"+npart+"custom");
565                if (partCheck.checked) {
566                        partType.style.fontWeight = "normal";
[b2651a6]567
[66d40b0]568                        if (partType.value == "EXTENDED") {
569                                visible=true;
570                                partType.style.fontWeight = "bold";
571                        }
[b2651a6]572                        // La particion 4 no tiene partTypeCustom
573                        if(npart != 4){
574                                partTypeCustom.style.fontWeight = "normal";
575                                if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") {
576                                        visible=true;
577                                        partTypeCustom.style.fontWeight = "bold";
578                                }
[66d40b0]579                        }
580                }
581        }
582        if (visible) {
583                logical.style.visibility="visible";
584        } else {
585                logical.style.visibility="hidden";
586        }
587}
588
Note: See TracBrowser for help on using the repository browser.