From 72e5fa568ed44c0903dd845118214c9009792eae Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Tue, 10 Jun 2008 19:47:32 +0000 Subject: Now we do Ajax ourselves, no need for the expensive prototype framwork. --- parsemail.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'parsemail.js') diff --git a/parsemail.js b/parsemail.js index fe75f75..e25e573 100644 --- a/parsemail.js +++ b/parsemail.js @@ -1,9 +1,37 @@ window.onload=function() { var url = "/" + window.location.search.substring(1); + var xmlHttp = null; + + if (typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); } + if (!xmlHttp ) { + try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch(e) { + try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch(e) { xmlHttp = null; } + } + } + + if (xmlHttp) { + xmlHttp.open('GET', url, true); + xmlHttp.onreadystatechange = function () { if( xmlHttp.readyState == 4 ) { handleComplete(xmlHttp); } }; + if( xmlHttp.overrideMimeType != null ) { + xmlHttp.overrideMimeType('text/plain; charset=x-user-defined'); + } + xmlHttp.send(null); + } - document.getElementById( "content" ).innerHTML = "

Fetching Mailbox... (this may take a while, please be patient...)

"; + document.getElementById( "content" ).innerHTML = "

Fetching Mailbox... " + url + " (this may take a while, please be patient...)

"; +} - new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { parsemail(transport.responseText); } }); +function handleComplete(transport) { + switch ( transport.status ) { + case 200: case 304: + parsemail(transport.responseText); + break; + default: + alert( "Oech" + transport.status + " " + transport.responseText ); + break; + } } var myStates = { -- cgit v1.2.3