diff options
Diffstat (limited to 'parsemail.js')
-rw-r--r-- | parsemail.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/parsemail.js b/parsemail.js index fe75f75..e25e573 100644 --- a/parsemail.js +++ b/parsemail.js | |||
@@ -1,9 +1,37 @@ | |||
1 | window.onload=function() { | 1 | window.onload=function() { |
2 | var url = "/" + window.location.search.substring(1); | 2 | var url = "/" + window.location.search.substring(1); |
3 | var xmlHttp = null; | ||
4 | |||
5 | if (typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); } | ||
6 | if (!xmlHttp ) { | ||
7 | try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); | ||
8 | } catch(e) { | ||
9 | try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); | ||
10 | } catch(e) { xmlHttp = null; } | ||
11 | } | ||
12 | } | ||
13 | |||
14 | if (xmlHttp) { | ||
15 | xmlHttp.open('GET', url, true); | ||
16 | xmlHttp.onreadystatechange = function () { if( xmlHttp.readyState == 4 ) { handleComplete(xmlHttp); } }; | ||
17 | if( xmlHttp.overrideMimeType != null ) { | ||
18 | xmlHttp.overrideMimeType('text/plain; charset=x-user-defined'); | ||
19 | } | ||
20 | xmlHttp.send(null); | ||
21 | } | ||
3 | 22 | ||
4 | document.getElementById( "content" ).innerHTML = "<p><b>Fetching Mailbox... (this may take a while, please be patient...)</b><br/></p>"; | 23 | document.getElementById( "content" ).innerHTML = "<p><b>Fetching Mailbox... " + url + " (this may take a while, please be patient...)</b><br/></p>"; |
24 | } | ||
5 | 25 | ||
6 | new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { parsemail(transport.responseText); } }); | 26 | function handleComplete(transport) { |
27 | switch ( transport.status ) { | ||
28 | case 200: case 304: | ||
29 | parsemail(transport.responseText); | ||
30 | break; | ||
31 | default: | ||
32 | alert( "Oech" + transport.status + " " + transport.responseText ); | ||
33 | break; | ||
34 | } | ||
7 | } | 35 | } |
8 | 36 | ||
9 | var myStates = { | 37 | var myStates = { |