about summary refs log tree commit diff stats
path: root/read.html
diff options
context:
space:
mode:
authorAndrew Dolgov <noreply@fakecake.org>2018-06-29 15:07:39 +0300
committerAndrew Dolgov <noreply@fakecake.org>2018-06-29 15:07:39 +0300
commit27dfbb1f00bfe018311b92d709ce0b9eae9774cd (patch)
tree98a76b901225e94f167ecd1c2d00fbbf967891af /read.html
parent49cf8bbd4d7e2a7e98777a271f04c2268e146e95 (diff)
downloadthe-epube-27dfbb1f00bfe018311b92d709ce0b9eae9774cd.tar.gz
the-epube-27dfbb1f00bfe018311b92d709ce0b9eae9774cd.tar.xz
minor location check on rendered
Diffstat (limited to 'read.html')
-rw-r--r--read.html51
1 files changed, 27 insertions, 24 deletions
diff --git a/read.html b/read.html
index f606235..8c81f42 100644
--- a/read.html
+++ b/read.html
@@ -791,40 +791,43 @@
 			$(".chapter").html("");
 
 			try {
+				var location = book.rendition.currentLocation();
 
-				var cur_href = book.canonical(book.rendition.currentLocation().start.href);
-				var toc_entry = false;
+				if (location.start) {
+					var cur_href = book.canonical(location.start.href);
+					var toc_entry = false;
 
-				function iterate_sublist(row, nest) {
-					if (nest == 3) return false;
+					function iterate_sublist(row, nest) {
+						if (nest == 3) return false;
 
-					if (row.subitems) {
-						$.each(row.subitems, function (i, r) {
+						if (row.subitems) {
+							$.each(row.subitems, function (i, r) {
 
-							if (book.spine.get(r.href).canonical == cur_href) {
-								toc_entry = r;
-								return true;
-							}
-
-							if (iterate_sublist(r, nest + 1))
-								return true;
-						});
-					}
+								if (book.spine.get(r.href).canonical == cur_href) {
+									toc_entry = r;
+									return true;
+								}
 
-					return false;
-				}
+								if (iterate_sublist(r, nest + 1))
+									return true;
+							});
+						}
 
-				$.each(book.navigation.toc, function(i, a) {
-					if (book.spine.get(a.href).canonical == cur_href) {
-						toc_entry = a;
-						return;
+						return false;
 					}
 
-					if (iterate_sublist(a, 0)) return;
+					$.each(book.navigation.toc, function(i, a) {
+						if (book.spine.get(a.href).canonical == cur_href) {
+							toc_entry = a;
+							return;
+						}
 
-				});
+						if (iterate_sublist(a, 0)) return;
 
-				if (toc_entry) $(".chapter").html(toc_entry.label);
+					});
+
+					if (toc_entry) $(".chapter").html(toc_entry.label);
+				}
 
 			} catch (e) {
 				console.warn(e);