Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

removed old app-cache in favor of the new one which always works

  • Loading branch information...
commit 80ade1e1375612a1c532f406c247dfbec1f639f7 1 parent 757c049
AJ ONeal authored

Showing 1 changed file with 0 additions and 95 deletions. Show diff stats Hide diff stats

  1. +0 95 online-status/amionline-app-cache.js
95 online-status/amionline-app-cache.js
... ... @@ -1,95 +0,0 @@
1   -(function () {
2   - "use strict";
3   -
4   - //
5   - // App Cache Status
6   - //
7   - // This strategy is great if you're using a cache manifest
8   - //
9   - // The cache manifest should contain the *relative* paths
10   - // FALLBACK:
11   - // ./online.json ./offline.json
12   - //
13   - // `online.json` must contain {"status": "online"}
14   - // `offline.json` must contain {"status": "offline"}
15   - // if online, online.json is retrieved
16   - // if offline, offline.json is retreived from the cache
17   - function create(cb, options) {
18   - options = options || {};
19   -
20   - var isChecking = false
21   - , waitfor = options.timeout || 2000;
22   -
23   - function respond(status, err) {
24   - isChecking = false;
25   - cb(status, err);
26   - }
27   -
28   - function request() {
29   - var xhr = new XMLHttpRequest()
30   - , result = 'error'
31   - , timeoutid = -1;
32   -
33   - function handleStateChange() {
34   - var data, msg;
35   -
36   - if (xhr.readyState !== 4) {
37   - return;
38   - }
39   -
40   - clearTimeout(timeoutid);
41   -
42   - if(200 !== xhr.status) {
43   - msg = " ";
44   - if (0 === xhr.status) {
45   - msg += "(offline.json was not found or the server could not contacted and the application cache is misconfigured)";
46   - }
47   - if (404 === xhr.status) {
48   - msg += "(online.json was not found)";
49   - }
50   - respond('error', new Error("HTTP Status should be 200, but was " + xhr.status + msg));
51   - return;
52   - }
53   -
54   - try {
55   - data = JSON.parse(xhr.responseText);
56   - } catch(e) {
57   - respond('error', e);
58   - return;
59   - }
60   -
61   - if ('online' === data.status) {
62   - respond(data.status);
63   - } else if ('offline' === data.status) {
64   - respond(data.status);
65   - } else {
66   - respond('error', new Error("status neither 'offline' nor 'online'"));
67   - }
68   - }
69   -
70   - function assumeError() {
71   - xhr.abort();
72   - respond('error', new Error("timeout after " + waitfor + "ms"));
73   - }
74   -
75   - timeoutid = setTimeout(assumeError, waitfor);
76   -
77   - xhr.open("GET", "online.json?_invalidate_cache_=" + new Date().valueOf(), true);
78   - xhr.onreadystatechange = handleStateChange;
79   - xhr.send();
80   - }
81   -
82   - function check() {
83   - if (true === isChecking) {
84   - return;
85   - }
86   - isChecking = true;
87   - request();
88   - }
89   -
90   - return check;
91   - }
92   -
93   - exports.create = create;
94   - provide('amionline-app-cache', exports);
95   -}());

0 comments on commit 80ade1e

Please sign in to comment.
Something went wrong with that request. Please try again.