MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Tag: Manual revert
(3 intermediate revisions by the same user not shown)
Line 117:
return;
}
 
/*
* Longer terms are checked first so that phrases such as
* "repository install" are highlighted before "repository".
*/
terms.sort(function (a, b) {
return b.length - a.length;
});
 
var escapedTerms = terms.map(function (term) {
Line 184 ⟶ 192:
);
}
 
var normalisedMatch =
tuflowNormaliseSearchText(match);
 
var termIndex = terms.findIndex(function (term) {
return term === normalisedMatch;
});
 
/*
* Cycle through five highlight colours.
*/
var colourNumber =
(Math.max(termIndex, 0) % 5) + 1;
 
var mark = document.createElement('mark');
 
mark.className = 'search-highlight';
'search-highlight search-highlight-' +
colourNumber;
 
mark.textContent = match;
fragment.appendChild(mark);
Line 209 ⟶ 234:
});
}
 
 
/* -------------------------------------------------------------------------