script.js revision 3233:b5d08bc0d224
1/*
2 * Copyright (c) 2013, 2015, 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
26var packageSearchIndex;
27var typeSearchIndex;
28var memberSearchIndex;
29var tagSearchIndex;
30function 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
39    $.get(pathtoroot + "package-search-index.zip")
40            .done(function() {
41                JSZipUtils.getBinaryContent(pathtoroot + "package-search-index.zip", function(e, data) {
42                    var zip = new JSZip(data);
43                    zip.load(data);
44                    packageSearchIndex = JSON.parse(zip.file("package-search-index.json").asText());
45                });
46            });
47    $.get(pathtoroot + "type-search-index.zip")
48            .done(function() {
49                JSZipUtils.getBinaryContent(pathtoroot + "type-search-index.zip", function(e, data) {
50                    var zip = new JSZip(data);
51                    zip.load(data);
52                    typeSearchIndex = JSON.parse(zip.file("type-search-index.json").asText());
53                });
54            });
55    $.get(pathtoroot + "member-search-index.zip")
56            .done(function() {
57                JSZipUtils.getBinaryContent(pathtoroot + "member-search-index.zip", function(e, data) {
58                    var zip = new JSZip(data);
59                    zip.load(data);
60                    memberSearchIndex = JSON.parse(zip.file("member-search-index.json").asText());
61                });
62            });
63    $.get(pathtoroot + "tag-search-index.zip")
64            .done(function() {
65                JSZipUtils.getBinaryContent(pathtoroot + "tag-search-index.zip", function(e, data) {
66                    var zip = new JSZip(data);
67                    zip.load(data);
68                    tagSearchIndex = JSON.parse(zip.file("tag-search-index.json").asText());
69                });
70            });
71}
72
73function createElem(doc, tag, path) {
74    var script = doc.createElement(tag);
75    var scriptElement = doc.getElementsByTagName(tag)[0];
76    script.src = pathtoroot + path;
77    scriptElement.parentNode.insertBefore(script, scriptElement);
78}
79
80function show(type)
81{
82    count = 0;
83    for (var key in methods) {
84        var row = document.getElementById(key);
85        if ((methods[key] &  type) != 0) {
86            row.style.display = '';
87            row.className = (count++ % 2) ? rowColor : altColor;
88        }
89        else
90            row.style.display = 'none';
91    }
92    updateTabs(type);
93}
94
95function updateTabs(type)
96{
97    for (var value in tabs) {
98        var sNode = document.getElementById(tabs[value][0]);
99        var spanNode = sNode.firstChild;
100        if (value == type) {
101            sNode.className = activeTableTab;
102            spanNode.innerHTML = tabs[value][1];
103        }
104        else {
105            sNode.className = tableTab;
106            spanNode.innerHTML = "<a href=\"javascript:show("+ value + ");\">" + tabs[value][1] + "</a>";
107        }
108    }
109}
110