diff options
author | emkael <emkael@tlen.pl> | 2018-11-14 23:19:23 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-11-14 23:19:23 +0100 |
commit | 3bbf39e31f766f91a12f5fb1ae80c0b5b1bdb35f (patch) | |
tree | bbb67850d1c451064ba62d0c978c6ade22ba48a8 /sklady | |
parent | 24a0c22e419c19b1a3b5538eb9d757badf92ea94 (diff) |
Grouping tables per board record, defaulting to record from the HTML file
Diffstat (limited to 'sklady')
-rw-r--r-- | sklady/tdd.js | 23 |
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 { |