Browse Source

push.js: add file:// urls support

Fix for Android

Android was not working because the status is set to 200, not 0.
pull/750/head
artemave 11 years ago committed by Elliot Bradbury
parent
commit
1e021bc5e0
  1. 14
      js/push.js

14
js/push.js

@ -213,6 +213,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]);
@ -225,6 +227,9 @@
}
xhr = new XMLHttpRequest();
if (isFileProtocol) {
xhr.open('GET', options.url, false);
} else {
xhr.open('GET', options.url, true);
xhr.setRequestHeader('X-PUSH', 'true');
@ -240,6 +245,7 @@
}
}
};
}
if (!PUSH.id) {
cacheReplace({
@ -259,6 +265,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();
}

Loading…
Cancel
Save