1187N/A/*
1187N/A * CDDL HEADER START
1187N/A *
1187N/A * The contents of this file are subject to the terms of the
1187N/A * Common Development and Distribution License (the "License").
1187N/A * You may not use this file except in compliance with the License.
1187N/A *
1187N/A * See LICENSE.txt included in this distribution for the specific
1187N/A * language governing permissions and limitations under the License.
1187N/A *
1187N/A * When distributing Covered Code, include this CDDL HEADER in each
1187N/A * file and include the License file at LICENSE.txt.
1187N/A * If applicable, add the following below this CDDL HEADER, with the
1187N/A * fields enclosed by brackets "[]" replaced with your own identifying
1187N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1187N/A *
1187N/A * CDDL HEADER END
1187N/A */
1421N/A
1281N/A/*
1421N/A * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
1421N/A */
1421N/A
1421N/A/*
1187N/A * Portions Copyright 2011 Jens Elkner.
1187N/A */
1187N/Adocument.pageReady = [];
1187N/Adocument.domReady = [];
1187N/A
1187N/Awindow.onload = function() {
1281N/A for(var i in document.pageReady) {
1281N/A document.pageReady[i]();
1281N/A }
1187N/A}
1187N/A
1187N/A$(document).ready(function() {
1281N/A for(var i in this.domReady) {
1281N/A document.domReady[i]();
1281N/A }
1187N/A});
1187N/A
1187N/A/**
1187N/A * Resize the element with the ID 'content' so that it fills the whole browser
1187N/A * window (i.e. the space between the header and the bottom of the window) and
1281N/A * thus get rid off the scrollbar in the page header.
1187N/A */
1187N/Afunction resizeContent() {
1281N/A if (document.adjustContent != 0) {
1281N/A $('#content').css('top', $('body').outerHeight(true)).css('bottom', 0);
1281N/A }
1187N/A}
1187N/A
1187N/Afunction domReadyMast() {
1281N/A var h = document.locHash;
1281N/A if (!window.location.hash) {
1281N/A if (h != null && h != "null") {
1281N/A window.location.hash=h
1281N/A } else {
1281N/A $('#content').focus();
1281N/A }
1281N/A }
1281N/A if (document.annotate) {
1281N/A $('a[class=r]').tooltip({ left: 5, showURL: false });
1281N/A var toggle_js = document.getElementById('toggle-annotate-by-javascript');
1281N/A var toggle_ss = document.getElementById('toggle-annotate');
1187N/A
1281N/A toggle_js.style.display = 'inline';
1281N/A toggle_ss.style.display = 'none';
1281N/A }
1187N/A}
1187N/A
1187N/Afunction pageReadyMast() {
1281N/A document.adjustContent = 0;
1281N/A if ($('#whole_header') != null && $('#content') != null) {
1281N/A document.adjustContent = 1;
1281N/A resizeContent();
1281N/A }
1281N/A $(window).resize(
1281N/A function() {
1281N/A resizeContent();
1281N/A }
1281N/A );
1187N/A}
1187N/A
1187N/Afunction domReadyMenu() {
1281N/A var projects = document.projects;
1281N/A var sbox = document.getElementById('sbox');
1281N/A/*
1281N/A $("#project").autocomplete(projects, {
1281N/A minChars: 0,
1281N/A multiple: true,
1281N/A multipleSeparator: ",",
1281N/A //mustMatch: true,
1281N/A matchContains: "word",
1281N/A max: 200,
1281N/A cacheLength:20,
1281N/A //autoFill: false,
1281N/A formatItem: function(row, i, max) {
1281N/A return (row != null) ? i + "/" + max + ": " + row[0] : "";
1281N/A },
1281N/A formatMatch: function(row, i, max) {
1281N/A return (row != null) ? row[0] : "";
1281N/A },
1281N/A formatResult: function(row) {
1281N/A return (row != null) ? row[0] : "";
1281N/A },
1281N/A width: "300px"
1281N/A });
1254N/A*/
1281N/A // TODO Bug 11749
1281N/A // var p = document.getElementById('project');
1281N/A // p.setAttribute("autocomplete", "off");
1187N/A}
1187N/A
1187N/Afunction domReadyHistory() {
1281N/A // start state should ALWAYS be: first row: r1 hidden, r2 checked ;
1187N/A // second row: r1 clicked, (r2 hidden)(optionally)
1281N/A // I cannot say what will happen if they are not like that, togglediffs
1187N/A // will go mad !
1187N/A $("#revisions input[type=radio]").bind("click",togglediffs);
1281N/A togglediffs();
1187N/A}
1187N/A
1187N/Afunction get_annotations() {
1281N/A link = document.link + "?a=true";
1281N/A if (document.rev.length > 0) {
1281N/A link += '&' + document.rev;
1281N/A }
1281N/A hash = "&h=" + window.location.hash.substring(1, window.location.hash.length);
1281N/A window.location = link + hash;
1187N/A}
1187N/A
1187N/Afunction toggle_annotations() {
1281N/A $("span").each(
1281N/A function() {
1281N/A if (this.className == 'blame') {
1281N/A this.className = 'blame-hidden';
1281N/A } else if (this.className == 'blame-hidden') {
1281N/A this.className = 'blame';
1281N/A }
1281N/A }
1281N/A );
1187N/A}
1187N/A
1187N/A/** list.jsp */
1187N/A
1187N/A/**
1187N/A * Initialize defaults for list.jsp
1187N/A */
1187N/Afunction pageReadyList() {
1281N/A document.sym_div_width = 240;
1281N/A document.sym_div_height_max = 480;
1281N/A document.sym_div_top = 100;
1281N/A document.sym_div_left_margin = 40;
1281N/A document.sym_div_height_margin = 40;
1281N/A document.highlight_count = 0;
1281N/A $(window).resize(function() {
1281N/A if (document.sym_div_shown == 1) {
1281N/A document.sym_div.style.left = get_sym_div_left() + "px";
1281N/A document.sym_div.style.height = get_sym_div_height() + "px";
1281N/A }
1281N/A });
1187N/A}
1187N/A
1187N/A/* ------ Navigation window for definitions ------ */
1187N/A/**
1187N/A * Create the Navigation toggle link as well as its contents.
1187N/A */
1187N/Afunction get_sym_list_contents() {
1281N/A // var contents = "<input id=\"input_highlight\" name=\"input_highlight\"
1281N/A // class=\"q\"/>";
1281N/A // contents += "&nbsp;&nbsp;";
1281N/A // contents += "<b><a href=\"#\" onclick=\"javascript:add_highlight();return
1281N/A // false;\" title=\"Add highlight\">Highlight</a></b><br/>";
1281N/A var contents =
1281N/A "<a href=\"#\" onclick=\"javascript:lsttoggle();\">[Close]</a><br/>"
1281N/A if (typeof get_sym_list != 'function') {
1281N/A return contents;
1281N/A }
1187N/A
1281N/A var symbol_classes = get_sym_list();
1281N/A for ( var i = 0; i < symbol_classes.length; i++) {
1281N/A if (i > 0) {
1281N/A contents += "<br/>";
1281N/A }
1281N/A var symbol_class = symbol_classes[i];
1281N/A var class_name = symbol_class[1];
1281N/A var symbols = symbol_class[2];
1281N/A contents += "<b>" + symbol_class[0] + "</b><br/>";
1187N/A
1281N/A for (var j = 0; j < symbols.length; j++) {
1281N/A var symbol = symbols[j][0];
1281N/A var line = symbols[j][1];
1281N/A contents += "<a href=\"#" + line + "\" class=\"" + class_name + "\">"
1281N/A + escape_html(symbol) + "</a><br/>";
1281N/A }
1281N/A }
1187N/A
1281N/A return contents;
1187N/A}
1187N/A
1187N/Afunction escape_html(string) {
1281N/A return string.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
1187N/A}
1187N/A
1187N/Afunction get_sym_div_left() {
1281N/A document.sym_div_left = $(window)
1281N/A .width() - (document.sym_div_width + document.sym_div_left_margin);
1281N/A return document.sym_div_left;
1187N/A}
1187N/A
1187N/Afunction get_sym_div_height() {
1281N/A document.sym_div_height = $(window)
1281N/A .height() - document.sym_div_top - document.sym_div_height_margin;
1187N/A
1281N/A if (document.sym_div_height > document.sym_div_height_max) {
1281N/A document.sym_div_height = document.sym_div_height_max;
1281N/A }
1281N/A return document.sym_div_height;
1187N/A}
1187N/A
1187N/Afunction get_sym_div_top() {
1281N/A return document.sym_div_top;
1187N/A}
1187N/A
1187N/Afunction get_sym_div_width() {
1281N/A return document.sym_div_width;
1187N/A}
1187N/A
1187N/A/**
1187N/A * Toggle the display of the 'Navigation' window used to highlight definitions.
1187N/A */
1187N/Afunction lsttoggle() {
1281N/A if (document.sym_div == null) {
1281N/A document.sym_div = document.createElement("div");
1281N/A document.sym_div.id = "sym_div";
1187N/A
1281N/A document.sym_div.className = "sym_list_style";
1281N/A document.sym_div.style.margin = "0px auto";
1281N/A document.sym_div.style.width = get_sym_div_width() + "px";
1281N/A document.sym_div.style.height = get_sym_div_height() + "px";
1281N/A document.sym_div.style.top = get_sym_div_top() + "px";
1281N/A document.sym_div.style.left = get_sym_div_left() + "px";
1187N/A
1281N/A document.sym_div.innerHTML = get_sym_list_contents();
1187N/A
1281N/A document.body.appendChild(document.sym_div);
1281N/A document.sym_div_shown = 1;
1281N/A } else if (document.sym_div_shown == 1) {
1281N/A document.sym_div.className = "sym_list_style_hide";
1281N/A document.sym_div_shown = 0;
1281N/A } else {
1281N/A document.sym_div.style.height = get_sym_div_height() + "px";
1281N/A document.sym_div.style.width = get_sym_div_width() + "px";
1281N/A document.sym_div.style.top = get_sym_div_top() + "px";
1281N/A document.sym_div.style.left = get_sym_div_left() + "px";
1281N/A document.sym_div.className = "sym_list_style";
1281N/A document.sym_div_shown = 1;
1281N/A }
1187N/A}
1187N/A
1187N/A/**
1187N/A * Toggle the display of line numbers.
1187N/A */
1187N/Afunction lntoggle() {
1281N/A $("a").each(
1281N/A function() {
1281N/A if (this.className == 'l' || this.className == 'hl') {
1281N/A this.className = this.className + '-hide';
1281N/A this.setAttribute("tmp", this.innerHTML);
1281N/A this.innerHTML = '';
1281N/A } else if (this.className == 'l-hide'
1281N/A || this.className == 'hl-hide')
1281N/A {
1281N/A this.innerHTML = this.getAttribute("tmp");
1281N/A this.className = this.className.substr(0, this.className
1281N/A .indexOf('-'));
1281N/A }
1281N/A });
1187N/A}
1187N/A
1187N/A/* ------ Highlighting ------ */
1187N/A/**
1187N/A * An expensive Highlighter:
1187N/A * Note: It will replace link's href contents as well, be careful.
1187N/A */
1187N/A/* Not used.
1281N/Afunction HighlightKeywordsFullText(keywords) {
1281N/A var el = $("body");
1281N/A $(keywords).each(
1281N/A function() {
1281N/A var pattern = new RegExp("("+this+")", ["gi"]);
1281N/A var rs = "<span style='background-color:#FFFF00;font-weight:bold;'"
1281N/A + ">$1</span>";
1281N/A el.html(el.html().replace(pattern, rs));
1281N/A }
1281N/A );
1281N/A // HighlightKeywordsFullText(["nfstcpsock"]);
1187N/A}
1187N/A*/
1187N/A
1187N/A/**
1187N/A * Highlight keywords by changeing the style of matching tags.
1187N/A */
1187N/Afunction HighlightKeyword(keyword) {
1281N/A var high_colors = [ "#ffff66", "#ffcccc", "#ccccff", "#99ff99", "#cc66ff" ];
1281N/A var pattern = "a:contains('" + keyword + "')";
1281N/A $(pattern).css({
1281N/A 'text-decoration' : 'underline',
1281N/A 'background-color' : high_colors[document.highlight_count
1281N/A % high_colors.length],
1281N/A 'font-weight' : 'bold'
1281N/A });
1281N/A document.highlight_count++;
1187N/A}
1187N/A//Test: HighlightKeyword('timeval');
1187N/A
1187N/A/**
1187N/A * Highlight the text given as value of the element with the ID "input_highlight" .
1187N/A * @see HighlightKeyword
1187N/A */
1187N/Afunction add_highlight() {
1281N/A var tbox = document.getElementById('input_highlight');
1281N/A HighlightKeyword(tbox.value);
1187N/A}
1187N/A
1187N/Afunction toggle_filelist() {
1281N/A $("span").each(
1281N/A function() {
1281N/A if (this.className == "filelist") {
1281N/A this.setAttribute("style", "display: none;");
1281N/A this.className = "filelist-hidden";
1281N/A } else if (this.className == "filelist-hidden") {
1281N/A this.setAttribute("style", "display: inline;");
1281N/A this.className = "filelist";
1281N/A }
1281N/A }
1281N/A );
1187N/A}
1187N/A
1421N/Afunction toggle_revtags() {
1421N/A $("tr").each(
1421N/A function() {
1421N/A if (this.className == "revtags") {
1421N/A this.setAttribute("style", "display: none;");
1421N/A this.className = "revtags-hidden";
1421N/A } else if (this.className == "revtags-hidden") {
1421N/A this.setAttribute("style", "display: table-row;");
1421N/A this.className = "revtags";
1421N/A }
1421N/A }
1421N/A );
1421N/A $("span").each(
1421N/A function() {
1421N/A if (this.className == "revtags") {
1421N/A this.setAttribute("style", "display: none;");
1421N/A this.className = "revtags-hidden";
1421N/A } else if (this.className == "revtags-hidden") {
1421N/A this.setAttribute("style", "display: inline;");
1421N/A this.className = "revtags";
1421N/A }
1421N/A }
1421N/A );
1421N/A}
1421N/A
1187N/Afunction togglediffs() {
1281N/A var cr2 = false;
1281N/A var cr1 = false;
1281N/A $("#revisions input[type=radio]").each(
1281N/A function() {
1281N/A if (this.name=="r1") {
1281N/A if (this.checked) {
1281N/A cr1 = true;
1281N/A return true;
1281N/A }
1281N/A if (cr2) {
1281N/A this.disabled = ''
1281N/A } else {
1281N/A this.disabled = 'true'
1281N/A }
1281N/A } else if (this.name=="r2") {
1281N/A if (this.checked) {
1281N/A cr2=true;
1281N/A return true;
1281N/A }
1281N/A if (!cr1) {
1281N/A this.disabled = ''
1281N/A } else {
1281N/A this.disabled = 'true'
1281N/A }
1281N/A }
1281N/A }
1281N/A );
1187N/A}
1187N/A
1187N/Afunction selectAllProjects() {
1281N/A $("#project *").attr("selected", "selected");
1187N/A}
1187N/A
1187N/Afunction invertAllProjects() {
1281N/A $("#project *").each(
1281N/A function() {
1281N/A if ($(this).attr("selected")) {
1281N/A $(this).removeAttr("selected")
1281N/A } else {
1281N/A $(this).attr("selected", "true");
1281N/A }
1281N/A }
1281N/A );
1187N/A}
1187N/A
1187N/Afunction goFirstProject() {
1281N/A var selected=$.map($('#project :selected'), function(e) {
1281N/A return $(e).text();
1281N/A });
1281N/A window.location = document.xrefPath + '/' + selected[0];
1187N/A}
1187N/A
1342N/Afunction clearSearchFrom() {
1342N/A $("#sbox :input[type=text]").each(
1342N/A function() {
1342N/A $(this).attr("value", "");
1342N/A }
1342N/A );
1342N/A $("#project *").each(
1342N/A function() {
1342N/A if ($(this).attr("selected")) {
1342N/A $(this).removeAttr("selected")
1342N/A }
1342N/A }
1342N/A );
1342N/A}
1342N/A
1187N/Afunction checkEnter(event) {
1342N/A concat='';
1342N/A $("#sbox :input[type=text]").each(
1342N/A function() {
1342N/A concat+=$.trim($(this).val());
1342N/A }
1342N/A );
1342N/A if (event.keyCode == '13' && concat=='')
1281N/A {
1281N/A goFirstProject();
1281N/A } else if (event.keyCode == '13') {
1342N/A $("#sbox").submit();
1281N/A }
1421N/A}