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

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 b584da5 was 0285a39, checked in by irina <irinagomez@…>, 10 years ago

#679 Varios repos: cambios en consola web en el comando restaurar imagen y el asistente de deploy de imágenes para permitan restaurar las imágenes de todos los repositorios de la UO.

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

  • Property mode set to 100644
File size: 22.0 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 \
[9a1df17]242ogExecAndLog command session log ogListPartitions "+n_disk+" \n \
[3b8969b]243reboot \n";
[eb3e2b8]244}
[a71cfe29]245
[523c8ac]246
[f5d9d43]247function codeParticionadoGPT (form) {
248        var partCode="";
249        var logicalCode="";
[b2651a6]250        var cacheCode="";
[f5d9d43]251        var cacheSize;
252        var extended=false;
253        var n_disk = form.n_disk.value;
254        var tipo_part_table = form.tipo_part_table.value;
255                numParts=document.getElementById("numGPTpartitions").value;
256               
257        for (var nPart=1; nPart <= numParts; nPart++) {
258                var partCheck=eval("form.checkGPT"+nPart);
259                if (partCheck.checked) {
[523c8ac]260                        // Distinguimos entre cache y el resto de particiones
[b2651a6]261                        // Solo tratamos la particion 4 como cache, si se selecciono este tipo
262                        if(nPart == 4 && form.partGPT4.value == "CACHE") {
[523c8ac]263                                if (form.sizeGPT4.value == "0") {
264                                        cacheCode="\
[d1795da]265ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \
[b2651a6]266sizecache=`ogGetCacheSize` \n \
[d1795da]267ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
[523c8ac]268ogDeletePartitionTable "+n_disk+"  \n \
[9a1df17]269ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \
[d1795da]270ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
[9a1df17]271initCache "+ n_disk +" $sizecache &>/dev/null \n ";
[523c8ac]272                                } else {
273                                        if (form.sizeGPT4.value == "CUSTOM") {
274                                                cacheSize = form.sizeGPT4custom.value;
275                                        } else {
276                                                cacheSize = form.sizeGPT4.value;
[f5d9d43]277                                        }
[523c8ac]278                                        cacheCode="\
[d1795da]279ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
280ogDeletePartitionTable "+n_disk+" \n \
[523c8ac]281ogUpdatePartitionTable "+n_disk+" \n \
[d1795da]282ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \
[9a1df17]283initCache "  + n_disk +" "+ cacheSize + " &>/dev/null";
[523c8ac]284                                }
285                        } else{
286                                var partType=eval("form.partGPT"+nPart);
287                                if (partType.value == "CUSTOM" ) {
288                                        var partTypeCustom=eval("form.partGPT"+nPart+"custom");
289                                        partCode += " " + partTypeCustom.value;
290                                } else {
291                                        partCode += " " + partType.value;
292                                }
293                                var partSize=eval("form.sizeGPT"+nPart);
294                                if (partSize.value == "CUSTOM" ) {
295                                        var partSizeCustom=eval("form.sizeGPT"+nPart+"custom");
296                                        partCode += ":" + partSizeCustom.value;
297                                } else {
298                                        partCode += ":" + partSize.value;
299                                }
300                        }
301                } else {
302                        if(nPart == 4){
303                                cacheCode="\
[d1795da]304ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \
[523c8ac]305ogDeletePartitionTable "+n_disk+" \n \
306ogUpdatePartitionTable "+n_disk+" \n";
307partCode += " EMPTY:0";
308                        } else{
309                                partCode += " EMPTY:0";
310                        }
[f5d9d43]311                }
312        }
[523c8ac]313        form.codigo.value="\
[f5d9d43]314ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \
[d1795da]315ogEcho log session \"[0]  $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \
316ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \
[f5d9d43]317ogUnmountAll "+n_disk+" \n  \
[1a2fa9d8]318ogUnmountCache \n \
[f5d9d43]319" + cacheCode + " \n \
[d1795da]320ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
[9a1df17]321ogExecAndLog command session ogListPartitions "+n_disk+" \n \
[d1795da]322ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \
[9a1df17]323ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \
[d1795da]324ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \
[f5d9d43]325ogSetPartitionActive "+n_disk+" 1 \n \
[d1795da]326ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \
[f5d9d43]327ogUpdatePartitionTable "+n_disk+" \n \
328ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \
[9a1df17]329ogExecAndLog command session log ogListPartitions "+n_disk+" \n \
[3b8969b]330reboot \n";
[f5d9d43]331}
332
333
[523c8ac]334function showPartitionForm (tipo_table_part) {
[f5d9d43]335        document.getElementById("form"+tipo_table_part).style.display="inline";
336        if(tipo_table_part == "MSDOS"){
337                // De los dos tipos, se oculta el otro
338                document.getElementById("formGPT").style.display="none";
[523c8ac]339        } else{
[f5d9d43]340                document.getElementById("formMSDOS").style.display="none";
341        }
342}
343
[a71cfe29]344
345// Código de pulsación de selección de partición.
[523c8ac]346function clickPartitionCheckbox (form, npart, isGPT) {
[f5d9d43]347        // Si el parametro no esta definido, se toma como false
348        isGPT = (isGPT)?isGPT:"false";
349        if(isGPT == true){
350                prefix="GPT";
[523c8ac]351        } else {
[f5d9d43]352                prefix="";
353        }
354        var partCheck=eval("form.check"+prefix+npart);
355        var partType=eval("form.part"+prefix+npart);
356        var partSize=eval("form.size"+prefix+npart);
357        var partTypeCustom=eval("form.part"+prefix+npart+"custom");
358        var partSizeCustom=eval("form.size"+prefix+npart+"custom");
359        var freeDisk=document.getElementById("freedisk"+prefix);
360        //var logical=document.getElementById("logicas"+prefix);
[a71cfe29]361        if (partCheck.checked) {
362                partType.disabled=false;
363                partSize.disabled=false;
[f5d9d43]364                if(npart != 4){
365                        if (partType.options[partType.selectedIndex].value == "CUSTOM") {
366                                partTypeCustom.disabled=false;
367                        }
[a71cfe29]368                }
369                if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
370                        partSizeCustom.disabled=false;
371                } else {
372                        partSizeCustom.disabled=true;
373                }
374        } else {
375                partType.disabled=true;
376                partSize.disabled=true;
[b2651a6]377                // El campo TypeCustom no existe para la particion 4
378                if(npart != 4)
379                        partTypeCustom.disabled=true;
[a71cfe29]380                partSizeCustom.disabled=true;
381        }
[66d40b0]382        if (npart <= 4) {
[f5d9d43]383                // Si el formulario es GPT no hay extendidas
384                if(isGPT != true){
385                        checkExtendedPartition(form);
386                }
[66d40b0]387                calculateFreeDisk(form);
388        }
[a71cfe29]389}
390
[92cf666]391/**
392 * Dado un numero de disco, recorre todos los input hidden con nombre disksize_"disco"
393 * y devuelve el de menor valor
394 */
395function getMinDiskSize(disk){
396        var diskSizeArray = document.getElementsByName("disksize_"+disk);
397        var minSize = diskSizeArray[0].value;
398        for(var i= 1; i < diskSizeArray.length; i++){
399                if(diskSizeArray[i].value < minSize)
400                        minSize = diskSizeArray[i].value;
401        }
402        return minSize;
403}
[a71cfe29]404
405// Código para calcular el espacio libre del disco.
[66d40b0]406function calculateFreeDisk(form) {
[f5d9d43]407        // Si esta seleccionada la opcion GPT, se llama a la funcion correspondiente
408        if(document.getElementById("tipo_part_table").value == "GPT"){
409                calculateFreeGPTDisk(form);
410        }
[2e69949]411        // Capturamos el disco seleccionado
412        var disk = document.getElementById("n_disk").value;
[92cf666]413        // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor
414        var diskSize = getMinDiskSize(disk);
415       
[2e69949]416               
[a71cfe29]417        var freeDisk=document.getElementById("freedisk");
[2e69949]418        freeDisk.value=diskSize;
[12603f8]419        for (var npart=1; npart<=4; npart++) {
[a71cfe29]420                var partCheck=eval("form.check"+npart);
421                var partSize=eval("form.size"+npart);
422                var partSizeCustom=eval("form.size"+npart+"custom");
423                if (partCheck.checked) {
424                        if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
425                                freeDisk.value -= parseInt(partSizeCustom.value);
426                        } else {
427                                freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
428                        }
429                }
430        }
431        if (parseInt(freeDisk.value) < 0) {
432                freeDisk.style.fontWeight = "bold";
433                freeDisk.style.fontStyle = "italic";
434        } else {
435                freeDisk.style.fontWeight = "normal";
436                freeDisk.style.fontStyle = "normal";
437        }
438        if (form.size4.value == 0) {
439                freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
440        }
441}
442
[f5d9d43]443// Código para calcular el espacio libre del disco. en el formulario GPT
444function calculateFreeGPTDisk(form) {
445        // Si esta seleccionada la opcion MSDOS, se llama a la funcion correspondiente
[2e69949]446    if(document.getElementById("tipo_part_table").value == "MSDOS"){
447            calculateFreeDisk(form);
448    }
449    // Capturamos el disco seleccionado
450        var disk = document.getElementById("n_disk").value;
451        // Buscamos el input hidden para el disco seleccionado
[92cf666]452        var diskSize = getMinDiskSize(disk);
[2e69949]453        document.getElementById('freediskGPT').value=diskSize;
454       
[f5d9d43]455        var freeDisk=document.getElementById("freediskGPT");
456        // Capturamos el numero de particiones que hay hechas
457        numParts=document.getElementById("numGPTpartitions").value;
[2e69949]458    for (npart=1; npart<=numParts; npart++) {
459            var partCheck=eval("form.checkGPT"+npart);
460            var partSize=eval("form.sizeGPT"+npart);
461            var partSizeCustom=eval("form.sizeGPT"+npart+"custom");
462            if (partCheck.checked) {
463                    if (partSize.options[partSize.selectedIndex].value == "CUSTOM") {
464                            freeDisk.value -= parseInt(partSizeCustom.value);
465                    } else {
466                            freeDisk.value -= parseInt(partSize.options[partSize.selectedIndex].value);
467                    }
468            }
469    }
470    if (parseInt(freeDisk.value) < 0) {
471            freeDisk.style.fontWeight = "bold";
472            freeDisk.style.fontStyle = "italic";
473    } else {
474            freeDisk.style.fontWeight = "normal";
475            freeDisk.style.fontStyle = "normal";
476    }
477    if (form.size4.value == 0) {
478            freeDisk.value += " (- cache)";         // Aviso de caché sin modificar.
479    }
[f5d9d43]480}
481
482// Agrega una nueva fila a la tabla de particiones con una nueva particion
483function addGPTPartition(){
484        var partitionTypes = "";
[9f31169]485        partitionTypes+='<OPTION value="WINDOWS"> Windows </OPTION>';
486        partitionTypes+='<OPTION value="WIN-RESERV"> Windows Reserved </OPTION>';
487        partitionTypes+='<OPTION value="LINUX"> Linux </OTION>';
488        partitionTypes+='<OPTION value="LINUX-RESERV"> Linux Reserved </OPTION>';
489        partitionTypes+='<OPTION value="LINUX-SWAP"> Linux Swap </OPTION>';
490        partitionTypes+='<OPTION value="LINUX-RAID"> Linux RAID </OPTION>';
491        partitionTypes+='<OPTION value="LINUX-LVM"> Linux LVM </OPTION>';
492        partitionTypes+='<OPTION value="CHROMEOS"> ChromeOS </OTION>';
493        partitionTypes+='<OPTION value="CHROMEOS-KRN"> ChromeOS Kernel </OPTION>';
494        partitionTypes+='<OPTION value="CHROMEOS-RESERV"> ChromeOS Reserved </OPTION>';
495        partitionTypes+='<OPTION value="HFS"> MacOS HFS </OPTION>';
[fea9dfb]496        partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>';
[9f31169]497        partitionTypes+='<OPTION value="HFS-RAID"> MacOS HFS RAID </OPTION>';
498        partitionTypes+='<OPTION value="FREEBSD"> FreeBSD </OPTION>';
499        partitionTypes+='<OPTION value="FREEBSD-DISK"> FreeBSD Disk </OPTION>';
500        partitionTypes+='<OPTION value="FREEBSD-BOOT"> FreeBSD Boot </OPTION>';
501        partitionTypes+='<OPTION value="FREEBSD-SWAP"> FreeBSD Swap </OPTION>';
502        partitionTypes+='<OPTION value="SOLARIS"> Solaris </OPTION>';
503        partitionTypes+='<OPTION value="SOLARIS-DISK"> Solaris Disk </OPTION>';
504        partitionTypes+='<OPTION value="SOLARIS-BOOT"> Solaris Boot </OPTION>';
505        partitionTypes+='<OPTION value="SOLARIS-SWAP"> Solaris Swap </OPTION>';
506        partitionTypes+='<OPTION value="EFI"> EFI </OPTION>';
507        partitionTypes+='<OPTION value="MBR"> MBR </OPTION>';
508        partitionTypes+='<OPTION value="BIOS-BOOT"> BIOS Boot </OPTION>';
[f5d9d43]509
510
511        table = document.getElementById("particionesGPT");
512        // Capturamos el numero de particiones, antes incrementamos
513        document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)+1
514        numPart=document.getElementById("numGPTpartitions").value;
515        partitionRow = table.insertRow(-1);
516        partitionRow.id = "trPartition"+numPart;
517        partitionRow.innerHTML="<td> \
518<input type='checkbox' name='checkGPT"+numPart+"' value='checkGPT"+numPart+"' onclick='clickPartitionCheckbox(this.form, "+numPart+",true);' /> Partici&oacute;n "+numPart+"</td> \
519<td>\
520<select name='partGPT"+numPart+"' id='partGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
521        if (this.options[this.selectedIndex].value == \'CUSTOM\') { \
522                this.form.partGPT"+numPart+"custom.disabled=false; \
523        } else { \
524                this.form.partGPT"+numPart+"custom.disabled=true; \
525        }'><option value='CUSTOM'> Personalizar </option> \
526</select> \
527<br> \
528<select name='partGPT"+numPart+"custom' id='partGPT"+numPart+"custom' style='width:220' disabled='true' >"+partitionTypes+"</select> \
529</td> \
530<td> \
531<select name='sizeGPT"+numPart+"' id='sizeGPT"+numPart+"' style='width:220' disabled='true' onclick=' \
532        if (this.form.size"+numPart+".options[this.form.size"+numPart+".selectedIndex].value == \'CUSTOM\') { \
533                this.form.sizeGPT"+numPart+"custom.disabled=false; \
534        } else { \
535                this.form.sizeGPT"+numPart+"custom.disabled=true; \
536        } \
537' onchange='calculateFreeGPTDisk(this.form);'>0<option value='CUSTOM'> Personalizar </option> \
538</select> \
539<br /> \
540<input type='text' style='width:100' name='sizeGPT"+numPart+"custom' value='0' disabled='true' onchange='calculateFreeDisk(this.form);' /> \
541</td>"
542
543}
544
545// Agrega una nueva fila a la tabla de particiones con una nueva particion
546function deleteGPTPartition(){
547        table = document.getElementById("particionesGPT");
548        // Capturamos el numero de particiones
549        numPart=document.getElementById("numGPTpartitions").value;
[c7b62bd]550        // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador
[f5d9d43]551        if(numPart > 4){
552                partitionRow = document.getElementById("trPartition"+numPart);
553                table.deleteRow(partitionRow.rowIndex);
[c7b62bd]554                // Decrementamos el numero de particiones
555                document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1;
[f5d9d43]556        }
557}
558
[66d40b0]559// Código para comprobar si hay partición extendida activa para mostrar las lógicas.
560function checkExtendedPartition(form) {
561        var logical=document.getElementById("logicas");
562        var visible=false;
[b2651a6]563        for (npart=1; npart<=4; npart++) {
[66d40b0]564                var partCheck=eval("form.check"+npart);
565                var partType=eval("form.part"+npart);
566                var partTypeCustom=eval("form.part"+npart+"custom");
567                if (partCheck.checked) {
568                        partType.style.fontWeight = "normal";
[b2651a6]569
[66d40b0]570                        if (partType.value == "EXTENDED") {
571                                visible=true;
572                                partType.style.fontWeight = "bold";
573                        }
[b2651a6]574                        // La particion 4 no tiene partTypeCustom
575                        if(npart != 4){
576                                partTypeCustom.style.fontWeight = "normal";
577                                if (partType.value == "CUSTOM" && partTypeCustom.value == "EXTENDED") {
578                                        visible=true;
579                                        partTypeCustom.style.fontWeight = "bold";
580                                }
[66d40b0]581                        }
582                }
583        }
584        if (visible) {
585                logical.style.visibility="visible";
586        } else {
587                logical.style.visibility="hidden";
588        }
589}
590
Note: See TracBrowser for help on using the repository browser.