From 3bbf39e31f766f91a12f5fb1ae80c0b5b1bdb35f Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 14 Nov 2018 23:19:23 +0100 Subject: Grouping tables per board record, defaulting to record from the HTML file --- sklady/tdd.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'sklady/tdd.js') 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 { -- cgit v1.2.3