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){ |
---|
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; |
---|
22 | command="cloneRemoteFromMaster " + form.ipMaster.value + " " + form.source.value + " " + protocol + " " + form.targetpart.value + " " + form.tool.value + " " + form.compresor.value; |
---|
23 | form.codigo.value="\ |
---|
24 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + comand + "\"\n " + |
---|
25 | command + " | tee -a $OGLOGCOMMAND \n "; |
---|
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; |
---|
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; |
---|
39 | case "UNICAST": |
---|
40 | protocol=" UNICAST"; |
---|
41 | break; |
---|
42 | } |
---|
43 | //form.codigo.value="deployImage REPO /"; |
---|
44 | if (form.modo[0].checked) |
---|
45 | { |
---|
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 ; |
---|
49 | form.codigo.value="\ |
---|
50 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command + "\"\n \ " + |
---|
51 | command + " \n"; |
---|
52 | //form.codigo.value="deployImage REPO /" + form.idimagen.value + " 1 " + form.idparticion.value + " " + protocol ; |
---|
53 | } |
---|
54 | else |
---|
55 | { |
---|
56 | command="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
57 | form.codigo.value="\ |
---|
58 | ogEcho log session \"[0] $MSG_SCRIPTS_TASK_START " + command +"\"\n \ " + |
---|
59 | command + " \n"; |
---|
60 | //form.codigo.value="updateCache REPO /" + form.idimagen.value + ".img" + " " + protocol ; |
---|
61 | } |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | function codeParticionado(form){ |
---|
66 | var errorMsg = "¡El espacio libre en disco no puede ser menor que 0!"; |
---|
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"){ |
---|
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 | } |
---|
78 | } |
---|
79 | else{ |
---|
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 | } |
---|
87 | } |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | function codeParticionadoMSDOS (form) { |
---|
93 | var partCode=""; |
---|
94 | var logicalCode=""; |
---|
95 | var cacheCode; |
---|
96 | var cacheSize; |
---|
97 | var extended=false; |
---|
98 | var n_disk = form.n_disk.value; |
---|
99 | var tipo_part_table = form.tipo_part_table.value; |
---|
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; |
---|
105 | |
---|
106 | for (var nPart=1; nPart<maxParts; nPart++) { |
---|
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 | } |
---|
132 | } |
---|
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="\ |
---|
141 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
142 | sizecache=`ogGetCacheSize` \n \ |
---|
143 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
144 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
145 | ogUpdatePartitionTable "+n_disk+" | tee -a $OGLOGCOMMAND \n \ |
---|
146 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
147 | initCache "+n_disk+" $sizecache &>/dev/null | tee -a $OGLOGCOMMAND \n "; |
---|
148 | } else { |
---|
149 | if (form.size4.value == "CUSTOM") { |
---|
150 | cacheSize = form.size4custom.value; |
---|
151 | } else { |
---|
152 | cacheSize = form.size4.value; |
---|
153 | } |
---|
154 | cacheCode="\ |
---|
155 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
156 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
157 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
158 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
159 | initCache " + n_disk + " " + cacheSize + " &>/dev/null | tee -a $OGLOGCOMMAND"; |
---|
160 | } |
---|
161 | } else { |
---|
162 | cacheCode="\ |
---|
163 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
164 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
165 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
166 | partCode += " EMPTY:0"; |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
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 | } |
---|
201 | |
---|
202 | form.codigo.value="\ |
---|
203 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
204 | ogEcho log session \"[0] $MSG_HELP_ogCreatePartitions \"\n \ |
---|
205 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
206 | ogUnmountCache \n \ |
---|
207 | ogUnmountAll "+n_disk+" 2>/dev/null\n \ |
---|
208 | " + cacheCode + " \n \ |
---|
209 | ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
210 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION \n \ |
---|
211 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
212 | ogCreatePartitions "+n_disk+" " + partCode + " | tee -a $OGLOGCOMMAND \n \ |
---|
213 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
214 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
215 | ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
216 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
217 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
218 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION $OGLOGFILE \n \ |
---|
219 | reboot \n"; |
---|
220 | } |
---|
221 | |
---|
222 | |
---|
223 | function codeParticionadoGPT (form) { |
---|
224 | var partCode=""; |
---|
225 | var logicalCode=""; |
---|
226 | var cacheCode=""; |
---|
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) { |
---|
236 | // Distinguimos entre cache y el resto de particiones |
---|
237 | // Solo tratamos la particion 4 como cache, si se selecciono este tipo |
---|
238 | if(nPart == 4 && form.partGPT4.value == "CACHE") { |
---|
239 | if (form.sizeGPT4.value == "0") { |
---|
240 | cacheCode="\ |
---|
241 | ogEcho session \"[20] $MSG_HELP_ogGetCacheSize\"\n \ |
---|
242 | sizecache=`ogGetCacheSize` \n \ |
---|
243 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
244 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
245 | ogUpdatePartitionTable "+n_disk+" | tee -a $OGLOGCOMMAND \n \ |
---|
246 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
247 | initCache "+ n_disk +" $sizecache &>/dev/null | tee -a $OGLOGCOMMAND \n "; |
---|
248 | } else { |
---|
249 | if (form.sizeGPT4.value == "CUSTOM") { |
---|
250 | cacheSize = form.sizeGPT4custom.value; |
---|
251 | } else { |
---|
252 | cacheSize = form.sizeGPT4.value; |
---|
253 | } |
---|
254 | cacheCode="\ |
---|
255 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
256 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
257 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
258 | ogEcho session \"[50] $MSG_HELP_ogCreateCache\"\n \ |
---|
259 | initCache " + n_disk +" "+ cacheSize + " &>/dev/null | tee -a $OGLOGCOMMAND"; |
---|
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="\ |
---|
280 | ogEcho session \"[30] $MSG_HELP_ogUpdatePartitionTable "+n_disk+"\"\n \ |
---|
281 | ogDeletePartitionTable "+n_disk+" \n \ |
---|
282 | ogUpdatePartitionTable "+n_disk+" \n"; |
---|
283 | partCode += " EMPTY:0"; |
---|
284 | } else{ |
---|
285 | partCode += " EMPTY:0"; |
---|
286 | } |
---|
287 | } |
---|
288 | } |
---|
289 | form.codigo.value="\ |
---|
290 | ogCreatePartitionTable "+n_disk+" "+tipo_part_table +" \n \ |
---|
291 | ogEcho log session \"[0] $MSG_HELP_ogCreatePartitions "+n_disk+"\"\n \ |
---|
292 | ogEcho session \"[10] $MSG_HELP_ogUnmountAll "+n_disk+"\"\n \ |
---|
293 | ogUnmountCache \n \ |
---|
294 | ogUnmountAll "+n_disk+" \n \ |
---|
295 | " + cacheCode + " \n \ |
---|
296 | ogEcho session \"[60] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
297 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION \n \ |
---|
298 | ogEcho session \"[70] $MSG_HELP_ogCreatePartitions " + partCode + "\"\n \ |
---|
299 | ogCreatePartitions "+n_disk+" " + partCode + " | tee -a $OGLOGCOMMAND \n \ |
---|
300 | ogEcho session \"[80] $MSG_HELP_ogSetPartitionActive "+n_disk+" 1\"\n \ |
---|
301 | ogSetPartitionActive "+n_disk+" 1 \n \ |
---|
302 | ogEcho log session \"[100] $MSG_HELP_ogListPartitions "+n_disk+"\"\n \ |
---|
303 | ogUpdatePartitionTable "+n_disk+" \n \ |
---|
304 | ms-sys /dev/sda | grep unknow && ms-sys /dev/sda \n \ |
---|
305 | ogListPartitions "+n_disk+" | tee -a $OGLOGCOMMAND $OGLOGSESSION $OGLOGFILE \n \ |
---|
306 | reboot \n"; |
---|
307 | } |
---|
308 | |
---|
309 | |
---|
310 | function showPartitionForm (tipo_table_part) { |
---|
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"; |
---|
315 | } else{ |
---|
316 | document.getElementById("formMSDOS").style.display="none"; |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | |
---|
321 | // Código de pulsación de selección de partición. |
---|
322 | function clickPartitionCheckbox (form, npart, isGPT) { |
---|
323 | // Si el parametro no esta definido, se toma como false |
---|
324 | isGPT = (isGPT)?isGPT:"false"; |
---|
325 | if(isGPT == true){ |
---|
326 | prefix="GPT"; |
---|
327 | } else { |
---|
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); |
---|
337 | if (partCheck.checked) { |
---|
338 | partType.disabled=false; |
---|
339 | partSize.disabled=false; |
---|
340 | if(npart != 4){ |
---|
341 | if (partType.options[partType.selectedIndex].value == "CUSTOM") { |
---|
342 | partTypeCustom.disabled=false; |
---|
343 | } |
---|
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; |
---|
353 | // El campo TypeCustom no existe para la particion 4 |
---|
354 | if(npart != 4) |
---|
355 | partTypeCustom.disabled=true; |
---|
356 | partSizeCustom.disabled=true; |
---|
357 | } |
---|
358 | if (npart <= 4) { |
---|
359 | // Si el formulario es GPT no hay extendidas |
---|
360 | if(isGPT != true){ |
---|
361 | checkExtendedPartition(form); |
---|
362 | } |
---|
363 | calculateFreeDisk(form); |
---|
364 | } |
---|
365 | } |
---|
366 | |
---|
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 | } |
---|
380 | |
---|
381 | // Código para calcular el espacio libre del disco. |
---|
382 | function calculateFreeDisk(form) { |
---|
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 | } |
---|
387 | // Capturamos el disco seleccionado |
---|
388 | var disk = document.getElementById("n_disk").value; |
---|
389 | // Buscamos por nombre todos los campos disksize_"disk" y nos quedamos con el de menor valor |
---|
390 | var diskSize = getMinDiskSize(disk); |
---|
391 | |
---|
392 | |
---|
393 | var freeDisk=document.getElementById("freedisk"); |
---|
394 | freeDisk.value=diskSize; |
---|
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 | |
---|
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 |
---|
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 |
---|
428 | var diskSize = getMinDiskSize(disk); |
---|
429 | document.getElementById('freediskGPT').value=diskSize; |
---|
430 | |
---|
431 | var freeDisk=document.getElementById("freediskGPT"); |
---|
432 | // Capturamos el numero de particiones que hay hechas |
---|
433 | numParts=document.getElementById("numGPTpartitions").value; |
---|
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 | } |
---|
456 | } |
---|
457 | |
---|
458 | // Agrega una nueva fila a la tabla de particiones con una nueva particion |
---|
459 | function addGPTPartition(){ |
---|
460 | var partitionTypes = ""; |
---|
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>'; |
---|
472 | partitionTypes+='<OPTION value="HFS-BOOT"> MacOS HFS Boot </OPTION>'; |
---|
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>'; |
---|
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; |
---|
526 | // Si ya solo quedan 4 particiones, no se elimina ni se decrementa el contador |
---|
527 | if(numPart > 4){ |
---|
528 | partitionRow = document.getElementById("trPartition"+numPart); |
---|
529 | table.deleteRow(partitionRow.rowIndex); |
---|
530 | // Decrementamos el numero de particiones |
---|
531 | document.getElementById("numGPTpartitions").value = parseInt(document.getElementById("numGPTpartitions").value)-1; |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
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; |
---|
539 | for (npart=1; npart<=4; npart++) { |
---|
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"; |
---|
545 | |
---|
546 | if (partType.value == "EXTENDED") { |
---|
547 | visible=true; |
---|
548 | partType.style.fontWeight = "bold"; |
---|
549 | } |
---|
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 | } |
---|
557 | } |
---|
558 | } |
---|
559 | } |
---|
560 | if (visible) { |
---|
561 | logical.style.visibility="visible"; |
---|
562 | } else { |
---|
563 | logical.style.visibility="hidden"; |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|