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 | // 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 |
---|
12 | // version 1.1: showPartitionForm: Se incluye aviso para particiones GTP. |
---|
13 | // autor: Irina Gomez, ETSII Universidad de Sevilla |
---|
14 | // fecha: 2016-06-21 |
---|
15 | // *********************************************************************************************************** |
---|
16 | |
---|
17 | function codeCloneRemotePartition(form){ |
---|
18 | var command ; |
---|
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; |
---|
29 | command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
30 | form.codigo.value="\ |
---|
31 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ |
---|
32 | ogExecAndLog command " + command + " \n "; |
---|
33 | } |
---|
34 | |
---|
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 | |
---|
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; |
---|
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; |
---|
60 | case "TORRENT": |
---|
61 | protocol=" TORRENT " + form.modp2p.value + ":" + form.timep2p.value; |
---|
62 | break; |
---|
63 | case "UNICAST": |
---|
64 | protocol=" UNICAST"; |
---|
65 | break; |
---|
66 | case "UNICAST-DIRECT": |
---|
67 | protocol=" UNICAST-DIRECT"; |
---|
68 | break; |
---|
69 | } |
---|
70 | //form.codigo.value="deployImage REPO /"; |
---|
71 | if (form.modo[0].checked) |
---|
72 | { |
---|
73 | // UHU - Distinguimos entre disco y particion, el valor de idparticion sera disco;particion. eje. 1;1 |
---|
74 | var diskPart = form.idparticion.value.split(";"); |
---|
75 | command="deployImage " + form.idimagen.value + " "+diskPart[0]+" " + diskPart[1] + " " + protocol ; |
---|
76 | form.codigo.value="\ |
---|
77 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ " + |
---|
78 | command + " \n"; |
---|
79 | //form.codigo.value="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol ; |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | command="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
84 | form.codigo.value="\ |
---|
85 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command +"\"\n \ " + |
---|
86 | command + " \n"; |
---|
87 | //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
88 | } |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | function codeParticionado(form){ |
---|
93 | var errorMsg = "¡El espacio libre en disco no puede ser menor que 0!"; |
---|
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"){ |
---|
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 | } |
---|
105 | } |
---|
106 | else{ |
---|
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 | } |
---|
114 | } |
---|
115 | |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | function codeParticionadoMSDOS (form) { |
---|
120 | var partCode=""; |
---|
121 | var logicalCode=""; |
---|
122 | var sizecacheCode=""; |
---|
123 | var cacheCode; |
---|
124 | var cacheSize; |
---|
125 | var extended=false; |
---|
126 | var n_disk = form.n_disk.value; |
---|
127 | var tipo_part_table = form.tipo_part_table.value; |
---|
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; |
---|
133 | |
---|
134 | for (var nPart=1; nPart<maxParts; nPart++) { |
---|
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 | } |
---|
160 | } |
---|
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") { |
---|
168 | sizecacheCode="\ |
---|
169 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
170 | sizecache=`ogGetCacheSize` \n "; |
---|
171 | cacheCode="\ |
---|
172 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
173 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
174 | ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \ |
---|
175 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
176 | initCache "+n_disk+" $sizecache NOMOUNT &>/dev/null \n "; |
---|
177 | } else { |
---|
178 | if (form.size4.value == "CUSTOM") { |
---|
179 | cacheSize = form.size4custom.value; |
---|
180 | } else { |
---|
181 | cacheSize = form.size4.value; |
---|
182 | } |
---|
183 | cacheCode="\ |
---|
184 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
185 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
186 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
187 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
188 | initCache " + n_disk + " " + cacheSize + " NOMOUNT &>/dev/null"; |
---|
189 | } |
---|
190 | } else { |
---|
191 | cacheCode="\ |
---|
192 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
193 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
194 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
195 | partCode += " EMPTY:0"; |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
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 | } |
---|
230 | |
---|
231 | form.codigo.value="\ |
---|
232 | " + sizecacheCode + " \n \ |
---|
233 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
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 \ |
---|
237 | ogUnmountCache \n \ |
---|
238 | " + cacheCode + " \n \ |
---|
239 | ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
240 | ogExecAndLog command session ogListPartitions "+n_disk+" \n \ |
---|
241 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
242 | ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \ |
---|
243 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
244 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
245 | ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
246 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
247 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
248 | ogExecAndLog command session log ogListPartitions "+n_disk+" \n"; |
---|
249 | } |
---|
250 | |
---|
251 | |
---|
252 | function codeParticionadoGPT (form) { |
---|
253 | var partCode=""; |
---|
254 | var logicalCode=""; |
---|
255 | var sizecacheCode=""; |
---|
256 | var cacheCode=""; |
---|
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) { |
---|
266 | // Distinguimos entre cache y el resto de particiones |
---|
267 | // Solo tratamos la particion 4 como cache, si se selecciono este tipo |
---|
268 | if(nPart == 4 && form.partGPT4.value == "CACHE") { |
---|
269 | if (form.sizeGPT4.value == "0") { |
---|
270 | sizecacheCode="\ |
---|
271 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
272 | sizecache=`ogGetCacheSize` \n "; |
---|
273 | cacheCode="\ |
---|
274 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
275 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
276 | ogExecAndLog command ogUpdatePartitionTable "+n_disk+" \n \ |
---|
277 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
278 | initCache "+ n_disk +" $sizecache NOMOUNT &>/dev/null \n "; |
---|
279 | } else { |
---|
280 | if (form.sizeGPT4.value == "CUSTOM") { |
---|
281 | cacheSize = form.sizeGPT4custom.value; |
---|
282 | } else { |
---|
283 | cacheSize = form.sizeGPT4.value; |
---|
284 | } |
---|
285 | cacheCode="\ |
---|
286 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
287 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
288 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
289 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
290 | initCache " + n_disk +" "+ cacheSize + " NOMOUNT &>/dev/null"; |
---|
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="\ |
---|
311 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
312 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
313 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
314 | partCode += " EMPTY:0"; |
---|
315 | } else{ |
---|
316 | partCode += " EMPTY:0"; |
---|
317 | } |
---|
318 | } |
---|
319 | } |
---|
320 | form.codigo.value="\ |
---|
321 | " + sizecacheCode + " \n \ |
---|
322 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
323 | ogEcho log session \"[0] $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \ |
---|
324 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
325 | ogUnmountAll "+n_disk+" \n \ |
---|
326 | ogUnmountCache \n \ |
---|
327 | " + cacheCode + " \n \ |
---|
328 | ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
329 | ogExecAndLog command session ogListPartitions "+n_disk+" \n \ |
---|
330 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
331 | ogExecAndLog command ogCreatePartitions "+n_disk+" " + partCode + " \n \ |
---|
332 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
333 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
334 | ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
335 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
336 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
337 | ogExecAndLog command session log ogListPartitions "+n_disk+" \n"; |
---|
338 | } |
---|
339 | |
---|
340 | |
---|
341 | function showPartitionForm (tipo_table_part) { |
---|
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"; |
---|
346 | document.getElementById("warngpt").style.display="none"; |
---|
347 | } else{ |
---|
348 | document.getElementById("formMSDOS").style.display="none"; |
---|
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"; |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | |
---|
363 | // Código de pulsación de selección de partición. |
---|
364 | function clickPartitionCheckbox (form, npart, isGPT) { |
---|
365 | // Si el parametro no esta definido, se toma como false |
---|
366 | isGPT = (isGPT)?isGPT:"false"; |
---|
367 | if(isGPT == true){ |
---|
368 | prefix="GPT"; |
---|
369 | } else { |
---|
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); |
---|
379 | if (partCheck.checked) { |
---|
380 | partType.disabled=false; |
---|
381 | partSize.disabled=false; |
---|
382 | if(npart != 4){ |
---|
383 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
384 | partTypeCustom.disabled=false; |
---|
385 | } |
---|
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; |
---|
395 | // El campo TypeCustom no existe para la particion 4 |
---|
396 | if(npart != 4) |
---|
397 | partTypeCustom.disabled=true; |
---|
398 | partSizeCustom.disabled=true; |
---|
399 | } |
---|
400 | if (npart <= 4) { |
---|
401 | // Si el formulario es GPT no hay extendidas |
---|
402 | if(isGPT != true){ |
---|
403 | checkExtendedPartition(form); |
---|
404 | } |
---|
405 | calculateFreeDisk(form); |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
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 | } |
---|
422 | |
---|
423 | // Código para calcular el espacio libre del disco. |
---|
424 | function calculateFreeDisk(form) { |
---|
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 | } |
---|
429 | // Capturamos el disco seleccionado |
---|
430 | var disk = document.getElementById("n_disk").value; |
---|
431 | // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor |
---|
432 | var diskSize = getMinDiskSize(disk); |
---|
433 | |
---|
434 | |
---|
435 | var freeDisk=document.getElementById("freedisk"); |
---|
436 | freeDisk.value=diskSize; |
---|
437 | for (var npart=1; npart<=4; npart++) { |
---|
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 | |
---|
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 |
---|
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 |
---|
470 | var diskSize = getMinDiskSize(disk); |
---|
471 | document.getElementById('freediskGPT').value=diskSize; |
---|
472 | |
---|
473 | var freeDisk=document.getElementById("freediskGPT"); |
---|
474 | // Capturamos el numero de particiones que hay hechas |
---|
475 | numParts=document.getElementById("numGPTpartitions").value; |
---|
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 | } |
---|
498 | } |
---|
499 | |
---|
500 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
501 | function addGPTPartition(){ |
---|
502 | var partitionTypes = ""; |
---|
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>'; |
---|
514 | partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>'; |
---|
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>'; |
---|
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; |
---|
568 | // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador |
---|
569 | if(numPart > 4){ |
---|
570 | partitionRow = document.getElementById("trPartition"+numPart); |
---|
571 | table.deleteRow(partitionRow.rowIndex); |
---|
572 | // Decrementamos el numero de particiones |
---|
573 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1; |
---|
574 | } |
---|
575 | } |
---|
576 | |
---|
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; |
---|
581 | for (npart=1; npart<=4; npart++) { |
---|
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"; |
---|
587 | |
---|
588 | if (partType.value == "EXTENDED") { |
---|
589 | visible=true; |
---|
590 | partType.style.fontWeight = "bold"; |
---|
591 | } |
---|
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 | } |
---|
599 | } |
---|
600 | } |
---|
601 | } |
---|
602 | if (visible) { |
---|
603 | logical.style.visibility="visible"; |
---|
604 | } else { |
---|
605 | logical.style.visibility="hidden"; |
---|
606 | } |
---|
607 | } |
---|
608 | |
---|