Skip to content

Commit 7c0af85

Browse files
Make search and bookmark functions globally accessible
Co-authored-by: 0xrinegade <[email protected]>
1 parent 580a9c9 commit 7c0af85

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

assets/js/main.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
initializeLLMsButton();
2424
}
2525

26+
// Global functions that need to be accessible outside their initialization scopes
27+
let performSearch = null;
28+
let toggleBookmark = null;
29+
2630
// Search functionality
2731
function initializeSearch() {
2832
const searchToggle = document.getElementById('search-toggle');
@@ -97,7 +101,8 @@
97101
}, 150);
98102
});
99103

100-
function performSearch(query) {
104+
// Define performSearch and assign to global variable
105+
performSearch = function(query) {
101106
if (!searchIndex) {
102107
searchResults.innerHTML = '<div class="search-result"><div class="search-result-title">Search not available</div></div>';
103108
return;
@@ -110,7 +115,7 @@
110115
console.error('Search error:', e);
111116
searchResults.innerHTML = '<div class="search-result"><div class="search-result-title">Search error occurred</div></div>';
112117
}
113-
}
118+
};
114119

115120
function displaySearchResults(results, query) {
116121
if (results.length === 0) {
@@ -197,7 +202,8 @@
197202
toggleBookmark(currentUrl, currentTitle);
198203
});
199204

200-
function toggleBookmark(url, title) {
205+
// Define toggleBookmark and assign to global variable
206+
toggleBookmark = function(url, title) {
201207
let bookmarks = JSON.parse(localStorage.getItem('solana-mcp-bookmarks') || '[]');
202208
const existingIndex = bookmarks.findIndex(b => b.url === url);
203209

@@ -219,7 +225,7 @@
219225

220226
localStorage.setItem('solana-mcp-bookmarks', JSON.stringify(bookmarks));
221227
window.bookmarks = bookmarks;
222-
}
228+
};
223229

224230
function updateBookmarkIcon() {
225231
const bookmarks = JSON.parse(localStorage.getItem('solana-mcp-bookmarks') || '[]');
@@ -556,15 +562,18 @@
556562

557563
// Export for global access
558564
window.SolanaMCPDocs = {
559-
search: performSearch,
560-
toggleBookmark: (url, title) => toggleBookmark(url, title),
565+
search: (query) => performSearch && performSearch(query),
566+
toggleBookmark: (url, title) => toggleBookmark && toggleBookmark(url, title),
561567
getBookmarks: () => JSON.parse(localStorage.getItem('solana-mcp-bookmarks') || '[]'),
562568
clearBookmarks: () => {
563569
localStorage.removeItem('solana-mcp-bookmarks');
564570
window.bookmarks = [];
565571
}
566572
};
567573

574+
// Also expose performSearch globally for backward compatibility
575+
window.performSearch = (query) => performSearch && performSearch(query);
576+
568577
// Micro-animations and interactive enhancements
569578
function initializeMicroAnimations() {
570579
// Enhanced button interactions

0 commit comments

Comments
 (0)