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