Skip to content

Add BERG hyperlink and tooltip#512

Open
KartikP wants to merge 6 commits intomasterfrom
kp/berg-tooltip
Open

Add BERG hyperlink and tooltip#512
KartikP wants to merge 6 commits intomasterfrom
kp/berg-tooltip

Conversation

@KartikP
Copy link
Contributor

@KartikP KartikP commented Mar 5, 2026

Domain specific links redirect to appropriate external links. Includes both box and tooltip option. Tooltip option currently disabled. To re-enable tooltip, remove comment wrapper and rename tooltip attribute. See inline comment in line 266 (model.html).

image

@mschrimpf
Copy link
Member

also tagging @gifale95

Copy link
Member

@mschrimpf mschrimpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, but please move javascript outside of the html

Comment on lines +321 to +353
var bergLink = document.getElementById('berg-link');
if (bergLink) {
bergLink.addEventListener('click', function() {
gtag('event', 'click', {
event_category: 'BERG',
event_label: 'main_link',
transport_type: 'beacon'
});
});
}
document.addEventListener('click', function(e) {
var link = e.target.closest('.tooltip-multiline a');
if (!link) return;
var href = link.getAttribute('href');
var label = 'unknown';
if (href.indexOf('gifale95.github.io/BERG') !== -1) label = 'tooltip_berg';
else if (href.indexOf('readthedocs') !== -1) label = 'tooltip_documentation';
else if (href.indexOf('drive.google.com') !== -1) label = 'tooltip_tutorial';
gtag('event', 'click', {
event_category: 'BERG',
event_label: label,
transport_type: 'beacon'
});
});
document.querySelectorAll('.berg-box-link').forEach(function(link) {
link.addEventListener('click', function() {
gtag('event', 'click', {
event_category: 'BERG',
event_label: this.getAttribute('data-berg-label'),
transport_type: 'beacon'
});
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not put this in the javascript? bad practice imo to mix this in the html.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Didn't want to create a single javascript file for berg tracking. I'll make a generic link-tracking utility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's totally fine to put this in a single javascript file too. The website is set up to compress all javascript files into a single one before deployment, so no need to worry about network bandwidth or so. (Only worry about writing clean code ;-))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants