From 42bfe425902e027301a9f2a14598815c1db38dd7 Mon Sep 17 00:00:00 2001
From: Kevin Abel <kevin.abel.0@gmail.com>
Date: Mon, 21 Apr 2014 14:37:40 -0500
Subject: [PATCH] Allow a cancelled directoy request to abort the pending XHR

---
 www/js/search.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/www/js/search.js b/www/js/search.js
index 7df9172..a117172 100644
--- a/www/js/search.js
+++ b/www/js/search.js
@@ -82,6 +82,9 @@
 			};
 			Directory.prototype.cancelSearch = function() {
 				this._searchCanceled = true;
+				if (this._xhr) {
+					this._xhr.abort();
+				}
 			};
 			Directory.prototype.execute = function(q) {
 				var cacheData = this._cache.get(q),
@@ -92,7 +95,7 @@
 				if (cacheData) {
 					this._render(cacheData);
 				} else {
-					$.get(this._server + '/service.php?q=' + encodeURIComponent(q), function(data) {
+					this._xhr = $.get(this._server + '/service.php?q=' + encodeURIComponent(q), function(data) {
 						self._cache.save(q, data);
 						self._render(data);
 					});
-- 
GitLab