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