utils.js revision c6d2bb78af2f7ed5cdc80dec65d0d084cd035b22
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/*
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * CDDL HEADER START
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * The contents of this file are subject to the terms of the
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Common Development and Distribution License (the "License").
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * You may not use this file except in compliance with the License.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * See LICENSE.txt included in this distribution for the specific
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * language governing permissions and limitations under the License.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * When distributing Covered Code, include this CDDL HEADER in each
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * file and include the License file at LICENSE.txt.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * If applicable, add the following below this CDDL HEADER, with the
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * fields enclosed by brackets "[]" replaced with your own identifying
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * information: Portions Copyright [yyyy] [name of copyright owner]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * CDDL HEADER END
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/*
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Portions Copyright 2011 Jens Elkner.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/**
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Spaces plugin.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Inserts a dummy space between line number and the text so that on copy-paste
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * the white space is preserved.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Internally listens on scroll events and autofills the spaces only for the visible
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * elements.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * IMPORTANT: This plugin is strictly dependent on ascending order of lines
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * and on their attribute "name". It performs a binary search which boosts performance
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * of this plugin for really long files.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * @author Krystof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger(function (w, $) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var spaces = function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var inner = {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger defaults: {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger interval: 750,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger selector: "a.l, a.hl",
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $parent: null,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger callback: function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (!$(this).hasClass("selected")) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(this).addClass("selected");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(this).text($(this).text() + " ");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger options: {},
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $collection: $(),
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger initialized: false,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger lock: false,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger binarySearch: function (array, key, compare) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var lo = 0,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger hi = array.length - 1,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger mid,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger element,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger cmp;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger while (lo <= hi) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger mid = ((lo + hi) >> 1);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger cmp = compare(array[mid], key)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (cmp === 0) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return mid;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger } else if (cmp < 0) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger lo = mid + 1;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger } else {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger hi = mid - 1;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return -1;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger handleScrollEvent: function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.lock = false;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var expectations = {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // the first element in viewport
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger start: Math.floor(inner.options.$parent.scrollTop() / inner.$collection.first().height()),
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // the last element in viewport
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger end: Math.ceil((inner.options.$parent.scrollTop()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger + inner.options.$parent.height()) / inner.$collection.first().height())
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger };
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var indices = {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger start: 0,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger end: inner.$collection.length
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger };
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var cmp = function (a, key) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return $(a).attr("name") - key; // comparing the "name" attribute with the desired value
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger };
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger indices.start = inner.binarySearch(inner.$collection, expectations.start, cmp);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger indices.end = inner.binarySearch(inner.$collection, expectations.end, cmp);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger /** cutoffs */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger indices.start = Math.max(0, indices.start);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger indices.start = Math.min(inner.$collection.length - 1, indices.start);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (indices.end === -1)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger indices.end = inner.$collection.length - 1;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger indices.end = Math.min(inner.$collection.length - 1, indices.end);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger /** calling callback for every element in the viewport */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for (var i = indices.start; i <= indices.end; i++) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.options.callback.apply(inner.$collection[i])
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger init: function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (inner.initialized) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.$collection = inner.options.$parent.find(inner.options.selector);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (inner.$collection.length <= 0) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var scrollHandler = function (e) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (inner.lock) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.lock = true;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger setTimeout(inner.handleScrollEvent, inner.options.interval);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger };
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.options.$parent.scroll(scrollHandler)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .resize(scrollHandler)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.initialized = true;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger };
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger this.init = function (options) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.options = $.extend({}, inner.defaults, {$parent: $("#content")}, options)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.init();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return this;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger };
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $.spaces = new ($.extend(spaces, $.spaces ? $.spaces : {}));
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger})(window, window.jQuery);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger(function(window, $) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var hash = function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var inner = {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger self: this,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger initialized: false,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger highlighted: [],
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger defaults: {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger highlightedClass: 'target',
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger linkSelectorTemplate: '{parent} a[name={n}]',
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger clickSelector: '{parent} a.l, {parent} a.hl',
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger parent: 'div#src',
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger autoScroll: true,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger autoScrollDuration: 500,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger tooltip: true
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger options: {},
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $tooltip: null,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger bindClickHandler: function() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(inner.format(inner.options.clickSelector, {parent: inner.options.parent})).click (function (e){
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(e.shiftKey) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // shift pressed
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var val = inner.toInt($(this).attr("name"))
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(!val){
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return false
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var l = inner.getLinesParts(window.location.hash)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(l.length == 2) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger window.location.hash = "#" + Math.min(l[0], val) + "-" + Math.max(val, l[1])
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger } else if ( l.length == 1){
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger window.location.hash = "#" + Math.min(l[0], val) + "-" + Math.max(l[0], val)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return false
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return true
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger })
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger getHashParts: function (hash) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(!hash || hash == "")
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return hash;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return (hash = hash.split("#")).length > 1 ? hash[1] : "";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger getLinesParts: function ( hashPart ) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger hashPart = inner.getHashParts(hashPart)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (!hashPart || hashPart == "")
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return hashPart;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var s = hashPart.split("-")
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(s.length > 1 && inner.toInt(s[0]) && inner.toInt(s[1]))
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return [ inner.toInt(s[0]), inner.toInt(s[1]) ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(s.length > 0 && inner.toInt(s[0]))
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return [ inner.toInt(s[0]) ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return []
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger lines: function (urlPart) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger p = inner.getLinesParts(urlPart)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(p.length == 2) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var l = [];
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for ( var i = Math.min(p[0],p[1]); i <= Math.max(p[0], p[1]); i ++ )
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger l.push(i);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return l;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger } else if (p.length == 1){
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return [ p[0] ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return [];
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger reload: function(e){
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for ( var i = 0; i < inner.highlighted.length; i ++ ) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // remove color
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.highlighted[i].removeClass(inner.options.highlightedClass)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.highlighted = []
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var lines = inner.lines(window.location.hash);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(lines.length < 1) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // not a case of line highlighting
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for ( var i = 0; i < lines.length; i ++ ) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // color
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var slc = inner.format(inner.options.linkSelectorTemplate, { "parent": inner.options.parent,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger "n": lines[i] } );
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var el = $(slc).addClass(inner.options.highlightedClass)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.highlighted.push(el)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger format: function(format) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var args = Array.prototype.slice.call(arguments, 1);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger args = args.length > 0 ? typeof args[0] === "object" ? args[0] : args : args;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return format.replace(/{([a-zA-Z0-9_-]+)}/g, function(match, number) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return typeof args[number] != 'undefined'
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger ? args[number]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger : match
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger ;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger toInt: function (string) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return parseInt(string)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger scroll: function (){
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(!inner.options.autoScroll)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var lines = inner.getLinesParts(window.location.hash);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(lines.length > 0) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var line = lines[0] // first line
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#content").animate({
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger scrollTop: $(inner.format(inner.options.linkSelectorTemplate, {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger parent: inner.options.parent,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger n: line
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger })).offset().top - $(inner.options.parent).offset().top
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }, inner.options.autoScrollDuration);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger tooltip: function() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(!inner.options.tooltip)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.$tooltip = inner.$tooltip ?
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.$tooltip :
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("<div>Did you know? You can select a range of lines<br /> by clicking on the other while holding shift key.</div>")
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .appendTo($("body"))
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .hide()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .addClass("tooltip")
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .addClass("diff_navigation_style")
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(inner.format(inner.options.clickSelector, {parent: inner.options.parent}))
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .click(function(e) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if(!inner.options.tooltip)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // show box
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var $el = $(this)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger setTimeout(function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.$tooltip
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .show()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .stop()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .fadeIn()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .fadeOut( 5000 )
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger .offset({
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger top: $el.offset().top + 20,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger left: $el.offset().left + $el.width() + 5
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }, 300);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.options.tooltip = false;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger })
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger } // inner
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger this.init = function (options) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if ( inner.initialized ) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return this;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.options = $.extend(inner.defaults, options, {})
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(window).on("hashchange", inner.reload)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.reload()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.tooltip()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.bindClickHandler()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.scroll()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger inner.initialized = true
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return this;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $.hash = new ($.extend(hash, $.hash ? $.hash : {}));
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}) (window, window.jQuery);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger$(document).ready(function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#content").scroll(scope_on_scroll);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#dirlist").tablesorter({
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger sortList: [[0, 0]],
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger cancelSelection: true,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger headers: {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger 1: {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger sorter: 'text'
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger 3: {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger sorter: 'dates'
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger 4: {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger sorter: 'groksizes'
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // starting spaces plugin
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $.spaces.init()
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $.hash.init({parent: "pre"})
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#sbox input[type='submit']").click(function (e) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#results > p.pagetitle").hide(); // description
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#results > p.slider").hide(); // pagination
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#results > h3").hide(); // error
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#results > table, #results > ul").hide(); // results + empty
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#results > table + p, #results > ul + p").hide(); // results + empty timing
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger })
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger});
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerdocument.pageReady = [];
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerdocument.domReady = [];
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerwindow.onload = function() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for(var i in document.pageReady) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.pageReady[i]();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger$(document).ready(function() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for(var i in this.domReady) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.domReady[i]();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger});
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/**
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Resize the element with the ID 'content' so that it fills the whole browser
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * window (i.e. the space between the header and the bottom of the window) and
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * thus get rid off the scrollbar in the page header.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction resizeContent() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (document.adjustContent != 0) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $('#content').css('top', $('body').outerHeight(true)).css('bottom', 0);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/**
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Get a parameter value from the URL.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger *
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * @param p the name of the parameter
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * @return the decoded value of parameter p
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction getParameter(p) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // First split up the parameter list. That is, transform from
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // ?a=b&c=d
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // to
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // [ ["a", "b"], ["c","d"] ]
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (getParameter.params === undefined) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger getParameter.params = window.location.search.substr(1).split("&").map(
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger function (x) { return x.split("="); });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var params = getParameter.params;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // Then look for the parameter.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for (var i in params) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (params[i][0] === p && params[i].length > 1) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return decodeURIComponent(params[i][1]);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return undefined;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction domReadyMast() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (!window.location.hash) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var h = getParameter("h");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (h && h !== "") {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger window.location.hash = h;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger } else {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $('#content').focus();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (document.annotate) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $('a.r').tooltip({
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger content: function () {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var element = $(this);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var title = element.attr("title") || ""
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var parts = title.split(/<br\/>(?=[a-zA-Z0-9]+:)/g);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (parts.length <= 0)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return "";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var $el = $("<dl>");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger for (var i = 0; i < parts.length; i++) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var definitions = parts[i].split(":");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (definitions.length < 2)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger continue;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("<dt>").text(definitions.shift().trim()).appendTo($el);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var $dd = $("<dd>");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $.each(definitions.join("").split("<br/>"), function (i, el) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $dd.append(el.trim());
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $dd.append($("<br/>"));
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $dd.appendTo($el);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return $el;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger })
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger //$('a.r').tooltip({ left: 5, showURL: false });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var toggle_js = document.getElementById('toggle-annotate-by-javascript');
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var toggle_ss = document.getElementById('toggle-annotate');
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger toggle_js.style.display = 'inline';
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger toggle_ss.style.display = 'none';
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // When we move to a version of XHTML that supports the onscroll
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // attribute in the div element, we should add an onscroll attribute
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // in the generated XHTML in mast.jsp. For now, set it with jQuery.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#content").scroll(scope_on_scroll);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction pageReadyMast() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.adjustContent = 0;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if ($('#whole_header') != null && $('#content') != null) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.adjustContent = 1;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger resizeContent();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(window).resize(
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger function() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger resizeContent();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger );
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction domReadyMenu() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var projects = document.projects;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var sbox = document.getElementById('sbox');
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/*
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#project").autocomplete(projects, {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger minChars: 0,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger multiple: true,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger multipleSeparator: ",",
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger //mustMatch: true,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger matchContains: "word",
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger max: 200,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger cacheLength:20,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger //autoFill: false,
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger formatItem: function(row, i, max) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return (row != null) ? i + "/" + max + ": " + row[0] : "";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger formatMatch: function(row, i, max) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return (row != null) ? row[0] : "";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger formatResult: function(row) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger return (row != null) ? row[0] : "";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger },
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger width: "300px"
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger });
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger*/
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // TODO Bug 11749
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // var p = document.getElementById('project');
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // p.setAttribute("autocomplete", "off");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction domReadyHistory() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // start state should ALWAYS be: first row: r1 hidden, r2 checked ;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // second row: r1 clicked, (r2 hidden)(optionally)
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // I cannot say what will happen if they are not like that, togglediffs
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // will go mad !
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $("#revisions input[type=radio]").click(togglediffs);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger togglediffs();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger togglerevs();
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction get_annotations() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger var link = window.location.pathname + "?a=true";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (document.rev) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger link += "&r=" + encodeURIComponent(document.rev);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (window.location.hash) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // If a line is highlighted when "annotate" is clicked, we want to
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // preserve the highlighting, but we don't want the page to scroll
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // to the highlighted line. So put the line number in a URL parameter
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger // instead of in the hash.
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger link += "&h=";
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger link += window.location.hash.substring(1, window.location.hash.length);
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger }
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger window.location = link;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction toggle_annotations() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(document.body).toggleClass("blame-hidden");
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger}
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/** list.jsp */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger/**
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger * Initialize defaults for list.jsp
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger */
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulingerfunction pageReadyList() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.sym_div_width = 240;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.sym_div_height_max = 480;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.sym_div_top = 100;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.sym_div_left_margin = 40;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.sym_div_height_margin = 40;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.highlight_count = 0;
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger $(window).resize(function() {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger if (document.sym_div_shown == 1) {
b4b45a7526fef6a514d6c746d80a05f898ba573dKryštof Tulinger document.sym_div.style.left = get_sym_div_left() + "px";
document.sym_div.style.height = get_sym_div_height() + "px";
}
});
}
/* ------ 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 += "&nbsp;&nbsp;";
// 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();
for ( var i = 0; i < symbol_classes.length; i++) {
if (i > 0) {
contents += "<br/>";
}
var symbol_class = symbol_classes[i];
var class_name = symbol_class[1];
var symbols = symbol_class[2];
contents += "<b>" + symbol_class[0] + "</b><br/>";
for (var j = 0; j < symbols.length; j++) {
var symbol = symbols[j][0];
var line = symbols[j][1];
contents += "<a href=\"#" + line + "\" class=\"" + class_name + "\" onclick=\"lnshow(); return true;\">"
+ escape_html(symbol) + "</a><br/>";
}
}
return contents;
}
function escape_html(string) {
return string.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
}
function get_sym_div_left() {
document.sym_div_left = $(window)
.width() - (document.sym_div_width + document.sym_div_left_margin);
return document.sym_div_left;
}
function get_sym_div_height() {
document.sym_div_height = $(window)
.height() - document.sym_div_top - document.sym_div_height_margin;
if (document.sym_div_height > document.sym_div_height_max) {
document.sym_div_height = document.sym_div_height_max;
}
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() {
if (document.sym_div == null) {
document.sym_div = document.createElement("div");
document.sym_div.id = "sym_div";
document.sym_div.className = "sym_list_style";
document.sym_div.style.margin = "0px auto";
document.sym_div.style.width = get_sym_div_width() + "px";
document.sym_div.style.height = get_sym_div_height() + "px";
document.sym_div.style.top = get_sym_div_top() + "px";
document.sym_div.style.left = get_sym_div_left() + "px";
document.sym_div.innerHTML = get_sym_list_contents();
document.body.appendChild(document.sym_div);
document.sym_div_shown = 1;
} else if (document.sym_div_shown == 1) {
document.sym_div.className = "sym_list_style_hide";
document.sym_div_shown = 0;
} else {
document.sym_div.style.height = get_sym_div_height() + "px";
document.sym_div.style.width = get_sym_div_width() + "px";
document.sym_div.style.top = get_sym_div_top() + "px";
document.sym_div.style.left = get_sym_div_left() + "px";
document.sym_div.className = "sym_list_style";
document.sym_div_shown = 1;
}
}
/**
* Toggle the display of line numbers.
*/
function lntoggle() {
$(document.body).toggleClass("lines-hidden");
}
function lnshow() {
$(document.body).removeClass("lines-hidden");
}
/* ------ 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>";
el.html(el.html().replace(pattern, rs));
}
);
// HighlightKeywordsFullText(["nfstcpsock"]);
}
*/
/**
* Highlight keywords by changeing the style of matching tags.
*/
function HighlightKeyword(keyword) {
var high_colors = [ "#ffff66", "#ffcccc", "#ccccff", "#99ff99", "#cc66ff" ];
var pattern = "a:contains('" + keyword + "')";
$(pattern).css({
'text-decoration' : 'underline',
'background-color' : high_colors[document.highlight_count
% high_colors.length],
'font-weight' : 'bold'
});
document.highlight_count++;
}
//Test: HighlightKeyword('timeval');
/**
* Highlight the text given as value of the element with the ID "input_highlight" .
* @see HighlightKeyword
*/
function add_highlight() {
var tbox = document.getElementById('input_highlight');
HighlightKeyword(tbox.value);
}
function toggle_filelist() {
$("div").each(
function() {
if (this.className == "filelist") {
this.setAttribute("style", "display: none;");
this.className = "filelist-hidden";
} else if (this.className == "filelist-hidden") {
this.setAttribute("style", "display: inline;");
this.className = "filelist";
}
}
);
}
function toggle_revtags() {
$("tr").each(
function() {
if (this.className == "revtags") {
this.setAttribute("style", "display: none;");
this.className = "revtags-hidden";
} else if (this.className == "revtags-hidden") {
this.setAttribute("style", "display: table-row;");
this.className = "revtags";
}
}
);
$("span").each(
function() {
if (this.className == "revtags") {
this.setAttribute("style", "display: none;");
this.className = "revtags-hidden";
} else if (this.className == "revtags-hidden") {
this.setAttribute("style", "display: inline;");
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() {
var toggleState = $(this).closest("p").attr("data-toggle-state");
var thisCell = $(this).closest("td");
if (toggleState == "less") {
$(this).closest("p").attr("data-toggle-state", "more");
thisCell.find(".rev-message-summary").addClass("rev-message-hidden");
thisCell.find(".rev-message-full").removeClass("rev-message-hidden");
$(this).html("... show less");
}
else if (toggleState == "more") {
$(this).closest("p").attr("data-toggle-state", "less");
thisCell.find(".rev-message-full").addClass("rev-message-hidden");
thisCell.find(".rev-message-summary").removeClass("rev-message-hidden");
$(this).html("show more ...");
}
return false;
});
}
function selectAllProjects() {
$("#project *").prop("selected", true);
}
function invertAllProjects() {
$("#project *").each(
function() {
if ($(this).prop("selected")) {
$(this).prop("selected", false);
} else {
$(this).prop("selected", true);
}
}
);
}
function goFirstProject(e) {
e = e || window.event
if($(e.target).is("option")) {
var selected=$.map($('#project :selected'), function(e) {
return $(e).text();
});
window.location = document.xrefPath + '/' + selected[0];
} else if ( $(e.target).is("optgroup") ) {
if(! e.shiftKey) {
$("#project :selected").prop("selected", false).change();
}
$(e.target).children().prop("selected", true).change();
}
}
function clearSearchFrom() {
$("#sbox :input[type=text]").each(
function() {
$(this).attr("value", "");
}
);
$("#type :selected").prop("selected", false);
}
function checkEnter(event) {
concat='';
$("#sbox :input[type=text]").each(
function() {
concat+=$.trim($(this).val());
}
);
if (event.keyCode == '13' && concat=='')
{
goFirstProject(event);
} else if (event.keyCode == '13') {
$("#sbox").submit();
}
}
// Intelligence Window code starts from here
document.onmousemove = function(event) {
event = event || window.event; // cover IE
document.intelliWindowMouseX = event.clientX;
document.intelliWindowMouseY = event.clientY;
};
$(document).keypress(function(e) {
if (document.activeElement.id === 'search' ||
typeof document.intelliWindow === 'undefined') {
return true;
}
if (e.which === 49) { // '1' pressed
if (document.intelliWindow.className === "intelli_window_style") {
hideIntelliWindow();
} else if (document.intelliWindow.className === "intelli_window_style_hide") {
showIntelliWindow();
}
}
if (e.which === 50) { // '2' pressed
var symbol = document.intelliWindow.symbol;
var highlighted_symbols_with_same_name = $("a").filter(function(index) {
var bgcolor = $(this).css("background-color");
return $(this).text() === symbol &&
(bgcolor === "rgb(255, 215, 0)" || bgcolor === "rgb(255,215,0)" || bgcolor === "#ffd700"); // gold. the last two cover IE
})
if (highlighted_symbols_with_same_name.length === 0) {
highlightSymbol(symbol);
} else {
unhighlightSymbol(symbol);
}
}
return true;
});
function onMouseOverSymbol(symbol, symbolType) {
updateIntelliWindow(symbol, symbolType);
}
function updateIntelliWindow(symbol, symbolType) {
if (!document.intelliWindow) {
createIntelliWindow();
}
var header = [
createCapitionHTML(),
createSymbolHTML(symbol),
createDescriptionHTML(symbolType),
].join("");
document.intelliWindow.innerHTML = header + createActionHTML(symbol, symbolType);
document.intelliWindow.symbol = symbol;
}
function showIntelliWindow() {
var iw = document.intelliWindow;
iw.className = "intelli_window_style";
var top;
var left;
if (document.intelliWindowMouseY + iw.offsetHeight + 20 > $(window).height()) {
top = $(window).height() - iw.offsetHeight - 20;
} else {
top = document.intelliWindowMouseY;
}
if (document.intelliWindowMouseX + iw.offsetWidth + 20 > $(window).width()) {
left = $(window).width() - iw.offsetWidth - 20;
} else {
left = document.intelliWindowMouseX;
}
iw.style.top = top + "px";
iw.style.left = left + "px";
}
function createIntelliWindow() {
document.intelliWindow = document.createElement("div");
document.intelliWindow.id = "intelli_win";
document.body.appendChild(document.intelliWindow);
hideIntelliWindow();
}
function hideIntelliWindow() {
document.intelliWindow.className = "intelli_window_style_hide";
}
function createCapitionHTML() {
return '<a onclick="hideIntelliWindow()">[Close]</a><br/><b>Intelligence Window</b><br/>';
}
function createSymbolHTML(symbol) {
return "<i><h2>" + symbol + "</h2></i>";
}
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/>";
}
}
function createActionHTML(symbol, symbolType) {
var escapedSymbol = escapeSingleQuote(symbol);
var project = $("input[name='project']").val();
return [
"In current file:<br/><ul>",
"<li><a onclick=\"highlightSymbol('", escapedSymbol, "')\">Highlight <b><i>", symbol,
"</i></b></a>.</li>",
"<li><a onclick=\"unhighlightSymbol('", escapedSymbol, "')\">Unhighlight <b><i>", symbol,
"</i></b></a>.</li>",
"<li><a onclick=\"unhighlightAll()\">Unhighlight all.</li></ul>",
"In project ", project, ":<br/><ul>",
"<li><a onclick=\"intelliWindowSearch('defs=', '", escapedSymbol, "', '", symbolType,
"')\">Search for definitions of <i><b>", symbol,
"</b></i>.</a></li>",
"<li><a onclick=\"intelliWindowSearch('refs=', '", escapedSymbol, "', '", symbolType,
"')\">Search for references of <i><b>", symbol,
"</b></i>.</a></li>",
"<li><a onclick=\"intelliWindowSearch('q=', '", escapedSymbol, "', '", symbolType,
"')\">Do a full search with <i><b>", symbol,
"</b></i>.</a></li>",
"<li><a onclick=\"intelliWindowSearch('path=', '", escapedSymbol, "', '", symbolType,
"')\">Search for file names that contain <i><b>", symbol,
"</b></i>.</a></li></ul>",
"<a onclick=\"googleSymbol('", escapedSymbol, "')\">Google <b><i>", symbol, "</i></b>.</a>"
].join("");
}
function highlightSymbol(symbol) {
var symbols_with_same_name = $("a").filter(function(index) {
return $(this).text() === symbol;
})
symbols_with_same_name.css("background-color", "rgb(255, 215, 0)"); // gold
return false;
}
function unhighlightSymbol(symbol) {
var symbols_with_same_name = $("a").filter(function(index) {
return $(this).text() === symbol;
})
symbols_with_same_name.css("background-color", "rgb(255, 255, 255)"); // white
return false;
}
function unhighlightAll() {
$("a").filter(function(index) {
var bgcolor = $(this).css("background-color");
return bgcolor === "rgb(255, 215, 0)" || bgcolor === "rgb(255,215,0)" || bgcolor === "#ffd700"; // gold. the last two cover IE
}).css("background-color", "rgb(255, 255, 255)"); // white
return false;
}
function intelliWindowSearch(param, symbol, symbolType) {
var contextPath = $("#contextpath").val();
var project = $("input[name='project']").val();
var url = contextPath + "/s?" + param + symbol + "&project=" + project;
window.open(url, '_blank');
return false;
}
function googleSymbol(symbol) {
var url = "https://www.google.com/search?q=" + symbol;
window.open(url, '_blank');
return false;
}
function escapeSingleQuote(string) {
return string.replace("'", "\\'");
}
var scope_visible = 0;
var scope_text = '';
/**
* Fold or unfold a function definition.
*/
function fold(id) {
var i = document.getElementById(id + "_fold_icon").children[0];
i.className = i.className === 'fold-icon' ? 'unfold-icon' : 'fold-icon';
$("#" + id + "_fold").toggle('fold');
}
/**
* 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 cnt = document.getElementById("content");
var scope_cnt = document.getElementById("scope_content");
var y = cnt.getBoundingClientRect().top + 2;
var c = document.elementFromPoint(15, y+1);
scope_cnt.innerHTML = '';
if (c.className === "l" || c.className === "hl") {
prev = c;
var par = c.parentNode;
while( par.className !== 'scope-body' && par.className !== 'scope-head' ) {
par = par.parentNode;
if (par === null) {
return ;
}
}
var head = par.className === 'scope-body' ? par.previousSibling : par;
var sig = head.children[0];
scope_cnt.innerHTML = '<a href="#' + head.id + '">' + sig.innerHTML + '</a>';
}
}