Skip to content

Commit ed60320

Browse files
committed
Fix automatic day switching in program
1 parent 454ce5d commit ed60320

3 files changed

Lines changed: 21 additions & 26 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
jekyll-theme-conference (3.7.1)
4+
jekyll-theme-conference (3.7.2)
55
jekyll (~> 4.0)
66

77
GEM

_includes/js/program.js

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,28 @@ window.conference.program = (() => {
66
};
77

88
const init = () => {
9-
if ($("#day-list")) {
10-
// Switch to day if page load with hash
11-
const hash = window.location.hash;
12-
if (hash) {
13-
$('#day-list a[href="' + hash + '"]').tab("show");
14-
}
9+
const $dayList = $('#day-list');
10+
if (!$dayList.length) return;
1511

16-
// Switch to day if today
17-
else {
18-
const now = new Date();
19-
const tsNow = Math.floor(now.getTime() / 1000);
20-
21-
$('a[data-toggle="tab"]').each(function () {
22-
const tsMidnight = new Date($(this).data("ts") * 1000);
23-
24-
if (tsMidnight <= tsNow < tsMidnight + 24 * 60 * 60) {
25-
$(this).tab("show");
26-
updateHash(this.hash);
27-
}
28-
});
29-
}
30-
31-
// Add current selected day as hash to URL while keeping current scrolling position
32-
$('a[data-toggle="tab"]').on("shown.bs.tab", function () {
33-
updateHash(this.hash);
12+
const hash = window.location.hash;
13+
if (hash) {
14+
$(`a[data-toggle="tab"][href="${hash}"]`).tab('show');
15+
} else {
16+
const tsNow = Date.now() / 1000 | 0;
17+
$('a[data-toggle="tab"]').each(function () {
18+
const tsMidnight = $(this).data("ts");
19+
if (tsMidnight && tsMidnight <= tsNow && tsNow < tsMidnight + 24 * 60 * 60) {
20+
$(this).tab('show');
21+
updateHash(this.hash);
22+
return false;
23+
}
3424
});
3525
}
26+
27+
// Add current selected day as hash to URL while keeping current scrolling position
28+
$('a[data-toggle="tab"]').on('shown.bs.tab', function () {
29+
updateHash(this.hash);
30+
});
3631
};
3732

3833
return {

jekyll-theme-conference.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gem::Specification.new do |spec|
44
spec.name = "jekyll-theme-conference"
5-
spec.version = "3.7.1"
5+
spec.version = "3.7.2"
66
spec.authors = ["Lorenz Schmid"]
77
spec.email = ["lorenzschmid@users.noreply.github.com"]
88

0 commit comments

Comments
 (0)