summaryrefslogtreecommitdiff
path: root/itjs/loader.js
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2007-08-28 20:46:27 +0000
committerThomas BrĂ¼derli2007-08-28 20:46:27 +0000
commit52ead6bc0391e0c85cdba31e83cd38e661a514c6 (patch)
tree7e3d6b4069699987a2c771585a25f1d9235b0906 /itjs/loader.js
parent3f1a528fd4d9539f130e4c00291b4365b406548b (diff)
downloaditools-52ead6bc0391e0c85cdba31e83cd38e661a514c6.tar.gz
itools-52ead6bc0391e0c85cdba31e83cd38e661a514c6.tar.bz2
itools-52ead6bc0391e0c85cdba31e83cd38e661a514c6.zip
Better separation (if/else) of XMLHTTP usage
Diffstat (limited to 'itjs/loader.js')
-rw-r--r--itjs/loader.js53
1 files changed, 28 insertions, 25 deletions
diff --git a/itjs/loader.js b/itjs/loader.js
index 324661a..0208d5a 100644
--- a/itjs/loader.js
+++ b/itjs/loader.js
@@ -65,42 +65,44 @@ load: function(baseurl, pos, num, query_volatile, retry)
if (num > 0)
{
+ this.loader = null;
+
if (retry)
baseurl += "&retry=" + retry;
- try
+ // use XMLHTTP request if available
+ if (baseurl.indexOf('http://') < 0 || baseurl.indexOf(window.location.hostname) > 0)
{
- if (!(baseurl.indexOf('http://') == 0 && baseurl.indexOf(window.location.hostname) < 0))
+ try
+ {
this.loader = new XMLHttpRequest();
- }
- catch (e)
- {
- var classnames = [ 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP' ];
-
- for (var i in classnames)
+ }
+ catch (e)
{
- try
+ var classnames = [ 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP' ];
+
+ for (var i in classnames)
{
- this.loader = new ActiveXObject(classnames[i]);
- break;
+ try
+ {
+ this.loader = new ActiveXObject(classnames[i]);
+ break;
+ }
+ catch (e) { }
}
- catch (e) {}
}
- }
- try
- {
- this.loader.open(this.method, baseurl + "&pos=" + pos + "&num=" + num + (query_volatile ? query_volatile : ""));
- var me = this;
- this.loader.onreadystatechange = function() { me.readyStateChanged(); }
- var workingxmlhttp = this.loader.onreadystatechange;
+ try
+ {
+ this.loader.open(this.method, baseurl + "&pos=" + pos + "&num=" + num + (query_volatile ? query_volatile : ""));
+ var me = this;
+ this.loader.onreadystatechange = function() { me.readyStateChanged(); }
+ var workingxmlhttp = this.loader.onreadystatechange;
- if (!workingxmlhttp) /* Old Konqueror */
- this.loader = null;
- }
- catch (e)
- {
- this.loader = null;
+ if (!workingxmlhttp) /* Old Konqueror */
+ this.loader = null;
+ }
+ catch (e) { }
}
if (this.loader)
@@ -115,6 +117,7 @@ load: function(baseurl, pos, num, query_volatile, retry)
else
{
var req_url = baseurl + "&pos=" + pos + "&num=" + num + (query_volatile ? query_volatile : "") + (this.post_data ? '&' + this.post_data : "") + "&itjs_call=it_loader.__inst" + this.instance + ".dataReady&itjs_callid=" + ++this.callid;
+
if (window.opera && !window.XMLHttpRequest) // Opera 7 only works with iframes
{
this.scrpt = document.createElement("iframe");