/////////////////////////////////////////////////////////////////////////////// // class httpRequest / Developped by Alexandre Del Bigio // (c) Alain Bensoussan Selas 2008 /////////////////////////////////////////////////////////////////////////////// function httpRequest() { } httpRequest.prototype.createRequest = function() { var xhr; try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e2) { try { xhr = new XMLHttpRequest(); } catch (e3) { xhr = false; } } } return(xhr); }; httpRequest.prototype.request = null; httpRequest.prototype.State = function( xhr, type ) { switch(xhr.readyState) { case 0: // (uninitialized) break; case 1: // (loading) this.OnLoading(); break; case 2: // (loaded) break; case 3: // (interactive) break; case 4: // (complete) if(xhr.status == 200) { if(type == "xml") { this.OnSuccess(xhr.responseXML); } else { this.OnSuccess(xhr.responseText); } } else { this.OnError(xhr.status); } break; } }; httpRequest.prototype.Wait = function(){}; httpRequest.prototype.OnSuccess = function(){}; httpRequest.prototype.OnError = function(){}; httpRequest.prototype.OnLoading = function(){}; httpRequest.prototype.getData = function( uri, type ) { var _this = this; this.request = this.createRequest(); this.Wait(); if(type == null) type = "html"; // this.request.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); // this.request.setRequestHeader("Pragma", "no-cache"); this.request.onreadystatechange = function() { _this.State(_this.request, type); }; this.request.open('GET', uri, true); this.request.send(null); }; httpRequest.prototype.postData = function( uri, params, type ) { var _this = this; this.request = this.createRequest(); this.Wait(); if(type == null) type = "html"; // this.request.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); // this.request.setRequestHeader("Pragma", "no-cache"); this.request.onreadystatechange = function() { _this.State(_this.request, type); }; this.request.open('POST', uri, true); this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); this.request.setRequestHeader("Content-length", params.length); this.request.setRequestHeader("Connection", "close"); this.request.send(params); }; /////////////////////////////////////////////////////////////////////////////// function mouseX(evt) { if(evt.pageX) return evt.pageX; if(evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); return 0; } function mouseY(evt) { if (evt.pageY) return evt.pageY; if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); return 0; } function showDefinition( e , id , mot , definition) { var hrq = new httpRequest(); var obj = document.getElementById('defs'); var posX = 0; var posY = 0; if(document.all) e = event; posX = mouseX(e); posY = mouseY(e); obj.innerHTML = '' + '' + ''+ ''+ ''+ ''+ ''+ ''+ '
'+mot+' X 
' + definition + '
'; obj.style.visibility = "visible"; obj.style.left = posX + 15 + "px"; obj.style.top = posY - 15 + "px"; obj.style.height = null; } function hideDefinition( wasClicked ) { if(wasClicked == true) { var obj = document.getElementById('defs'); obj.innerHTML = ""; obj.style.visibility = "hidden"; obj.style.height = 20; } else { // OnMouseOut = nothing } }