utils.js revision bb8db105b282dda9446815b09b97e46f5bd21ac4
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* Portions Copyright 2011 Jens Elkner.
*/
/**
* Spaces plugin.
*
* Inserts a dummy space between line number and the text so that on copy-paste
* the white space is preserved.
*
* Internally listens on scroll events and autofills the spaces only for the visible
* elements.
*
* IMPORTANT: This plugin is strictly dependent on ascending order of lines
* and on their attribute "name". It performs a binary search which boosts performance
* of this plugin for really long files.
*
* @author Krystof Tulinger
*/
(function (w, $) {
var spaces = function () {
var inner = {
defaults: {
interval: 750,
selector: "a.l, a.hl",
$parent: null,
callback: function () {
if (!$(this).hasClass("selected")) {
$(this).addClass("selected");
}
}
},
options: {},
$collection: $(),
initialized: false,
lock: false,
var lo = 0,
mid,
cmp;
if (cmp === 0) {
return mid;
} else if (cmp < 0) {
} else {
}
}
return -1;
},
handleScrollEvent: function () {
var expectations = {
// the first element in viewport
Math.abs(
) / myHeight
),
// the last element in viewport
(Math.abs(
) + parentHeight
) / myHeight
),
};
var indices = {
start: 0,
};
};
/** cutoffs */
/** calling callback for every element in the viewport */
}
},
init: function () {
if (inner.initialized) {
return;
}
return;
}
var scrollHandler = function (e) {
return;
}
};
.scroll() // fire the event if user has not scrolled
inner.initialized = true;
}
};
return this;
}
};
(function(window, $) {
var hash = function () {
var inner = {
self: this,
initialized: false,
highlighted: [],
defaults: {
highlightedClass: 'target',
linkSelectorTemplate: '{parent} a[name={n}]',
clickSelector: '{parent} a.l, {parent} a.hl',
parent: 'div#src',
autoScroll: true,
autoScrollDuration: 500,
tooltip: true
},
options: {},
$tooltip: null,
bindClickHandler: function() {
if(e.shiftKey) {
// shift pressed
if(!val){
return false
}
if(l.length == 2) {
} else if ( l.length == 1){
}
return false
}
return true
})
},
getHashParts: function (hash) {
return hash;
},
getLinesParts: function ( hashPart ) {
return hashPart;
return []
},
if(p.length == 2) {
var l = [];
l.push(i);
return l;
} else if (p.length == 1){
return [ p[0] ]
}
return [];
},
reload: function(e){
// remove color
}
inner.highlighted = []
// not a case of line highlighting
return
}
// color
"n": lines[i] } );
}
},
: match
;
});
},
},
scroll: function (){
return
$("#content").animate({
n: line
}
},
tooltip: function() {
return
$("<div>Did you know? You can select a range of lines<br /> by clicking on the other while holding shift key.</div>")
.appendTo($("body"))
.hide()
.addClass("tooltip")
.addClass("diff_navigation_style")
.click(function(e) {
return
// show box
var $el = $(this)
setTimeout(function () {
.show()
.stop()
.fadeIn()
.fadeOut( 5000 )
.offset({
});
}, 300);
})
}
} // inner
if ( inner.initialized ) {
return this;
}
inner.initialized = true
return this;
}
}
$("#dirlist").tablesorter({
cancelSelection: true,
headers: {
1: {
sorter: 'text'
},
3: {
sorter: 'dates'
},
4: {
sorter: 'groksizes'
}
}
});
// starting spaces plugin
$("#sbox input[type='submit']").click(function (e) {
})
});
}
}
for(var i in this.domReady) {
}
});
/**
* Resize the element with the ID 'content' so that it fills the whole browser
* window (i.e. the space between the header and the bottom of the window) and
* thus get rid off the scrollbar in the page header.
*/
function resizeContent() {
}
}
/**
* Get a parameter value from the URL.
*
* @param p the name of the parameter
* @return the decoded value of parameter p
*/
function getParameter(p) {
// First split up the parameter list. That is, transform from
// ?a=b&c=d
// to
// [ ["a", "b"], ["c","d"] ]
function (x) { return x.split("="); });
}
// Then look for the parameter.
for (var i in params) {
}
}
return undefined;
}
function domReadyMast() {
var h = getParameter("h");
if (h && h !== "") {
} else {
$('#content').focus();
}
}
$('a.r').tooltip({
content: function () {
var element = $(this);
return "";
var $el = $("<dl>");
continue;
var $dd = $("<dd>");
});
}
return $el;
},
})
//$('a.r').tooltip({ left: 5, showURL: false });
}
// When we move to a version of XHTML that supports the onscroll
// attribute in the div element, we should add an onscroll attribute
// in the generated XHTML in mast.jsp. For now, set it with jQuery.
}
function pageReadyMast() {
if ($('#whole_header') != null && $('#content') != null) {
}
function() {
}
);
}
function domReadyMenu() {
/*
$("#project").autocomplete(projects, {
minChars: 0,
multiple: true,
multipleSeparator: ",",
//mustMatch: true,
matchContains: "word",
max: 200,
cacheLength:20,
//autoFill: false,
formatItem: function(row, i, max) {
return (row != null) ? i + "/" + max + ": " + row[0] : "";
},
formatMatch: function(row, i, max) {
return (row != null) ? row[0] : "";
},
formatResult: function(row) {
return (row != null) ? row[0] : "";
},
width: "300px"
});
*/
// TODO Bug 11749
// var p = document.getElementById('project');
// p.setAttribute("autocomplete", "off");
}
function domReadyHistory() {
// start state should ALWAYS be: first row: r1 hidden, r2 checked ;
// second row: r1 clicked, (r2 hidden)(optionally)
// I cannot say what will happen if they are not like that, togglediffs
// will go mad !
togglediffs();
togglerevs();
}
function get_annotations() {
}
// If a line is highlighted when "annotate" is clicked, we want to
// preserve the highlighting, but we don't want the page to scroll
// to the highlighted line. So put the line number in a URL parameter
// instead of in the hash.
link += "&h=";
}
}
function toggle_annotations() {
}
/** list.jsp */
/**
* Initialize defaults for list.jsp
*/
function pageReadyList() {
}
});
}
/* ------ Navigation window for definitions ------ */
/**
* Create the Navigation toggle link as well as its contents.
*/
function get_sym_list_contents() {
// var contents = "<input id=\"input_highlight\" name=\"input_highlight\"
// class=\"q\"/>";
// contents += " ";
// contents += "<b><a href=\"#\" onclick=\"javascript:add_highlight();return
// false;\" title=\"Add highlight\">Highlight</a></b><br/>";
var contents =
"<a href=\"#\" onclick=\"javascript:lsttoggle();\">[Close]</a><br/>"
if (typeof get_sym_list != 'function') {
return contents;
}
var symbol_classes = get_sym_list();
if (i > 0) {
contents += "<br/>";
}
var symbol_class = symbol_classes[i];
contents += "<a href=\"#" + line + "\" class=\"" + class_name + "\" onclick=\"lnshow(); return true;\">"
}
}
return contents;
}
function escape_html(string) {
}
function get_sym_div_left() {
return document.sym_div_left;
}
function get_sym_div_height() {
}
return document.sym_div_height;
}
function get_sym_div_top() {
return document.sym_div_top;
}
function get_sym_div_width() {
return document.sym_div_width;
}
/**
* Toggle the display of the 'Navigation' window used to highlight definitions.
*/
function lsttoggle() {
} else {
}
}
/**
* Toggle the display of line numbers.
*/
function lntoggle() {
}
function lnshow() {
}
/* ------ Highlighting ------ */
/**
* An expensive Highlighter:
* Note: It will replace link's href contents as well, be careful.
*/
/* Not used.
function HighlightKeywordsFullText(keywords) {
var el = $("body");
$(keywords).each(
function() {
var pattern = new RegExp("("+this+")", ["gi"]);
var rs = "<span style='background-color:#FFFF00;font-weight:bold;'"
+ ">$1</span>";
}
);
// HighlightKeywordsFullText(["nfstcpsock"]);
}
*/
/**
* Highlight keywords by changeing the style of matching tags.
*/
function HighlightKeyword(keyword) {
'text-decoration' : 'underline',
% high_colors.length],
'font-weight' : 'bold'
});
}
//Test: HighlightKeyword('timeval');
/**
* Highlight the text given as value of the element with the ID "input_highlight" .
* @see HighlightKeyword
*/
function add_highlight() {
}
function toggle_filelist() {
$("div").each(
function() {
if (this.className == "filelist") {
this.className = "filelist-hidden";
} else if (this.className == "filelist-hidden") {
this.className = "filelist";
}
}
);
}
function toggle_revtags() {
$("tr").each(
function() {
if (this.className == "revtags") {
this.className = "revtags-hidden";
} else if (this.className == "revtags-hidden") {
this.className = "revtags";
}
}
);
$("span").each(
function() {
if (this.className == "revtags") {
this.className = "revtags-hidden";
} else if (this.className == "revtags-hidden") {
this.className = "revtags";
}
}
);
}
function togglediffs() {
var cr2 = false;
var cr1 = false;
$("#revisions input[type=radio]").each(
function() {
if (this.name=="r1") {
if (this.checked) {
cr1 = true;
return true;
}
if (cr2) {
this.disabled = ''
} else {
this.disabled = 'true'
}
} else if (this.name=="r2") {
if (this.checked) {
cr2=true;
return true;
}
if (!cr1) {
this.disabled = ''
} else {
this.disabled = 'true'
}
}
}
);
}
/**
* Function to toggle revision message length for long revision messages
*/
function togglerevs() {
$(".rev-toggle-a").click(function() {
if (toggleState == "less") {
$(this).html("... show less");
}
else if (toggleState == "more") {
$(this).html("show more ...");
}
return false;
});
}
function selectAllProjects() {
}
function invertAllProjects() {
$("#project *").each(
function() {
if ($(this).prop("selected")) {
$(this).prop("selected", false);
} else {
$(this).prop("selected", true);
}
}
);
}
function goFirstProject(e) {
return $(e).text();
});
if(! e.shiftKey) {
}
}
}
function clearSearchFrom() {
$("#sbox :input[type=text]").each(
function() {
}
);
}
function checkEnter(event) {
concat='';
$("#sbox :input[type=text]").each(
function() {
}
);
{
$("#sbox").submit();
}
}
// Intelligence Window code starts from here
};
return true;
}
}
}
(bgcolor === "rgb(255, 215, 0)" || bgcolor === "rgb(255,215,0)" || bgcolor === "#ffd700"); // gold. the last two cover IE
})
} else {
}
}
return true;
});
}
if (!document.intelliWindow) {
}
var header = [
].join("");
}
function showIntelliWindow() {
var top;
var left;
} else {
}
} else {
}
}
function createIntelliWindow() {
}
function hideIntelliWindow() {
}
function createCapitionHTML() {
return '<a onclick="hideIntelliWindow()">[Close]</a><br/><b>Intelligence Window</b><br/>';
}
function createSymbolHTML(symbol) {
}
function createDescriptionHTML(symbolType) {
switch (symbolType) {
case "def":
return "A declaration or definition.<hr/>";
case "defined-in-file":
return "A symbol declared or defined in this file.<hr/>";
case "undefined-in-file":
return "A symbol declared or defined elsewhere.<hr/>";
default:
// should not happen
return "Something I have no idea about.<hr/>";
}
}
return [
"In current file:<br/><ul>",
"</i></b></a>.</li>",
"</i></b></a>.</li>",
"<li><a onclick=\"unhighlightAll()\">Unhighlight all.</li></ul>",
"')\">Search for definitions of <i><b>", symbol,
"</b></i>.</a></li>",
"')\">Search for references of <i><b>", symbol,
"</b></i>.</a></li>",
"')\">Do a full search with <i><b>", symbol,
"</b></i>.</a></li>",
"')\">Search for file names that contain <i><b>", symbol,
"</b></i>.</a></li></ul>",
].join("");
}
function highlightSymbol(symbol) {
})
return false;
}
function unhighlightSymbol(symbol) {
})
return false;
}
function unhighlightAll() {
return bgcolor === "rgb(255, 215, 0)" || bgcolor === "rgb(255,215,0)" || bgcolor === "#ffd700"; // gold. the last two cover IE
return false;
}
return false;
}
function googleSymbol(symbol) {
return false;
}
function escapeSingleQuote(string) {
}
var scope_visible = 0;
var scope_text = '';
/**
* Fold or unfold a function definition.
*/
}
/**
* Function that is called when the #content div element is scrolled. Checks
* if the top of the page is inside a function scope. If so, update the
* scope element to show the name of the function and a link to its definition.
*/
function scope_on_scroll() {
prev = c;
var par = c.parentNode;
if (par === null) {
return ;
}
}
}
}