Skip to content

Commit cd087af

Browse files
committed
chore(js): Format fixes
1 parent 4973026 commit cd087af

File tree

6 files changed

+121
-93
lines changed

6 files changed

+121
-93
lines changed

assets/js/components/diagram.js

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,68 @@ export default function Diagram({ component }) {
66
if (!mermaidPromise) {
77
mermaidPromise = import('mermaid');
88
}
9-
mermaidPromise.then(({ default: mermaid }) => {
10-
// Configure mermaid with InfluxData theming
11-
mermaid.initialize({
12-
startOnLoad: false, // We'll manually call run()
13-
theme: document.body.classList.contains('dark-theme') ? 'dark' : 'default',
14-
themeVariables: {
15-
fontFamily: 'Proxima Nova',
16-
fontSize: '16px',
17-
lineColor: '#22ADF6',
18-
primaryColor: '#22ADF6',
19-
primaryTextColor: '#545454',
20-
secondaryColor: '#05CE78',
21-
tertiaryColor: '#f4f5f5',
22-
},
23-
securityLevel: 'loose', // Required for interactive diagrams
24-
logLevel: 'error'
9+
mermaidPromise
10+
.then(({ default: mermaid }) => {
11+
// Configure mermaid with InfluxData theming
12+
mermaid.initialize({
13+
startOnLoad: false, // We'll manually call run()
14+
theme: document.body.classList.contains('dark-theme')
15+
? 'dark'
16+
: 'default',
17+
themeVariables: {
18+
fontFamily: 'Proxima Nova',
19+
fontSize: '16px',
20+
lineColor: '#22ADF6',
21+
primaryColor: '#22ADF6',
22+
primaryTextColor: '#545454',
23+
secondaryColor: '#05CE78',
24+
tertiaryColor: '#f4f5f5',
25+
},
26+
securityLevel: 'loose', // Required for interactive diagrams
27+
logLevel: 'error',
28+
});
29+
30+
// Process the specific diagram component
31+
try {
32+
mermaid.run({ nodes: [component] });
33+
} catch (error) {
34+
console.error('Mermaid diagram rendering error:', error);
35+
}
36+
37+
// Store reference to mermaid for theme switching
38+
if (!window.mermaidInstances) {
39+
window.mermaidInstances = new Map();
40+
}
41+
window.mermaidInstances.set(component, mermaid);
42+
})
43+
.catch((error) => {
44+
console.error('Failed to load Mermaid library:', error);
2545
});
26-
27-
// Process the specific diagram component
28-
try {
29-
mermaid.run({ nodes: [component] });
30-
} catch (error) {
31-
console.error('Mermaid diagram rendering error:', error);
32-
}
33-
34-
// Store reference to mermaid for theme switching
35-
if (!window.mermaidInstances) {
36-
window.mermaidInstances = new Map();
37-
}
38-
window.mermaidInstances.set(component, mermaid);
39-
}).catch(error => {
40-
console.error('Failed to load Mermaid library:', error);
41-
});
42-
46+
4347
// Listen for theme changes to refresh diagrams
4448
const observer = new MutationObserver((mutations) => {
4549
mutations.forEach((mutation) => {
46-
if (mutation.attributeName === 'class' &&
47-
document.body.classList.contains('dark-theme') !== window.isDarkTheme) {
50+
if (
51+
mutation.attributeName === 'class' &&
52+
document.body.classList.contains('dark-theme') !== window.isDarkTheme
53+
) {
4854
window.isDarkTheme = document.body.classList.contains('dark-theme');
49-
55+
5056
// Reload this specific diagram with new theme
5157
if (window.mermaidInstances?.has(component)) {
5258
const mermaid = window.mermaidInstances.get(component);
5359
mermaid.initialize({
54-
theme: window.isDarkTheme ? 'dark' : 'default'
60+
theme: window.isDarkTheme ? 'dark' : 'default',
5561
});
5662
mermaid.run({ nodes: [component] });
5763
}
5864
}
5965
});
6066
});
61-
67+
6268
// Watch for theme changes on body element
6369
observer.observe(document.body, { attributes: true });
64-
70+
6571
// Return cleanup function to be called when component is destroyed
6672
return () => {
6773
observer.disconnect();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import SearchInteractions from '../utils/search-interactions';
1+
import SearchInteractions from '../utils/search-interactions.js';
22

33
export default function SidebarSearch({ component }) {
44
const searchInput = component.querySelector('.sidebar--search-field');
55
SearchInteractions({ searchInput });
6-
}
6+
}

assets/js/list-filters.js

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
// Count tag elements
22
function countTag(tag) {
3-
return $(".visible[data-tags*='" + tag + "']").length
3+
return $(".visible[data-tags*='" + tag + "']").length;
44
}
55

66
function getFilterCounts($labels) {
7-
$labels.each(function() {
8-
var tagName = $('input', this).attr('name').replace(/[\W/]+/, "-");
7+
$labels.each(function () {
8+
var tagName = $('input', this)
9+
.attr('name')
10+
.replace(/[\W/]+/, '-');
911
var tagCount = countTag(tagName);
1012
$(this).attr('data-count', '(' + tagCount + ')');
1113
if (tagCount <= 0) {
1214
$(this).fadeTo(200, 0.25);
1315
} else {
1416
$(this).fadeTo(400, 1.0);
1517
}
16-
})
18+
});
1719
}
1820

1921
export default function ListFilters({ component }) {
@@ -22,30 +24,41 @@ export default function ListFilters({ component }) {
2224

2325
getFilterCounts($labels);
2426

25-
$inputs.click(function() {
26-
27+
$inputs.click(function () {
2728
// List of tags to hide
28-
var tagArray = $(component).find("input:checkbox:checked").map(function(){
29-
return $(this).attr('name').replace(/[\W]+/, "-");
30-
}).get();
29+
var tagArray = $(component)
30+
.find('input:checkbox:checked')
31+
.map(function () {
32+
return $(this).attr('name').replace(/[\W]+/, '-');
33+
})
34+
.get();
3135

3236
// List of tags to restore
33-
var restoreArray = $(component).find("input:checkbox:not(:checked)").map(function(){
34-
return $(this).attr('name').replace(/[\W]+/, "-");
35-
}).get();
37+
var restoreArray = $(component)
38+
.find('input:checkbox:not(:checked)')
39+
.map(function () {
40+
return $(this).attr('name').replace(/[\W]+/, '-');
41+
})
42+
.get();
3643

3744
// Actions for filter select
38-
if ( $(this).is(':checked') ) {
39-
$.each( tagArray, function( index, value ) {
40-
$(".filter-item.visible:not([data-tags~='" + value + "'])").removeClass('visible').fadeOut()
41-
})
45+
if ($(this).is(':checked')) {
46+
$.each(tagArray, function (index, value) {
47+
$(".filter-item.visible:not([data-tags~='" + value + "'])")
48+
.removeClass('visible')
49+
.fadeOut();
50+
});
4251
} else {
43-
$.each( restoreArray, function( index, value ) {
44-
$(".filter-item:not(.visible)[data-tags~='" + value + "']").addClass('visible').fadeIn()
45-
})
46-
$.each( tagArray, function( index, value ) {
47-
$(".filter-item.visible:not([data-tags~='" + value + "'])").removeClass('visible').hide()
48-
})
52+
$.each(restoreArray, function (index, value) {
53+
$(".filter-item:not(.visible)[data-tags~='" + value + "']")
54+
.addClass('visible')
55+
.fadeIn();
56+
});
57+
$.each(tagArray, function (index, value) {
58+
$(".filter-item.visible:not([data-tags~='" + value + "'])")
59+
.removeClass('visible')
60+
.hide();
61+
});
4962
}
5063

5164
// Refresh filter count

assets/js/main.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ const componentRegistry = {
6262
'ask-ai-trigger': AskAITrigger,
6363
'code-placeholder': CodePlaceholder,
6464
'custom-time-trigger': CustomTimeTrigger,
65-
'diagram': Diagram,
65+
diagram: Diagram,
6666
'doc-search': DocSearch,
6767
'feature-callout': FeatureCallout,
6868
'flux-group-keys-demo': FluxGroupKeysDemo,
6969
'flux-influxdb-versions-trigger': FluxInfluxDBVersionsTrigger,
70-
'keybinding': KeyBinding,
70+
keybinding: KeyBinding,
7171
'list-filters': ListFilters,
7272
'product-selector': ProductSelector,
7373
'release-toc': ReleaseToc,
7474
'search-button': SearchButton,
7575
'sidebar-search': SidebarSearch,
7676
'sidebar-toggle': SidebarToggle,
77-
'theme': Theme,
78-
'theme-switch': ThemeSwitch
77+
theme: Theme,
78+
'theme-switch': ThemeSwitch,
7979
};
8080

8181
/**
@@ -93,12 +93,12 @@ function initGlobals() {
9393
window.influxdatadocs.pageContext = pageContext;
9494
window.influxdatadocs.toggleModal = modals.toggleModal;
9595
window.influxdatadocs.componentRegistry = componentRegistry;
96-
96+
9797
// Re-export jQuery to global namespace for legacy scripts
9898
if (typeof window.jQuery === 'undefined') {
9999
window.jQuery = window.$ = $;
100100
}
101-
101+
102102
return window.influxdatadocs;
103103
}
104104

@@ -108,32 +108,35 @@ function initGlobals() {
108108
*/
109109
function initComponents(globals) {
110110
const components = document.querySelectorAll('[data-component]');
111-
111+
112112
components.forEach((component) => {
113113
const componentName = component.getAttribute('data-component');
114114
const ComponentConstructor = componentRegistry[componentName];
115-
115+
116116
if (ComponentConstructor) {
117117
// Initialize the component and store its instance in the global namespace
118118
try {
119119
const instance = ComponentConstructor({ component });
120120
globals[componentName] = ComponentConstructor;
121-
121+
122122
// Optionally store component instances for future reference
123123
if (!globals.instances) {
124124
globals.instances = {};
125125
}
126-
126+
127127
if (!globals.instances[componentName]) {
128128
globals.instances[componentName] = [];
129129
}
130-
130+
131131
globals.instances[componentName].push({
132132
element: component,
133-
instance
133+
instance,
134134
});
135135
} catch (error) {
136-
console.error(`Error initializing component "${componentName}":`, error);
136+
console.error(
137+
`Error initializing component "${componentName}":`,
138+
error
139+
);
137140
}
138141
} else {
139142
console.warn(`Unknown component: "${componentName}"`);
@@ -163,10 +166,10 @@ function initModules() {
163166
function init() {
164167
// Initialize global namespace and expose core modules
165168
const globals = initGlobals();
166-
169+
167170
// Initialize non-component UI modules
168171
initModules();
169-
172+
170173
// Initialize components from registry
171174
initComponents(globals);
172175
}
@@ -175,4 +178,4 @@ function init() {
175178
document.addEventListener('DOMContentLoaded', init);
176179

177180
// Export public API
178-
export { initGlobals, componentRegistry };
181+
export { initGlobals, componentRegistry };

assets/js/utils/user-agent-platform.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,24 @@ export function getPlatform() {
1212
// Try to use modern User-Agent Client Hints API first (Chrome 89+, Edge 89+)
1313
if (navigator.userAgentData && navigator.userAgentData.platform) {
1414
const platform = navigator.userAgentData.platform.toLowerCase();
15-
15+
1616
if (platform.includes('mac')) return 'osx';
1717
if (platform.includes('win')) return 'win';
1818
if (platform.includes('linux')) return 'linux';
1919
}
20-
20+
2121
// Fall back to userAgent string parsing
2222
const userAgent = navigator.userAgent.toLowerCase();
23-
24-
if (userAgent.includes('mac') || userAgent.includes('iphone') || userAgent.includes('ipad')) return 'osx';
23+
24+
if (
25+
userAgent.includes('mac') ||
26+
userAgent.includes('iphone') ||
27+
userAgent.includes('ipad')
28+
)
29+
return 'osx';
2530
if (userAgent.includes('win')) return 'win';
26-
if (userAgent.includes('linux') || userAgent.includes('android')) return 'linux';
27-
31+
if (userAgent.includes('linux') || userAgent.includes('android'))
32+
return 'linux';
33+
2834
return 'other';
29-
}
35+
}

assets/js/version-selector.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
export default function ProductSelector({ component }) {
22
// Select the product dropdown and dropdown items
3-
const productDropdown = component.querySelector("#product-dropdown");
4-
const dropdownItems = component.querySelector("#dropdown-items");
3+
const productDropdown = component.querySelector('#product-dropdown');
4+
const dropdownItems = component.querySelector('#dropdown-items');
55

66
// Expand the menu on click
77
if (productDropdown) {
8-
productDropdown.addEventListener("click", function() {
9-
productDropdown.classList.toggle("open");
10-
dropdownItems.classList.toggle("open");
8+
productDropdown.addEventListener('click', function () {
9+
productDropdown.classList.toggle('open');
10+
dropdownItems.classList.toggle('open');
1111
});
1212
}
1313

1414
// Close the dropdown by clicking anywhere else
15-
document.addEventListener("click", function(e) {
15+
document.addEventListener('click', function (e) {
1616
// Check if the click was outside of the '.product-list' container
1717
if (!e.target.closest('.product-list')) {
18-
dropdownItems.classList.remove("open");
18+
dropdownItems.classList.remove('open');
1919
}
2020
});
2121
}

0 commit comments

Comments
 (0)