Skip to content

Instantly share code, notes, and snippets.

@joeauty
Created June 11, 2011 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeauty/1020388 to your computer and use it in GitHub Desktop.
Save joeauty/1020388 to your computer and use it in GitHub Desktop.
var webkitcache = $H();
this.cacheset = function(owner, datarequest, object) {
// assigns object to webkitcache global hash
if ($(object)) {
// part of DOM, create clone
webkitcache.set(owner + '_' + datarequest, object.cloneNode(true));
}
else {
webkitcache.set(owner + '_' + datarequest, object );
}
}
this.cacheget = function(owner, datarequest) {
// checks to see if cache for datarequest exists
if (webkitcache.get(owner + '_' + datarequest)) {
return true;
}
return false;
}
this.cacheoutput = function(owner, datarequest, object) {
if ($(object)) {
// replace entire object with cached object
$(object).replace(webkitcache.get(owner + '_' + datarequest).cloneNode(true));
}
else {
// updating using cache contents
$(object).update(webkitcache.get(owner + '_' + datarequest));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment