diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2011-05-06 03:19:20 -0400 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2011-05-06 03:19:20 -0400 |
commit | 9220ea44b5dd5e14f3ce3a4ae93f1b31561a93f8 (patch) | |
tree | 65a4862709f2f77694496242ce4f0371ab21b524 /web/js/010-debugger.js | |
parent | Only gc if thumbing. (diff) | |
download | PhotoFloat-9220ea44b5dd5e14f3ce3a4ae93f1b31561a93f8.tar.xz PhotoFloat-9220ea44b5dd5e14f3ce3a4ae93f1b31561a93f8.zip |
Better cache. Better gc.
Diffstat (limited to 'web/js/010-debugger.js')
-rw-r--r-- | web/js/010-debugger.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/web/js/010-debugger.js b/web/js/010-debugger.js index ecac65a..31d3db8 100644 --- a/web/js/010-debugger.js +++ b/web/js/010-debugger.js @@ -11,19 +11,25 @@ $(document).ready(function() { return "cache/" + cachePath(path + "/" + image + "_" + suffix + ".jpg"); } function loadAlbum(path) { + if (path in album_cache) { + albumLoaded(album_cache[path]); + return; + } $.ajax({ type: "GET", url: "cache/" + path + ".json", error: function() { $(document.body).html("Couldn't fetch it."); }, - success: function(album) { - current_album = album; - if (current_image_cache != null) - showPhoto(); - else - showAlbum(); - } + success: albumLoaded }); } + function albumLoaded(album) { + album_cache[cachePath(album.path)] = album; + current_album = album; + if (current_image_cache != null) + showPhoto(); + else if (cachePath(album.path) == current_album_cache) + showAlbum(); + } function showAlbum() { $("html, body").animate({ scrollTop: 0 }, "slow"); var title = ""; @@ -73,6 +79,7 @@ $(document).ready(function() { var current_album_cache = ""; var current_image_cache = ""; var current_album = null; + var album_cache = new Array(); $(window).hashchange(function() { var new_album_cache = location.hash.substring(1); var index = new_album_cache.lastIndexOf("/"); |