1jQuery(document).ready(function($) { 2 3 function capitalizeText(text) { 4 // Convert to lowercase first 5 var result = text.toLowerCase(); 6 7 // Split by spaces and process each word 8 var words = result.split(' '); 9 10 for (var i = 0; i < words.length; i++) { 11 var word = words[i]; 12 if (word.length > 0) { 13 // Check if word contains apostrophe 14 if (word.indexOf("'") !== -1) { 15 // Handle contractions and possessives 16 var parts = word.split("'"); 17 // Capitalize first part 18 if (parts[0].length > 0) { 19 parts[0] = parts[0].charAt(0).toUpperCase() + parts[0].slice(1); 20 } 21 // Keep everything after apostrophe lowercase 22 words[i] = parts.join("'"); 23 } else { 24 // Regular word - capitalize first letter 25 words[i] = word.charAt(0).toUpperCase() + word.slice(1); 26 } 27 } 28 } 29 30 return words.join(' '); 31 } 32 33 function fixTOCCapitalization() { 34 $('.wpj-jtoc--item .wpj-jtoc--item-content > a').each(function() { 35 var $link = $(this); 36 var originalText = $link.text(); 37 38 // Only process if text is all uppercase 39 if (originalText === originalText.toUpperCase() && originalText !== originalText.toLowerCase()) { 40 var capitalizedText = capitalizeText(originalText); 41 $link.text(capitalizedText); 42 } 43 }); 44 } 45 46 // Run on page load 47 fixTOCCapitalization(); 48 49 // Run when new content is loaded (for dynamic content) 50 $(document).on('DOMNodeInserted', function() { 51 setTimeout(fixTOCCapitalization, 100); 52 }); 53 54 // Alternative: Use MutationObserver for better performance 55 if (window.MutationObserver) { 56 var observer = new MutationObserver(function(mutations) { 57 var shouldRun = false; 58 mutations.forEach(function(mutation) { 59 if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { 60 shouldRun = true; 61 } 62 }); 63 if (shouldRun) { 64 setTimeout(fixTOCCapitalization, 100); 65 } 66 }); 67 68 observer.observe(document.body, { 69 childList: true, 70 subtree: true 71 }); 72 } 73});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.