summaryrefslogtreecommitdiff
path: root/sklady/tdd.js
diff options
context:
space:
mode:
Diffstat (limited to 'sklady/tdd.js')
-rw-r--r--sklady/tdd.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/sklady/tdd.js b/sklady/tdd.js
index 70a8424..4c3350c 100644
--- a/sklady/tdd.js
+++ b/sklady/tdd.js
@@ -51,12 +51,33 @@ var TDD = {
return undefined;
},
+ detectTable: function(hash) {
+ var regex = hash.match(/^#table-(\d+)$/);
+ if (regex) {
+ if (regex[1] === '0') {
+ return $(hash);
+ }
+ var links = $('a.b');
+ for (var link in links) {
+ link = $(links[link]);
+ var linkText = link.text().trim();
+ if (linkText === regex[1]) {
+ return link.closest('tr').prevAll('.' + TDD.rowHeaderClass + ':first').find('h4[id]');
+ }
+ }
+ }
+ return [];
+ },
+
bindEvents: function() {
$('tr').hover(TDD.hoverTable, TDD.unhoverTable);
$('tr').click(TDD.switchTable);
$(window).on('hashchange', function() {
- var table = $(location.hash);
+ var table = TDD.detectTable(location.hash);
if (table.length) {
+ if (location.hash != '#' + $(table).attr('id')) {
+ location.hash = '#' + $(table).attr('id');
+ }
$('.specified').removeClass('specified');
TDD.highlightTable(table);
} else {