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