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