utils.js revision 59c0e452797cd0654eec98e0ec85d7f5e314323d
/*
* 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;
}
}
/**
* Intelligence window plugin.
*
* Reworked to use Jquery in 2016
*/
var intelliWindow = function () {
var inner = {
// private
initialized: false,
// public
defaults: {
draggable: true,
appendDraggable: '#content',
selector: 'a.intelliWindow-symbol',
},
options: {},
// private
changeSymbol: function ($el) {
inner.$last_highlighted_current = $el.hasClass("symbol-highlighted") ? $el : inner.$last_highlighted_current
inner.modifyLinks();
},
modifyLinks: function () {
},
getSearchLink: function (query) {
},
getSymbolDescription: function (place) {
switch (place) {
case "def":
return "A declaration or definition.";
case "defined-in-file":
return "A symbol declared or defined in this file.";
case "undefined-in-file":
return "A symbol declared or defined elsewhere.";
default:
// should not happen
return "Something I have no idea about.";
}
},
getSymbols: function () {
},
}
}).addClass('symbol-highlighted')
},
unhighlight: function (symbol) {
if (inner.$last_highlighted_current &&
}
}).removeClass('symbol-highlighted')
},
unhighlightAll: function () {
},
} else {
}, 500);
}
},
scrollToNextElement: function (direction) {
var UP = -1;
var DOWN = 1;
switch (direction) {
case DOWN:
if ($highlighted.length) {
return;
}
}
break;
case UP:
if ($highlighted.length) {
return;
}
}
break;
default:
return;
}
},
});
},
toggle: function () {
},
hide: function () {
},
show: function () {
},
determinePosition: function () {
var position = {}
} else {
}
} else {
}
return position;
},
registerHandlers: function () {
})
switch (key) {
case 49: // 1
}
break;
case 50: // 2
}
break;
case 51: // 3
break;
case 110: // n
break;
case 98: // b
break;
default:
}
return true;
});
switch (key) {
case 27: // esc
break;
default:
}
return true;
});
inner.changeSymbol($(this));
});
},
e.preventDefault()
return false;
})
},
createWindow: function () {
var $firstList = $("<ul>")
$highlight = $("<a href=\"#\" title=\"Highlight\">" +
"<span>Highlight</span> <b class=\"symbol-name\"></b></a>")))
$unhighlight = $("<a href=\"#\" title=\"Unhighlight\">" +
"<span>Unhighlight</span> <b class=\"symbol-name\"></b></a>")))
$unhighlighAll = $("<a href=\"#\" title=\"Unhighlight all\">" +
"<span>Unhighlight all</span></a>")))
var $secondList = $("<ul>")
$("<a class=\"search-defs\" href=\"#\" target=\"_blank\">" +
"<span>Search for definitions of</span> <b class=\"symbol-name\"></b></a>")))
$("<a class=\"search-refs\" href=\"#\" target=\"_blank\">" +
"<span>Search for references of</span> <b class=\"symbol-name\"></b></a>")))
$("<a class=\"search-full\" href=\"#\" target=\"_blank\">" +
"<span>Do a full search with</span> <b class=\"symbol-name\"></b></a>")))
$("<a class=\"search-files\" href=\"#\" target=\"_blank\">" +
"<span>Search for file names that contain</span> <b class=\"symbol-name\"></b></a>")))
var $thirdList = $("<ul>")
$("<a class=\"search-google\" href=\"#\" target=\"_blank\">" +
"<span>Google</span> <b class=\"symbol-name\"></b></a>")))
var $controls = $("<div class=\"pull-right\">")
.append("<span class=\"pull-right\"> | </span>")
.append($("<div class=\"clearfix\">"))
return $("<div>")
.addClass('intelli-window')
.addClass('diff_navigation_style')
.hide()
.append($("<hr>"))
.append($("<hr>"))
},
init: function () {
if (inner.initialized) {
return
}
inner.initialized = true
$.ajax({
dataType: 'script',
cache: true
}).done(function () {
helper: 'clone',
start: function () {
$(this).hide();
},
},
}
});
}).fail(function () {
});
}
}
};
}
};
$("#dirlist").tablesorter({
cancelSelection: true,
headers: {
1: {
sorter: 'text'
},
3: {
sorter: 'dates'
},
4: {
sorter: 'groksizes'
}
}
});
// intelligence window plugin
$("#contextpath").each(function() {
$.intelliWindow.init();
return false
})
// starting spaces plugin
$("#sbox input[type='submit']").click(function (e) {
})
var searchableOptionListOptions = {
maxHeight: '300px',
showSelectionBelowList: false,
showSelectAll: false,
maxShow: 30,
resultsContainer: $("#ltbl"),
events: {
// override the default onScroll positioning event if neccessary
onScroll: function () {
var posY = this.$input.offset().top - this.config.scrollTarget.scrollTop() + this.$input.outerHeight(),
selectionContainerWidth = this.$innerContainer.outerWidth(false) - parseInt(this.$selectionContainer.css('border-left-width'), 10) - parseInt(this.$selectionContainer.css('border-right-width'), 10);
// container has a certain width
// make selection container a bit wider
} else {
// no border radius on top
this.$selectionContainer
if (this.$actionButtons) {
this.$actionButtons
}
}
this.$selectionContainer
}
}
};
});
}
}
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() {
}
function deselectAllProjects(){
}
function clearSearchFrom() {
$("#sbox input[type='text']").each(function () {
$(this).val("");
});
}
var scope_visible = 0;
var scope_text = '';
/**
* Fold or unfold a function definition.
*/
.children()
.first()
.toggleClass('unfold-icon')
.toggleClass('fold-icon')
}
/**
* 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() {
var $scope_cnt_el = $('#scope_content');
if ($(c).is('.l, .hl')) {
return;
}
}
}