mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
fix
This commit is contained in:
parent
cfc883aab6
commit
d9dbdd8d74
|
@ -45,28 +45,32 @@ var FILE = require('lib/file');
|
||||||
};
|
};
|
||||||
}(),
|
}(),
|
||||||
ajax = function(url, callback) {
|
ajax = function(url, callback) {
|
||||||
var pos = url.indexOf('://');
|
var pos = url.indexOf('://');
|
||||||
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
||||||
|
|
||||||
if (scheme == 'http' || scheme == 'https') {
|
switch (scheme) {
|
||||||
var req = xmlHttp();
|
case "http":
|
||||||
if (!req) {
|
case "https":
|
||||||
return;
|
var req = xmlHttp();
|
||||||
}
|
if (!req) {
|
||||||
req.open("GET", url, true);
|
|
||||||
req.onreadystatechange = function() {
|
|
||||||
if (req.readyState !== 4 || req.status !== 200 && req.status !== 304) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callback(req.responseText);
|
req.open("GET", url, true);
|
||||||
};
|
req.onreadystatechange = function() {
|
||||||
if (req.readyState === 4) {
|
if (req.readyState !== 4 || req.status !== 200 && req.status !== 304) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req.send(null);
|
callback(req.responseText);
|
||||||
} else {
|
};
|
||||||
responseText = FILE.readFile(url, "utf-8");
|
if (req.readyState === 4) {
|
||||||
callback(responseText);
|
return;
|
||||||
|
}
|
||||||
|
req.send(null);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
responseText = FILE.readFile(url, "utf-8");
|
||||||
|
callback(responseText);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
respond.ajax = ajax;
|
respond.ajax = ajax;
|
||||||
|
@ -271,4 +275,4 @@ var FILE = require('lib/file');
|
||||||
} else if (w.attachEvent) {
|
} else if (w.attachEvent) {
|
||||||
w.attachEvent("onresize", callMedia);
|
w.attachEvent("onresize", callMedia);
|
||||||
}
|
}
|
||||||
})(this);
|
})(this);
|
||||||
|
|
|
@ -389,16 +389,19 @@ var FILE = require('lib/file');
|
||||||
|
|
||||||
// --[ loadStyleSheet() ]-----------------------------------------------
|
// --[ loadStyleSheet() ]-----------------------------------------------
|
||||||
function loadStyleSheet(url) {
|
function loadStyleSheet(url) {
|
||||||
var pos = url.indexOf('://');
|
var pos = url.indexOf('://');
|
||||||
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
||||||
|
|
||||||
if (scheme == 'http' || scheme == 'https') {
|
switch (scheme) {
|
||||||
xhr.open("GET", url, false);
|
case "http":
|
||||||
xhr.send();
|
case "https":
|
||||||
return (xhr.status == 200) ? xhr.responseText : EMPTY_STRING;
|
xhr.open("GET", url, false);
|
||||||
} else {
|
xhr.send();
|
||||||
var responseText = FILE.readFile(url, "utf-8");
|
return (xhr.status == 200) ? xhr.responseText : EMPTY_STRING;
|
||||||
return responseText;
|
|
||||||
|
default:
|
||||||
|
var responseText = FILE.readFile(url, "utf-8");
|
||||||
|
return responseText;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -576,4 +579,4 @@ var FILE = require('lib/file');
|
||||||
addEvent(win, "load", init);
|
addEvent(win, "load", init);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user