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

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 426ca26 was dd14ed2, checked in by irina <irinagomez@…>, 8 years ago

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

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

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