fix links
This commit is contained in:
		
							parent
							
								
									0eed65e623
								
							
						
					
					
						commit
						6c7d3528f7
					
				@ -21,6 +21,73 @@ const { title, description = 'ForensicPathways - A comprehensive directory of di
 | 
			
		||||
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
 | 
			
		||||
  
 | 
			
		||||
<script>
 | 
			
		||||
  // Move utility functions OUTSIDE DOMContentLoaded to avoid race conditions
 | 
			
		||||
  function createToolSlug(toolName) {
 | 
			
		||||
    if (!toolName || typeof toolName !== 'string') {
 | 
			
		||||
      console.warn('[toolHelpers] Invalid toolName provided to createToolSlug:', toolName);
 | 
			
		||||
      return '';
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return toolName.toLowerCase()
 | 
			
		||||
      .replace(/[^a-z0-9\s-]/g, '')     // Remove special characters
 | 
			
		||||
      .replace(/\s+/g, '-')             // Replace spaces with hyphens
 | 
			
		||||
      .replace(/-+/g, '-')              // Remove duplicate hyphens
 | 
			
		||||
      .replace(/^-|-$/g, '');           // Remove leading/trailing hyphens
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function findToolByIdentifier(tools, identifier) {
 | 
			
		||||
    if (!identifier || !Array.isArray(tools)) return undefined;
 | 
			
		||||
    
 | 
			
		||||
    return tools.find(tool => 
 | 
			
		||||
      tool.name === identifier || 
 | 
			
		||||
      createToolSlug(tool.name) === identifier.toLowerCase()
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function isToolHosted(tool) {
 | 
			
		||||
    return tool.projectUrl !== undefined && 
 | 
			
		||||
           tool.projectUrl !== null && 
 | 
			
		||||
           tool.projectUrl !== "" && 
 | 
			
		||||
           tool.projectUrl.trim() !== "";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Consolidated scrolling utility - also moved outside DOMContentLoaded
 | 
			
		||||
  function scrollToElement(element, options = {}) {
 | 
			
		||||
    if (!element) return;
 | 
			
		||||
    
 | 
			
		||||
    // Calculate target position manually to avoid double-scroll
 | 
			
		||||
    setTimeout(() => {
 | 
			
		||||
      const headerHeight = document.querySelector('nav')?.offsetHeight || 80;
 | 
			
		||||
      const elementRect = element.getBoundingClientRect();
 | 
			
		||||
      const absoluteElementTop = elementRect.top + window.pageYOffset;
 | 
			
		||||
      const targetPosition = absoluteElementTop - headerHeight - 20; // Adjust this 20 as needed
 | 
			
		||||
      
 | 
			
		||||
      window.scrollTo({
 | 
			
		||||
        top: targetPosition,
 | 
			
		||||
        behavior: 'smooth'
 | 
			
		||||
      });
 | 
			
		||||
    }, 100);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Convenience functions for common scroll targets
 | 
			
		||||
  function scrollToElementById(elementId, options = {}) {
 | 
			
		||||
    const element = document.getElementById(elementId);
 | 
			
		||||
    scrollToElement(element, options);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function scrollToElementBySelector(selector, options = {}) {
 | 
			
		||||
    const element = document.querySelector(selector);
 | 
			
		||||
    scrollToElement(element, options);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Attach to window immediately - BEFORE DOMContentLoaded
 | 
			
		||||
  (window as any).createToolSlug = createToolSlug;
 | 
			
		||||
  (window as any).findToolByIdentifier = findToolByIdentifier;
 | 
			
		||||
  (window as any).isToolHosted = isToolHosted;
 | 
			
		||||
  (window as any).scrollToElement = scrollToElement;
 | 
			
		||||
  (window as any).scrollToElementById = scrollToElementById;
 | 
			
		||||
  (window as any).scrollToElementBySelector = scrollToElementBySelector;
 | 
			
		||||
 | 
			
		||||
  document.addEventListener('DOMContentLoaded', () => {
 | 
			
		||||
    const THEME_KEY = 'dfir-theme';
 | 
			
		||||
 | 
			
		||||
@ -73,68 +140,6 @@ const { title, description = 'ForensicPathways - A comprehensive directory of di
 | 
			
		||||
      getStoredTheme
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
      // Consolidated scrolling utility
 | 
			
		||||
      (window as any).scrollToElement = function(element, options = {}) {
 | 
			
		||||
        if (!element) return;
 | 
			
		||||
        
 | 
			
		||||
        // Calculate target position manually to avoid double-scroll
 | 
			
		||||
        setTimeout(() => {
 | 
			
		||||
          const headerHeight = document.querySelector('nav')?.offsetHeight || 80;
 | 
			
		||||
          const elementRect = element.getBoundingClientRect();
 | 
			
		||||
          const absoluteElementTop = elementRect.top + window.pageYOffset;
 | 
			
		||||
          const targetPosition = absoluteElementTop - headerHeight - 20; // Adjust this 20 as needed
 | 
			
		||||
          
 | 
			
		||||
          window.scrollTo({
 | 
			
		||||
            top: targetPosition,
 | 
			
		||||
            behavior: 'smooth'
 | 
			
		||||
          });
 | 
			
		||||
        }, 100);
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      // Convenience functions for common scroll targets
 | 
			
		||||
      (window as any).scrollToElementById = function(elementId, options = {}) {
 | 
			
		||||
        const element = document.getElementById(elementId);
 | 
			
		||||
        (window as any).scrollToElement(element, options);
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      (window as any).scrollToElementBySelector = function(selector, options = {}) {
 | 
			
		||||
        const element = document.querySelector(selector);
 | 
			
		||||
        (window as any).scrollToElement(element, options);
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
      function createToolSlug(toolName) {
 | 
			
		||||
        if (!toolName || typeof toolName !== 'string') {
 | 
			
		||||
          console.warn('[toolHelpers] Invalid toolName provided to createToolSlug:', toolName);
 | 
			
		||||
          return '';
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        return toolName.toLowerCase()
 | 
			
		||||
          .replace(/[^a-z0-9\s-]/g, '')     // Remove special characters
 | 
			
		||||
          .replace(/\s+/g, '-')             // Replace spaces with hyphens
 | 
			
		||||
          .replace(/-+/g, '-')              // Remove duplicate hyphens
 | 
			
		||||
          .replace(/^-|-$/g, '');           // Remove leading/trailing hyphens
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      function findToolByIdentifier(tools, identifier) {
 | 
			
		||||
        if (!identifier || !Array.isArray(tools)) return undefined;
 | 
			
		||||
        
 | 
			
		||||
        return tools.find(tool => 
 | 
			
		||||
          tool.name === identifier || 
 | 
			
		||||
          createToolSlug(tool.name) === identifier.toLowerCase()
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      function isToolHosted(tool) {
 | 
			
		||||
        return tool.projectUrl !== undefined && 
 | 
			
		||||
               tool.projectUrl !== null && 
 | 
			
		||||
               tool.projectUrl !== "" && 
 | 
			
		||||
               tool.projectUrl.trim() !== "";
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      (window as any).createToolSlug = createToolSlug;
 | 
			
		||||
      (window as any).findToolByIdentifier = findToolByIdentifier;
 | 
			
		||||
      (window as any).isToolHosted = isToolHosted;
 | 
			
		||||
 | 
			
		||||
    async function checkClientAuth(context = 'general') {
 | 
			
		||||
      try {
 | 
			
		||||
        const response = await fetch('/api/auth/status');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user