1$(document).ready(function () { 2 $('input[data-cpsearch]:not(:text)').click(function (event) { 3 cp_ExecuteSearch($('#' + $(this).data('cpsearch')), event); 4 }); 5 $('input[data-cpsearch]:text, textarea[data-cpsearch]').keypress(function (event) { 6 if (event.which != 13) return; 7 cp_ExecuteSearch($(this), event); 8 }); 9}); 10 11function cp_ExecuteSearch($input, event) { 12 if (($input.val() === '') && ($input.data('allowemptysearches') !== true)) return; 13 event.preventDefault(); 14 15 var href = $input.data('cpsearch'); 16 if (href == '') href = '/Main/Search.aspx?search='; 17 18 if ($input.val() !== '') { 19 var exactMatch = $input.data('cpsearch-exactmatch'); 20 if ((exactMatch !== '') && $('#' + exactMatch).is(':checked')) 21 href += encodeURIComponent('"' + $input.val() + '"') 22 else 23 href += encodeURIComponent($input.val()) 24 } 25 26 //alert(href); 27 window.location.href = href; 28} 29 30function initSplashPage(divId, height, width, top, left, borderWidth, padding, bgcolor, duration) { 31 var div = $get(divId); 32 33 var windowHeight = 0, windowWidth = 0; 34 if (typeof (window.innerWidth) == 'number') { 35 windowHeight = window.innerHeight; 36 windowWidth = window.innerWidth; 37 } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 38 windowHeight = document.documentElement.clientHeight; 39 windowWidth = document.documentElement.clientWidth; 40 } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { 41 windowHeight = document.body.clientHeight; 42 windowWidth = document.body.clientWidth; 43 } 44 45 div.style.height = height + 'px'; 46 div.style.width = width + 'px'; 47 div.style.top = Math.round((windowHeight / 2) - (height / (100 / (100 - top)))) + 'px'; 48 div.style.left = Math.round((windowWidth / 2) - (width / (100 / (100 - left)))) + 'px'; 49 div.style.backgroundColor = bgcolor; 50 div.style.padding = padding + 'px'; 51 div.style.borderWidth = borderWidth + 'px'; 52 53 toggleDiv(divId, false); 54 setTimeout(function () { closeSplashPage(); }, duration * 1000); 55} 56 57function smartLinks(terms, ignoreCase) { 58 var replacements = {}; 59 var regex = {}; 60 var count = 0; 61 var flags = ignoreCase ? 'gi' : 'g'; 62 63 for (var key in terms) { 64 var link = terms[key]; 65 //alert(link.url); 66 if (link.url.length > 0) 67 replacements[key] = '<a href="' + link.url + '" target="' + link.target + '" class="cpweb_SmartLinks" onmouseover="toolTipShow(this, \'' + link.toolTipClientId + '\');" onmouseout="toolTipHide(\'' + link.toolTipClientId + '\');">' + key + '</a>'; 68 else 69 replacements[key] = '<span class="cpweb_SmartLinks" onmouseover="toolTipShow(this, \'' + link.toolTipClientId + '\');" onmouseout="toolTipHide(\'' + link.toolTipClientId + '\');">' + key + '</span>'; 70 regex[key] = new RegExp('\\b' + key + '\\b', flags); 71 count++; 72 } 73 74 //if (count > 0) smartLinksReplaceInTextNodes(document.body, regex, replacements); 75 if (count > 0) smartLinksFindAndReplace(document.body, regex, replacements); 76} 77 78function smartLinksFindAndReplace(searchNode, regex, replacements) { 79 if (searchNode.className == "cpweb_SmartLinks") return; // no replacements within smart links 80 switch (searchNode.nodeName.toLowerCase()) { // no replacements within specified html elements 81 case 'head': 82 case 'script': 83 case 'style': 84 case 'title': 85 case 'meta': 86 case 'object': 87 case 'iframe': 88 case 'a': 89 return; 90 } 91 92 var childNodes = (searchNode || document.body).childNodes; 93 var cnLength = childNodes.length; 94 95 while (cnLength--) { 96 var currentNode = childNodes[cnLength]; 97 98 if (currentNode.nodeType === 1) 99 arguments.callee(currentNode, regex, replacements); 100 101 if (currentNode.nodeType !== 3) 102 continue; 103 104 if (currentNode.data.length <= 2) 105 continue; 106 107 smartLinksReplace(currentNode, cnLength, regex, replacements); 108 } 109} 110 111function smartLinksReplace(currentNode, index, regex, replacements) { 112 var parent = currentNode.parentNode; 113 114 var html = currentNode.data; 115 var replaced = false; 116 for (var key in replacements) { 117 regex[key].lastIndex = 0; 118 if (!regex[key].test(html)) 119 continue; 120 html = html.replace(regex[key], replacements[key]); 121 replaced = true; 122 } 123 124 if (replaced) { 125 //alert(currentNode.data + '\n\nwas replaced with\n\n' + html); 126 var frag = (function () { 127 var wrap = document.createElement('span'); 128 var frag = document.createDocumentFragment(); 129 wrap.innerHTML = html; 130 while (wrap.firstChild) 131 frag.appendChild(wrap.firstChild); 132 return frag; 133 })(); 134 parent.insertBefore(frag, currentNode); 135 parent.removeChild(currentNode); 136 } 137} 138 139function toolTipShow(source, divId) { 140 var div = $get(divId); 141 div.onmouseover = function (e) { toolTipShow(source, divId) } 142 div.onmouseout = function (e) { toolTipHide(divId) } 143 144 var style = $get(divId).style; 145 var offset = findOffset(source); 146 style.left = offset[0] + 'px'; 147 style.display = 'block'; 148 style.top = offset[1] - div.clientHeight + 'px'; 149} 150 151function toolTipHide(divId) { 152 $get(divId).style.display = 'none'; 153}
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.