script.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  3. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4. *
  5. * This code is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 only, as
  7. * published by the Free Software Foundation. Oracle designates this
  8. * particular file as subject to the "Classpath" exception as provided
  9. * by Oracle in the LICENSE file that accompanied this code.
  10. *
  11. * This code is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * version 2 for more details (a copy is included in the LICENSE file that
  15. * accompanied this code).
  16. *
  17. * You should have received a copy of the GNU General Public License version
  18. * 2 along with this work; if not, write to the Free Software Foundation,
  19. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22. * or visit www.oracle.com if you need additional information or have any
  23. * questions.
  24. */
  25. var moduleSearchIndex;
  26. var packageSearchIndex;
  27. var typeSearchIndex;
  28. var memberSearchIndex;
  29. var tagSearchIndex;
  30. function loadScripts(doc, tag) {
  31. createElem(doc, tag, 'jquery/jszip/dist/jszip.js');
  32. createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils.js');
  33. if (window.navigator.userAgent.indexOf('MSIE ') > 0 || window.navigator.userAgent.indexOf('Trident/') > 0 ||
  34. window.navigator.userAgent.indexOf('Edge/') > 0) {
  35. createElem(doc, tag, 'jquery/jszip-utils/dist/jszip-utils-ie.js');
  36. }
  37. createElem(doc, tag, 'search.js');
  38. $.get(pathtoroot + "module-search-index.zip")
  39. .done(function() {
  40. JSZipUtils.getBinaryContent(pathtoroot + "module-search-index.zip", function(e, data) {
  41. JSZip.loadAsync(data).then(function(zip){
  42. zip.file("module-search-index.json").async("text").then(function(content){
  43. moduleSearchIndex = JSON.parse(content);
  44. });
  45. });
  46. });
  47. });
  48. $.get(pathtoroot + "package-search-index.zip")
  49. .done(function() {
  50. JSZipUtils.getBinaryContent(pathtoroot + "package-search-index.zip", function(e, data) {
  51. JSZip.loadAsync(data).then(function(zip){
  52. zip.file("package-search-index.json").async("text").then(function(content){
  53. packageSearchIndex = JSON.parse(content);
  54. });
  55. });
  56. });
  57. });
  58. $.get(pathtoroot + "type-search-index.zip")
  59. .done(function() {
  60. JSZipUtils.getBinaryContent(pathtoroot + "type-search-index.zip", function(e, data) {
  61. JSZip.loadAsync(data).then(function(zip){
  62. zip.file("type-search-index.json").async("text").then(function(content){
  63. typeSearchIndex = JSON.parse(content);
  64. });
  65. });
  66. });
  67. });
  68. $.get(pathtoroot + "member-search-index.zip")
  69. .done(function() {
  70. JSZipUtils.getBinaryContent(pathtoroot + "member-search-index.zip", function(e, data) {
  71. JSZip.loadAsync(data).then(function(zip){
  72. zip.file("member-search-index.json").async("text").then(function(content){
  73. memberSearchIndex = JSON.parse(content);
  74. });
  75. });
  76. });
  77. });
  78. $.get(pathtoroot + "tag-search-index.zip")
  79. .done(function() {
  80. JSZipUtils.getBinaryContent(pathtoroot + "tag-search-index.zip", function(e, data) {
  81. JSZip.loadAsync(data).then(function(zip){
  82. zip.file("tag-search-index.json").async("text").then(function(content){
  83. tagSearchIndex = JSON.parse(content);
  84. });
  85. });
  86. });
  87. });
  88. if (!moduleSearchIndex) {
  89. createElem(doc, tag, 'module-search-index.js');
  90. }
  91. if (!packageSearchIndex) {
  92. createElem(doc, tag, 'package-search-index.js');
  93. }
  94. if (!typeSearchIndex) {
  95. createElem(doc, tag, 'type-search-index.js');
  96. }
  97. if (!memberSearchIndex) {
  98. createElem(doc, tag, 'member-search-index.js');
  99. }
  100. if (!tagSearchIndex) {
  101. createElem(doc, tag, 'tag-search-index.js');
  102. }
  103. $(window).resize(function() {
  104. $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  105. });
  106. }
  107. function createElem(doc, tag, path) {
  108. var script = doc.createElement(tag);
  109. var scriptElement = doc.getElementsByTagName(tag)[0];
  110. script.src = pathtoroot + path;
  111. scriptElement.parentNode.insertBefore(script, scriptElement);
  112. }
  113. function show(type) {
  114. count = 0;
  115. for (var key in data) {
  116. var row = document.getElementById(key);
  117. if ((data[key] & type) !== 0) {
  118. row.style.display = '';
  119. row.className = (count++ % 2) ? rowColor : altColor;
  120. }
  121. else
  122. row.style.display = 'none';
  123. }
  124. updateTabs(type);
  125. }
  126. function updateTabs(type) {
  127. for (var value in tabs) {
  128. var sNode = document.getElementById(tabs[value][0]);
  129. var spanNode = sNode.firstChild;
  130. if (value == type) {
  131. sNode.className = activeTableTab;
  132. spanNode.innerHTML = tabs[value][1];
  133. }
  134. else {
  135. sNode.className = tableTab;
  136. spanNode.innerHTML = "<a href=\"javascript:show("+ value + ");\">" + tabs[value][1] + "</a>";
  137. }
  138. }
  139. }
  140. function updateModuleFrame(pFrame, cFrame) {
  141. top.packageFrame.location = pFrame;
  142. top.classFrame.location = cFrame;
  143. }