tmp/js/ratatui.js

Ir a la documentación de este archivo.
00001 // Funciones de Ratatui
00002 
00006 function $(id){
00007         return document.getElementById(id);
00008 }
00009 
00012 var Remy = {                                                    // Es una "clase estática".
00013         debugar: false,
00014         test: null,                                             // Array que contendrá las líneas del test.
00015         resultado: true,                                        // Booleano indicando si hubo fallos en la ejecución.
00016         iframeCargado: false,                                   // Índica si está cargada el iframe.
00017         esperarACargar: 0,
00018         indice: null,
00019         pararEjecucion: false,
00020 
00024         ejecutar: function (){
00025                 Remy.debug("En ejecutar");
00026                 Remy.pararEjecucion = false;
00027                 if (Remy.test == null) return;                                  // Todavía no se ha cargado.
00028                 while ((Remy.indice < Remy.test.length) && !Remy.pararEjecucion){
00029                         if (Remy.test[Remy.indice].match(/(^\s*$)|(^\/\/)/) == null){
00030                                 Remy.debug("Ejecutando "+Remy.test[Remy.indice]);
00031                                 eval("Remy."+Remy.test[Remy.indice]);
00032                         }
00033                         Remy.indice++;
00034                 }
00035         },
00039         cargarJS: function (fichero){
00040                 Remy.debug("CargandoJS("+fichero+")");
00041                 var head = document.getElementsByTagName('head')[0];
00042                 var script = document.createElement('script');
00043                 script.src = fichero;
00044                 script.type = 'text/javascript';
00045                 head.appendChild(script);
00046                 Remy.esperar();
00047         },
00051         cargar: function(URL){
00052                 Remy.debug("Cargando("+URL+")");
00053                 Remy.iframeCargado = false;
00054                 $('iframe').src = URL;
00055                 Remy.esperarCarga();
00056         },
00059         verPagina: function(){
00060                 var html = $('iframe').contentDocument.getElementsByTagName("html")[0].innerHTML;
00061                 //html = html.replace(/\"/g,'#');
00062                 //html = html.replace(/\n/g,'');
00063                 return html;
00064         },
00069         verPaginaMD5: function(){
00070                 var html = $('iframe').contentDocument.getElementsByTagName("html")[0].innerHTML;
00071                 return Remy.md5(html);
00072         },
00076         mensaje: function(mensaje){
00077                 var texto = document.createTextNode(mensaje);
00078                 var p = document.createElement("p");
00079                 p.appendChild(texto);
00080                 $('fieldsetResultados').appendChild(p);
00081         },
00087         probarIgual: function(val1, val2, mensaje){
00088                 resultado = false;
00089                 if (val1 == val2) resultado = true;
00090                 if (!resultado){
00091                         Remy.resultado = false;
00092                         mensajeResultado = " -> NOK\n("+val1+" != "+val2+")";
00093                 }
00094                 else 
00095                         mensajeResultado = " -> OK";
00096                 var texto = document.createTextNode(mensaje + mensajeResultado);
00097                 var p = document.createElement("p");
00098                 p.appendChild(texto);
00099                 $('fieldsetResultados').appendChild(p);
00100                 return resultado;
00101         },
00106         probarMD5Pagina: function(md5, mensaje){
00107                 return Remy.probarIgual(Remy.verPaginaMD5(), md5, mensaje);
00108         },
00112         md5: function(texto){
00113                 return hex_md5(texto);
00114         },
00119         esperar: function(segundos){
00120                 if (arguments.length == 0) segundos = 2;        //Tiempo de espera por defecto.
00121                 Remy.pararEjecucion = true;     //Para que no siga ejecutando y espere...
00122                 window.setTimeout('Remy.ejecutar()', segundos*1000);
00123                 /*
00124                 var petición = new XMLHttpRequest();
00125                 petición.open("POST", Remy.URL_ESPERAR_PHP, false);
00126                 petición.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
00127                 var mensaje = "&retardo="+segundos;
00128                 petición.send(mensaje);
00129                 return;
00130                 */
00131         },
00134         esperarCarga: function(){
00135                 if(!Remy.iframeCargado){
00136                         Remy.pararEjecucion = true;     //Para que no siga ejecutando y espere...
00137                         Remy.debug("Esperando la carga...");
00138                         window.setTimeout('Remy.esperarCarga()', 2*1000);
00139                 }
00140                 else{
00141                         Remy.debug("¡Cargado!");
00142                         if (Remy.indice == null){
00143                                 Remy.debug("Parseando...");
00144                                 Remy.parsear();
00145                         }
00146                         else {
00147                                 Remy.debug("Reanudando ejecución.");
00148                                 Remy.ejecutar();
00149                         }
00150                 }
00151         },
00154         parsear: function(){
00155                 var codigo = $('iframe').contentDocument.getElementsByTagName("pre")[0].firstChild.nodeValue;   //Vale, parece raro y complicado, pero ahí está el código cargado (ver DOM Inspector).
00156                 Remy.test = codigo.split("\n"); // Separamos las líneas por retornos de carro.
00157                 Remy.indice = 0;
00158                 Remy.debug("Fin del parseo");
00159                 Remy.ejecutar();
00160         },
00161         ponerValor: function(elemento, valor){
00162                 $('iframe').contentDocument.getElementById(elemento).value = valor;
00163         },
00164         debug: function(mensaje){
00165                 if (Remy.debugar) Remy.mensaje(mensaje);
00166         },
00170         pulsar: function(idBoton){
00171                 var boton = $('iframe').contentDocument.getElementById(idBoton);
00172                 if (!boton) return
00173                 else boton.click();
00174         }
00175         //No olivdes quitar la coma del último elemento de la enumeración.
00176 };
00177 
00178 //Remy.cargarJS("js/md5.js");           //Cargamos la librería para utilizar md5

Generado el Mon Jan 7 19:45:44 2008 para Rataui por  doxygen 1.5.4