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