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) {
|
||||
var pos = url.indexOf('://');
|
||||
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
||||
var pos = url.indexOf('://');
|
||||
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
||||
|
||||
if (scheme == 'http' || scheme == 'https') {
|
||||
var req = xmlHttp();
|
||||
if (!req) {
|
||||
return;
|
||||
}
|
||||
req.open("GET", url, true);
|
||||
req.onreadystatechange = function() {
|
||||
if (req.readyState !== 4 || req.status !== 200 && req.status !== 304) {
|
||||
switch (scheme) {
|
||||
case "http":
|
||||
case "https":
|
||||
var req = xmlHttp();
|
||||
if (!req) {
|
||||
return;
|
||||
}
|
||||
callback(req.responseText);
|
||||
};
|
||||
if (req.readyState === 4) {
|
||||
return;
|
||||
}
|
||||
req.send(null);
|
||||
} else {
|
||||
responseText = FILE.readFile(url, "utf-8");
|
||||
callback(responseText);
|
||||
req.open("GET", url, true);
|
||||
req.onreadystatechange = function() {
|
||||
if (req.readyState !== 4 || req.status !== 200 && req.status !== 304) {
|
||||
return;
|
||||
}
|
||||
callback(req.responseText);
|
||||
};
|
||||
if (req.readyState === 4) {
|
||||
return;
|
||||
}
|
||||
req.send(null);
|
||||
break;
|
||||
|
||||
default:
|
||||
responseText = FILE.readFile(url, "utf-8");
|
||||
callback(responseText);
|
||||
}
|
||||
};
|
||||
respond.ajax = ajax;
|
||||
|
@ -271,4 +275,4 @@ var FILE = require('lib/file');
|
|||
} else if (w.attachEvent) {
|
||||
w.attachEvent("onresize", callMedia);
|
||||
}
|
||||
})(this);
|
||||
})(this);
|
||||
|
|
|
@ -389,16 +389,19 @@ var FILE = require('lib/file');
|
|||
|
||||
// --[ loadStyleSheet() ]-----------------------------------------------
|
||||
function loadStyleSheet(url) {
|
||||
var pos = url.indexOf('://');
|
||||
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
||||
var pos = url.indexOf('://');
|
||||
var scheme = (pos < 0) ? "" : url.substring(0, pos);
|
||||
|
||||
if (scheme == 'http' || scheme == 'https') {
|
||||
xhr.open("GET", url, false);
|
||||
xhr.send();
|
||||
return (xhr.status == 200) ? xhr.responseText : EMPTY_STRING;
|
||||
} else {
|
||||
var responseText = FILE.readFile(url, "utf-8");
|
||||
return responseText;
|
||||
switch (scheme) {
|
||||
case "http":
|
||||
case "https":
|
||||
xhr.open("GET", url, false);
|
||||
xhr.send();
|
||||
return (xhr.status == 200) ? xhr.responseText : EMPTY_STRING;
|
||||
|
||||
default:
|
||||
var responseText = FILE.readFile(url, "utf-8");
|
||||
return responseText;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -576,4 +579,4 @@ var FILE = require('lib/file');
|
|||
addEvent(win, "load", init);
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
})(this);
|
||||
|
|
Loading…
Reference in New Issue
Block a user