Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/ratchet.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dist/js/ratchet.js')
-rw-r--r--dist/js/ratchet.js40
1 files changed, 27 insertions, 13 deletions
diff --git a/dist/js/ratchet.js b/dist/js/ratchet.js
index 15b21d1..4efe2f1 100644
--- a/dist/js/ratchet.js
+++ b/dist/js/ratchet.js
@@ -420,6 +420,8 @@
options.container = options.container || options.transition ? document.querySelector('.content') : document.body;
+ var isFileProtocol = /^file:/.test(window.location.protocol);
+
for (key in bars) {
if (bars.hasOwnProperty(key)) {
options[key] = options[key] || document.querySelector(bars[key]);
@@ -432,21 +434,25 @@
}
xhr = new XMLHttpRequest();
- xhr.open('GET', options.url, true);
- xhr.setRequestHeader('X-PUSH', 'true');
+ if (isFileProtocol) {
+ xhr.open('GET', options.url, false);
+ } else {
+ xhr.open('GET', options.url, true);
+ xhr.setRequestHeader('X-PUSH', 'true');
- xhr.onreadystatechange = function () {
- if (options._timeout) {
- clearTimeout(options._timeout);
- }
- if (xhr.readyState === 4) {
- if (xhr.status === 200) {
- success(xhr, options);
- } else {
- failure(options.url);
+ xhr.onreadystatechange = function () {
+ if (options._timeout) {
+ clearTimeout(options._timeout);
}
- }
- };
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ success(xhr, options);
+ } else {
+ failure(options.url);
+ }
+ }
+ };
+ }
if (!PUSH.id) {
cacheReplace({
@@ -466,6 +472,14 @@
xhr.send();
+ if (isFileProtocol) {
+ if (xhr.status === 0 || xhr.status === 200) {
+ success(xhr, options);
+ } else {
+ failure(options.url);
+ }
+ }
+
if (xhr.readyState && !options.ignorePush) {
cachePush();
}