00001
00002
00006 function $(id){
00007 return document.getElementById(id);
00008 }
00009
00012 var Remy = {
00013 debugar: false,
00014 test: null,
00015 resultado: true,
00016 iframeCargado: false,
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;
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
00062
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;
00121 Remy.pararEjecucion = true;
00122 window.setTimeout('Remy.ejecutar()', segundos*1000);
00123
00124
00125
00126
00127
00128
00129
00130
00131 },
00134 esperarCarga: function(){
00135 if(!Remy.iframeCargado){
00136 Remy.pararEjecucion = true;
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;
00156 Remy.test = codigo.split("\n");
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
00176 };
00177
00178