cesiumDoc.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. (function() {
  2. var filterType = document.getElementById('filterType');
  3. var classFilter = document.getElementById('ClassFilter');
  4. var classList = document.getElementById('ClassList');
  5. function filter() {
  6. var value = classFilter.value.toLowerCase();
  7. var items = classList.getElementsByTagName('li');
  8. for (var i = 0; i < items.length; i++) {
  9. var item = items[i];
  10. var itemName = item.getAttribute('data-name') || '';
  11. itemName = itemName.toLowerCase().replace(/\s/g, '');
  12. if (itemName.indexOf(value) >= 0) {
  13. item.style.display = '';
  14. } else {
  15. item.style.display = 'none';
  16. }
  17. }
  18. }
  19. classFilter.onkeyup = filter;
  20. function getQueryParameter(name) {
  21. var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
  22. return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  23. }
  24. var show = getQueryParameter('show');
  25. if (show) {
  26. document.getElementById('filterType').value = show;
  27. }
  28. var searchTerm = getQueryParameter('classFilter') || '';
  29. classFilter.value = searchTerm;
  30. filter();
  31. function resetFilter() {
  32. classFilter.value = '';
  33. filter();
  34. }
  35. function updateMenuLinks() {
  36. var links = classList.getElementsByTagName('a');
  37. var searchTerm = classFilter.value;
  38. for (var i = 0; i < links.length; i++) {
  39. var link = links[i];
  40. var prefix = link.href.split('?')[0];
  41. link.href = prefix + (searchTerm === '' ? '' : '?classFilter=' + searchTerm);
  42. }
  43. }
  44. var menuLinks = classList.getElementsByTagName('a');
  45. for (var i = 0; i < menuLinks.length; i++) {
  46. menuLinks[i].onclick = function() {
  47. updateMenuLinks();
  48. }
  49. }
  50. })();