From f93dd965b3629ebb8eaa728e5e5ff2711487b2cf Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sun, 24 Sep 2023 21:02:20 -0400 Subject: highlight talks based on URL --- templates/page.tmpl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'templates/page.tmpl') diff --git a/templates/page.tmpl b/templates/page.tmpl index b3600e2c..ba832af6 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -314,7 +314,7 @@ Last edited var localStart = (new Date(o.getAttribute('start'))).toLocaleString([], dateOptions); var localEnd = (new Date(o.getAttribute('end'))).toLocaleString([], dateOptions); o.setAttribute('title', 'Your local time: ~ ' + localStart + ' to ~ ' + localEnd); - } + }); } if (document.querySelector('a[name=transcript]')) { @@ -419,6 +419,25 @@ if (video) { } // @license-end + // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0 + // Copyright (c) 2023 Sacha Chua - CC0 Public Domain + function highlightTalks() { + // highlight any talk mentioned in the highlight URL parameter + var params = new URLSearchParams(window.location.search); + if (!params.get('highlight')) return; + var talks = params.get('highlight').split(',').filter(function(o) { return o.match(/^[-a-z0-9]+$/); }); + var regexp = new RegExp('/talks/(' + talks.join('|') + ')/?$'); + document.querySelectorAll('a[href]').forEach(function(link) { + console.debug(link.getAttribute('href'), link.getAttribute('href').match(regexp)); + if (link.getAttribute('href').match(regexp)) { + console.debug(link); + link.classList.add('highlight'); + } + }); + } + + addEventListener('DOMContentLoaded', highlightTalks); + // @license-end -- cgit v1.2.3