Browse Source

Cache dom before leaving the page, rather than right after loding

This way dynamically added dom (vis js) also gets cached.
pull/564/head
artemave 11 years ago
parent
commit
1378886fe0
  1. 9
      js/push.js

9
js/push.js

@ -42,7 +42,6 @@
}
cacheMapping[data.id] = JSON.stringify(data);
window.history.replaceState(data.id, data.title, data.url);
domCache[data.id] = document.body.cloneNode(true);
};
var cachePush = function () {
@ -60,7 +59,7 @@
delete cacheMapping[cacheBackStack.shift()];
}
window.history.pushState(null, '', cacheMapping[PUSH.id].url);
window.history.pushState(null, '', getCached(PUSH.id).url);
cacheMapping.cacheForwardStack = JSON.stringify(cacheForwardStack);
cacheMapping.cacheBackStack = JSON.stringify(cacheBackStack);
@ -243,6 +242,8 @@
});
}
cacheCurrentContent();
if (options.timeout) {
options._timeout = setTimeout(function () { xhr.abort('timeout'); }, options.timeout);
}
@ -254,6 +255,10 @@
}
};
function cacheCurrentContent() {
domCache[PUSH.id] = document.body.cloneNode(true);
}
// Main XHR handlers
// =================

Loading…
Cancel
Save