summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2014-09-24 12:49:18 -0700
committerczaks <marcin@6irc.net>2014-10-07 03:27:34 +0200
commit970ff0d61911b4054cc0214de1db2deabe738cae (patch)
treeb69f2c17bd95d3a32525506b468dec246e1ccdc4 /js
parent51a74bbd73f82418370176a9bb6190fb3c1b9da4 (diff)
this is how you cache
Diffstat (limited to 'js')
-rw-r--r--js/inline.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/js/inline.js b/js/inline.js
index e93df2b6..8a2b6614 100644
--- a/js/inline.js
+++ b/js/inline.js
@@ -1,4 +1,6 @@
;(function() {
+ var cache = {}
+
var inline = function(e) {
e.preventDefault()
@@ -23,13 +25,21 @@
// XXX WTF the post hover script adds fetched threads to the DOM
selector = '#thread_' + OP + ' ' + selector
var $target = $(selector)
- add(link, $target)
+ return add(link, $target)
+ }
+
+ var url = this.pathname
+ var data = cache[url]
+ if (data) {
+ var $target = $(data).find(selector)
+ return add(link, $target)
}
- else
- $.get(this.pathname, function(data) {
- var $target = $(data).find(selector)
- add(link, $target)
- })
+
+ $.get(url, function(data) {
+ cache[url] = data
+ var $target = $(data).find(selector)
+ add(link, $target)
+ })
}
var add = function(link, $target) {