MCPcopy Index your code
hub / github.com/socketstream/socketstream / rank

Function rank

docs/js/docs.js:477–497  ·  view source on GitHub ↗
(page, terms)

Source from the content-addressed store, hash-verified

475 }
476
477 function rank(page, terms) {
478 var ranking = {page: page, rank:0},
479 keywords = page.keywords,
480 title = page.shortName.toLowerCase();
481
482 terms && angular.forEach(terms.toLowerCase().split(' '), function(term) {
483 var index;
484
485 if (ranking) {
486 if (keywords.indexOf(term) == -1) {
487 ranking = null;
488 } else {
489 ranking.rank ++; // one point for each term found
490 if ((index = title.indexOf(term)) != -1) {
491 ranking.rank += 20 - index; // ten points if you match title
492 }
493 }
494 }
495 });
496 return ranking;
497 }
498 }
499
500

Callers 1

updateSearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected