[3ec149c] | 1 | // ************************************************************************************************************************************************* |
---|
| 2 | // Libreria de scripts de Javascript |
---|
| 3 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
---|
| 4 | // Fecha Creación: 2009-2010 |
---|
| 5 | // Fecha Última modificación: Agosto-2010 |
---|
| 6 | // Nombre del fichero: Configurar.js |
---|
| 7 | // Descripción : |
---|
| 8 | // Este fichero implementa las funciones javascript del fichero Configurar.php (Comandos) |
---|
| 9 | // ************************************************************************************************************************************************* |
---|
| 10 | |
---|
[bbd5b61] | 11 | var atributos=""; // Variable global |
---|
| 12 | var swc=false; // Switch para detectar cache |
---|
| 13 | var swe=false; // Switch para detectar partición extendida |
---|
[3ec149c] | 14 | |
---|
| 15 | //________________________________________________________________________________________________________ |
---|
| 16 | // |
---|
| 17 | // Elimina una fila de una tabla de configuraciones perteneciente a las propiedades de una partición |
---|
[215cd24] | 18 | // Parámetros: |
---|
[3ec149c] | 19 | // icp: Identificador de la configuración-partición |
---|
| 20 | // o: Objeto checkbox que invoca la función |
---|
| 21 | //________________________________________________________________________________________________________ |
---|
| 22 | |
---|
[bbd5b61] | 23 | function eliminaParticion(o,icp) |
---|
[3ec149c] | 24 | { |
---|
| 25 | var res=confirm(TbMsg[4]); // Pide confirmación |
---|
| 26 | if(!res){ |
---|
| 27 | o.checked=false; |
---|
| 28 | return; |
---|
| 29 | } |
---|
[bbd5b61] | 30 | |
---|
| 31 | // Toma desplegable de tipo de partición |
---|
| 32 | var desplepar=o.parentNode.nextSibling.nextSibling.childNodes[0]; |
---|
| 33 | var tipar=tomavalorDesple(desplepar); // Partición |
---|
[215cd24] | 34 | if(tipar==="CACHE") swc=false; // Si es la caché se pone a false su switch |
---|
| 35 | if(tipar==="EXTENDED") swe=false; // Si es la EXTENDED se pone a false su switch |
---|
[bbd5b61] | 36 | |
---|
[3ec149c] | 37 | var tbCfg = document.getElementById("tabla_conf"); // Recupera objeto <TABLE> |
---|
| 38 | var trCfg = document.getElementById("TR_"+icp); // Recupera <TR> de la fila a eliminar |
---|
| 39 | var tbodyObj=tbCfg.firstChild; // Recupera hijo <TBODY> del objeto <TABLE> |
---|
| 40 | tbodyObj.removeChild(trCfg); // Elimina nodo <TR> completo |
---|
| 41 | } |
---|
| 42 | //________________________________________________________________________________________________________ |
---|
| 43 | |
---|
| 44 | function addParticion(objImg,cc) |
---|
| 45 | { |
---|
| 46 | var tbCfg = document.getElementById("tabla_conf"); // Recupera objeto <TABLE> |
---|
| 47 | var tbodyObj=tbCfg.firstChild; // Recupera hijo <TBODY> del objeto <TABLE> |
---|
| 48 | |
---|
| 49 | var trImg=document.getElementById("TRIMG_"+cc); // Recupera <TR> de los botones para insertar antes |
---|
| 50 | |
---|
| 51 | var k=objImg.getAttribute('value'); // Toma siguiente identificador de nodo |
---|
| 52 | var icp=cc+"_"+k; // Identificador de la configuración-partición |
---|
| 53 | |
---|
| 54 | /* Crea objeto TR y lo añade al TBODY de la tabla*/ |
---|
| 55 | var nwTR = document.createElement('TR'); |
---|
| 56 | nwTR.setAttribute("id","TR_"+icp); |
---|
| 57 | tbodyObj.insertBefore(nwTR,trImg); // Inserta nodo <TR> completo |
---|
| 58 | var patron = document.getElementById("TR_patron"); // Recupera <TR> patron |
---|
| 59 | nwTR.innerHTML=patron.innerHTML; |
---|
| 60 | /* Actualiza objeto checkbox nuevo para que actue como los demás */ |
---|
| 61 | var nwCHK = document.getElementById("CHK_patron"); // Recupera reciente chekcbox |
---|
[bbd5b61] | 62 | var fclbk="eliminaParticion(this,'"+icp+"');"; |
---|
[3ec149c] | 63 | nwCHK.setAttribute("onclick",fclbk); |
---|
| 64 | nwCHK.removeAttribute("id"); |
---|
| 65 | /* Incrementa para siguiente identificador de nodo */ |
---|
| 66 | k++; |
---|
| 67 | objImg.setAttribute('value',k); |
---|
| 68 | } |
---|
| 69 | //________________________________________________________________________________________________________ |
---|
| 70 | // |
---|
| 71 | // Confirma un bloque de configuración de particiones |
---|
[215cd24] | 72 | // Parámetros: |
---|
[3ec149c] | 73 | // idordenadores: Identificadores de los ordenadores a los que se aplicará el comando |
---|
| 74 | // cc: Identificador de la configuración (bloque de particiones) |
---|
| 75 | // Especificaciones: |
---|
| 76 | // Cuando un comando se va a aplicar a un conjunto aleatorio de ordenaores, el código del |
---|
| 77 | // ámbito será cero y la variable idambito contendrá la cadena con los identificadores de |
---|
| 78 | // los oordenadores separados por coma (este dato aparece en esta función como promer parámetro) |
---|
| 79 | //________________________________________________________________________________________________________ |
---|
| 80 | |
---|
| 81 | function Confirmar(cc) |
---|
| 82 | { |
---|
| 83 | if(comprobarDatos(cc)){ |
---|
[a1d39fe] | 84 | if(document.fdatosejecucion.ambito.value!=AMBITO_ORDENADORES){ |
---|
[3ec149c] | 85 | var tbOrd= document.getElementById("tbOrd_"+cc); // Recupera tabla de ordenadores de la configuración |
---|
| 86 | var idordenadores=tbOrd.getAttribute('value'); // Toma identificadores de los ordenadores |
---|
| 87 | var cadenaid=document.fdatos.cadenaid.value; // Cadena de identificadores de todos los ordenadores del ámbito |
---|
[215cd24] | 88 | if(idordenadores!==cadenaid){ // Si no son iguales es que el ámbito de aplicación es restringido |
---|
[3ec149c] | 89 | document.fdatosejecucion.ambito.value=0; // Ambito de aplicación restringido |
---|
| 90 | document.fdatosejecucion.idambito.value=idordenadores; |
---|
| 91 | } |
---|
| 92 | } |
---|
[69650cb] | 93 | document.fdatosejecucion.atributos.value=atributos; |
---|
[bbd5b61] | 94 | //alert(atributos) |
---|
[df8abeb] | 95 | //filtrado(); |
---|
[3ec149c] | 96 | document.fdatosejecucion.submit(); |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | //________________________________________________________________________________________________________ |
---|
| 100 | // |
---|
| 101 | // Confirma un bloque de configuración de particiones |
---|
| 102 | // Parametros: |
---|
| 103 | // cc: Identificador de la configuración (bloque de particiones) |
---|
[1a2fa9d8] | 104 | // Version 1.1: 2015-02-25. Irina Gomez ETSII US. Se envian datos de cuarta particion. |
---|
[3ec149c] | 105 | //________________________________________________________________________________________________________ |
---|
| 106 | |
---|
| 107 | function comprobarDatos(cc) |
---|
| 108 | { |
---|
| 109 | // Indices de campos a recuperar |
---|
| 110 | var ipar=1; |
---|
| 111 | var icodpar=2; |
---|
| 112 | var isysfi=3; |
---|
| 113 | var itama=4; |
---|
| 114 | var iope=6; |
---|
| 115 | |
---|
[bbd5b61] | 116 | var SL="%"; |
---|
| 117 | var TB="*"; |
---|
| 118 | var maxpar=0; |
---|
[e32794a] | 119 | var tbpar=[]; // Para control de particiones duplicadas |
---|
| 120 | var tbparam=[]; // Para control de configuración |
---|
[bbd5b61] | 121 | var npar; // Partición en formato integer |
---|
| 122 | var tch=0; // Tamaño de la caché |
---|
| 123 | |
---|
[c822b41] | 124 | var allpartsize=0; // Tamaño total de todas las particiones. |
---|
| 125 | var extsize=0; // Tamaño partición "EXTENDED" |
---|
| 126 | var allextsize=0; // Tamaño total de las particiones extendidas. |
---|
| 127 | |
---|
[0c15976] | 128 | var hdsize = document.getElementById("hdsize"+cc).value; |
---|
[c822b41] | 129 | |
---|
[3ec149c] | 130 | var trCfg = document.getElementById("TR_"+cc); // Recupera primer <TR> de la configuración |
---|
| 131 | trCfg=trCfg.nextSibling; // Primera fila de particiones |
---|
[215cd24] | 132 | while(trCfg.id!=="TRIMG_"+cc){ |
---|
[bbd5b61] | 133 | |
---|
| 134 | var tama=trCfg.childNodes[itama].childNodes[0].value; // Tamaño de partición |
---|
| 135 | |
---|
[d5b9f89] | 136 | // Comprobar tamaño negativo. |
---|
| 137 | if (tama < 0) { |
---|
| 138 | alert(TbMsg[8]); |
---|
| 139 | trCfg.childNodes[ipar].childNodes[0].focus(); |
---|
| 140 | return(false); |
---|
| 141 | } |
---|
[c822b41] | 142 | |
---|
[3ec149c] | 143 | var par=tomavalorDesple(trCfg.childNodes[ipar].childNodes[0]); // Partición |
---|
[bbd5b61] | 144 | npar=parseInt(par); |
---|
| 145 | if(maxpar<npar) maxpar=npar; // Guarda partición de mayor orden |
---|
[c822b41] | 146 | |
---|
[215cd24] | 147 | if (npar===4){ |
---|
[bbd5b61] | 148 | swc=true; // Se especifica partición caché |
---|
| 149 | tch=tama; |
---|
| 150 | } |
---|
| 151 | |
---|
[215cd24] | 152 | if(npar===0){ |
---|
[3ec149c] | 153 | alert(TbMsg[1]); |
---|
| 154 | trCfg.childNodes[ipar].childNodes[0].focus(); |
---|
| 155 | return(false); |
---|
| 156 | } |
---|
[bbd5b61] | 157 | |
---|
[215cd24] | 158 | if(tbpar[npar]===1){ // Existe ya una partición con ese número |
---|
[3ec149c] | 159 | alert(TbMsg[0]); |
---|
| 160 | trCfg.childNodes[ipar].childNodes[0].focus(); |
---|
| 161 | return(false); |
---|
| 162 | } |
---|
[bbd5b61] | 163 | |
---|
| 164 | tbpar[npar]=1; |
---|
[3ec149c] | 165 | var codpar=tomavalorDesple(trCfg.childNodes[icodpar].childNodes[0]); // Tipo de partición |
---|
[215cd24] | 166 | if(codpar===""){ |
---|
[3ec149c] | 167 | alert(TbMsg[2]); |
---|
| 168 | trCfg.childNodes[icodpar].childNodes[0].focus(); |
---|
| 169 | return(false); |
---|
| 170 | } |
---|
| 171 | |
---|
[215cd24] | 172 | if(codpar==="EXTENDED") { |
---|
[c822b41] | 173 | swe=true; |
---|
| 174 | extsize=tama; |
---|
| 175 | } else { |
---|
| 176 | if (npar<=4){ |
---|
| 177 | allpartsize+=parseInt(tama); |
---|
| 178 | } else { |
---|
| 179 | allextsize+=parseInt(tama); |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | |
---|
[215cd24] | 183 | if(codpar==="CACHE" && npar!==4){ |
---|
[bbd5b61] | 184 | alert(TbMsg[6]); |
---|
| 185 | trCfg.childNodes[icodpar].childNodes[0].focus(); |
---|
| 186 | return(false); |
---|
| 187 | } |
---|
| 188 | |
---|
[121946b] | 189 | var ope=tomavalorCheck(trCfg.childNodes[iope].childNodes[0]); // Formatar a realizar |
---|
[bbd5b61] | 190 | |
---|
[3ec149c] | 191 | var sysfi=tomatextDesple(trCfg.childNodes[isysfi].childNodes[0]); // Sistema de ficheros |
---|
[215cd24] | 192 | if(sysfi==="" || sysfi==="EMPTY" ){ // Si el sistema de fichero es vacio o empty... |
---|
| 193 | if(ope===1){ // Si se quiere formatear... |
---|
[bbd5b61] | 194 | alert(TbMsg[5]); |
---|
| 195 | trCfg.childNodes[isysfi].childNodes[0].focus(); |
---|
| 196 | return(false); |
---|
| 197 | } |
---|
| 198 | else |
---|
| 199 | sysfi="EMPTY"; |
---|
| 200 | } |
---|
| 201 | |
---|
[215cd24] | 202 | if(tama===0 && codpar!=="EXTENDED") { |
---|
[3ec149c] | 203 | alert(TbMsg[3]); |
---|
| 204 | trCfg.childNodes[itama].childNodes[0].focus(); |
---|
| 205 | return(false); |
---|
| 206 | } |
---|
[bbd5b61] | 207 | |
---|
| 208 | trCfg=trCfg.nextSibling; // Siguiente fila de particiones |
---|
[3ec149c] | 209 | /* Compone formato del comando */ |
---|
[bbd5b61] | 210 | tbparam[npar]="par="+par+TB+"cpt="+codpar+TB+"sfi="+sysfi+TB+"tam="+tama+TB+"ope="+ope+SL; |
---|
| 211 | |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | //Controles finales de los paramtros a enviar |
---|
| 215 | |
---|
| 216 | if(!swe){ // Si no se han especificado particiones extendidas ... |
---|
| 217 | if(maxpar>4){ // La partición de mayor orden supera el número 4 |
---|
| 218 | alert(TbMsg[7]); |
---|
| 219 | return(false); |
---|
| 220 | } |
---|
| 221 | } |
---|
| 222 | |
---|
[c822b41] | 223 | // Alerta si las particiones lógicas son mayores que la extendida |
---|
| 224 | if(swe){ |
---|
| 225 | if (allextsize>extsize) { |
---|
| 226 | alert(TbMsg["EXTSIZE"]); |
---|
| 227 | return(false); |
---|
| 228 | } |
---|
[215cd24] | 229 | allpartsize+=extsize; |
---|
[c822b41] | 230 | } |
---|
| 231 | // Alerta si tamaño del disco menor que las particiones |
---|
| 232 | if (hdsize<allpartsize) { |
---|
| 233 | alert(TbMsg["HDSIZE"]); |
---|
| 234 | return(false); |
---|
| 235 | } |
---|
| 236 | |
---|
[bbd5b61] | 237 | /* Compone cadena de particiones (Deja fuera la cache, |
---|
| 238 | si se especificó) ya que va en parametro aparte |
---|
| 239 | */ |
---|
| 240 | |
---|
| 241 | var RC="!"; |
---|
[4c4ea595] | 242 | var disco = document.disk.current_numdisk.value; |
---|
[5d05b06] | 243 | var table_type = document.getElementById("table_type").value; |
---|
[bbd5b61] | 244 | |
---|
[5d05b06] | 245 | atributos="ttp="+table_type+"@"+"dsk="+disco+"@"+"cfg="; // Inicializa variable global de parámetros del comando |
---|
[bbd5b61] | 246 | |
---|
| 247 | |
---|
| 248 | if(swc){ |
---|
| 249 | atributos+="dis="+disco+TB+"che=1"+TB+"tch="+tch+RC; // Caché con su tamaño |
---|
| 250 | } |
---|
| 251 | else{ |
---|
| 252 | atributos+="dis="+disco+TB+"che=0"+TB+"tch=0"+RC; // No se especifica caché |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | for(var i=1;i<=maxpar;i++){ |
---|
[1a2fa9d8] | 256 | // Version 1.1: Se envian datos cuarta particion. |
---|
| 257 | //if(i!=4){ |
---|
[bbd5b61] | 258 | if(tbparam[i]!=undefined) |
---|
| 259 | atributos+=tbparam[i]; |
---|
| 260 | else |
---|
| 261 | atributos+="par="+i+TB+"cpt=EMPTY"+TB+"sfi=EMPTY"+TB+"tam=0"+TB+"ope=0"+SL; |
---|
[1a2fa9d8] | 262 | //} |
---|
[bbd5b61] | 263 | } |
---|
| 264 | |
---|
| 265 | // Completa con EMPTY si las particiones son menores a 4 y no hay cache |
---|
| 266 | if(maxpar<4){ |
---|
| 267 | var up=4; |
---|
| 268 | if(swc) up=3; |
---|
[e32794a] | 269 | for(i=maxpar+1;i<=up;i++) |
---|
[bbd5b61] | 270 | atributos+="par="+i+TB+"cpt=EMPTY"+TB+"sfi=EMPTY"+TB+"tam=0"+TB+"ope=0"+SL; |
---|
| 271 | } |
---|
| 272 | |
---|
[3ec149c] | 273 | return(true); |
---|
| 274 | } |
---|
| 275 | //________________________________________________________________________________________________________ |
---|
| 276 | // |
---|
| 277 | // Devuelve el valor seleccionado de un desplegable cualquiera |
---|
| 278 | //________________________________________________________________________________________________________ |
---|
| 279 | |
---|
| 280 | function tomavalorDesple(desplegable) |
---|
| 281 | { |
---|
| 282 | var idx=desplegable.selectedIndex; // Indice seleccionado en el desplegable |
---|
| 283 | var val=desplegable.options[idx].value; // Valor seleccionado en el desplegable |
---|
| 284 | return(val); |
---|
| 285 | } |
---|
[121946b] | 286 | |
---|
| 287 | function tomavalorCheck(chk) |
---|
| 288 | { |
---|
| 289 | if(chk.checked) // Valor seleccionado en el desplegable |
---|
| 290 | return(1); |
---|
| 291 | return(0); |
---|
| 292 | } |
---|
[3ec149c] | 293 | //________________________________________________________________________________________________________ |
---|
| 294 | // |
---|
| 295 | // Devuelve el valor seleccionado de un desplegable cualquiera |
---|
| 296 | //________________________________________________________________________________________________________ |
---|
| 297 | |
---|
| 298 | function tomatextDesple(desplegable) |
---|
| 299 | { |
---|
| 300 | var idx=desplegable.selectedIndex; // Indice seleccionado en el desplegable |
---|
| 301 | var txt=desplegable.options[idx].text; // Valor seleccionado en el desplegable |
---|
| 302 | return(txt); |
---|
| 303 | } |
---|
| 304 | |
---|