utils.js revision dab33d94273a0b00747cffdb96bb7a4cb30ecf8c
/*
* 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.
*/
(function(window, $) {
var spaces = function () {
var inner = {
self: this,
initialized: false,
/**
* Mouse selection event
* - upon a user's selection triggers a select event
*/
mouse: {
dragging: false,
init: function () {
var that = this
}).mousemove(function(e){
}).mouseup(function(e){
if(wasDragging) {
}
}).dblclick(function(e){
//$(document).trigger("select")
});
},
},
defaults: {
"selector": "a.l, a.hl",
"parent": "div#src pre",
"selectedClass": "selected",
"sourceContainer": "pre",
},
options: {},
});
},
/**
* @returns {Boolean} if client is IE
*/
ie: function() {
return true;
return false;
},
getSelection: function () {
if (window.getSelection)
return window.getSelection()
return null
},
/**
* Select closest element giben by options.selector to the actual
* element
*
* @param {jQuery Object} $el actual element
* @param {boolean} next direction
* @param {boolean} last if it is the last element in array
* @param {int} depth max distance from the path between the actual
* element and the root element
* @returns {Object} of {element found, used given direction}
*/
}
var $result = null
var parentDepth = 10
// scan every previous parent up to partentDepth
// and scan every #depth nodes around a particular parent
parentDepth >= 0 ) {
if(!next) {
// scan #depth previous nodes if they are desired
}
} else {
// scan #depth next nodes if they are desired
}
}
// going level up
parentDepth --;
}
// no luck in parents -> find links within this node
if(last) {
} else {
}
}
return { "element": null, "directionUsed": false }
},
/**
* Handle select event by extracting a range, element lookup,
* extending range to approximate bounds and updating range back
* to the client
*
* @param {Event} e
* @returns {undefined} nothing
*/
selectHandler: function(e) {
var selection = null
return
}
//nothing to process
return
}
// if there were more ranges, select the one which is inside
// the parent element
// default: div#src pre
var r = selection.getRangeAt(i)
range = r;
}
}
// clone range (so it works in chrome)
// finding closest starting node based on inner.options.selector
// by default it's the closest line link
if($start == null){
// not successful
// - no line link
// - range is larger than the whole source container
// find the first link in the source container
}
return
}
// probably on the same line
$end_indir = true
} else {
// not on the same line so find closest node according to
// selector in next nodes
}
if($end == null){
// not successful
// - no line link
// - range is larger than the whole source container
// find the last link in the source container
$end_dir = false
}
return
}
if ($end_indir){
} else {
}
// extract contents (html now has dissapeared)
try {
// select all links in the content
// indent link by one space
} finally {
// even if there was an error fill the html back to the site
}
// clears the selection
// inserts the new updated range
},
init: function() {
// IE does not need this feature
return
}
} // inner
if ( inner.initialized )
return this;
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;
}
}
// starting spaces plugin
// TODO: disabled until fixed
// $.spaces.init()
$("#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();
}
}
}
// 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).attr("selected")) {
$(this).removeAttr("selected");
} else {
}
}
);
}
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 ;
}
}
}
}