Private methods
()
| 379 | ***********************************/ |
| 380 | |
| 381 | function updateSearch() { |
| 382 | var cache = {}, |
| 383 | pages = sections[$location.path().split('/')[1]], |
| 384 | modules = $scope.modules = [], |
| 385 | otherPages = $scope.pages = [], |
| 386 | search = $scope.search, |
| 387 | bestMatch = {page: null, rank:0}; |
| 388 | |
| 389 | angular.forEach(pages, function(page) { |
| 390 | var match, |
| 391 | id = page.id, |
| 392 | section = page.section; |
| 393 | |
| 394 | if (!(match = rank(page, search))) return; |
| 395 | |
| 396 | if (match.rank > bestMatch.rank) { |
| 397 | bestMatch = match; |
| 398 | } |
| 399 | |
| 400 | if (page.id == 'index') { |
| 401 | //skip |
| 402 | } else if (!NG_DOCS.apis[section]) { |
| 403 | otherPages.push(page); |
| 404 | } else if (id == 'angular.Module') { |
| 405 | module('ng', section).types.push(page); |
| 406 | } else if (match = id.match(GLOBALS)) { |
| 407 | module('ng', section).globals.push(page); |
| 408 | } else if (match = id.match(MODULE)) { |
| 409 | module(page.moduleName || match[1], section); |
| 410 | } else if (match = id.match(MODULE_FILTER)) { |
| 411 | module(page.moduleName || match[1], section).filters.push(page); |
| 412 | } else if (match = id.match(MODULE_CONTROLLER) && page.type === 'controller') { |
| 413 | module(page.moduleName || match[1], section).controllers.push(page); |
| 414 | } else if (match = id.match(MODULE_DIRECTIVE)) { |
| 415 | module(page.moduleName || match[1], section).directives.push(page); |
| 416 | } else if (match = id.match(MODULE_DIRECTIVE_INPUT)) { |
| 417 | module(page.moduleName || match[1], section).directives.push(page); |
| 418 | } else if (match = id.match(MODULE_CUSTOM)) { |
| 419 | if (page.type === 'service') { |
| 420 | module(page.moduleName || match[1], section).service(match[3])[page.id.match(/^.+Provider$/) ? 'provider' : 'instance'] = page; |
| 421 | } else { |
| 422 | var m = module(page.moduleName || match[1], section), |
| 423 | listName = page.type + 's'; |
| 424 | |
| 425 | if (m[listName]) { |
| 426 | m[listName].push(page); |
| 427 | } else { |
| 428 | m.others.push(page); |
| 429 | } |
| 430 | } |
| 431 | } else if (match = id.match(MODULE_TYPE) && page.type === 'type') { |
| 432 | module(page.moduleName || match[1], section).types.push(page); |
| 433 | } else if (match = id.match(MODULE_SERVICE)) { |
| 434 | if (page.type === 'overview') { |
| 435 | module(id, section); |
| 436 | } else { |
| 437 | module(page.moduleName || match[1], section).service(match[2])[match[3] ? 'provider' : 'instance'] = page; |
| 438 | } |