PageSourceSearch

https://qutecom.org/chrome/common/js/trac.js

js qutecom.org collected 2026-09-28 12:51:44 UTC 3,702 bytes, 133 lines download raw bytes

1(function($){
2
3  if (typeof _ == 'undefined')
4    babel.Translations.load({}).install();
5
6  $.fn.addAnchor = function(title) {
7    title = title || _("Link here");
8    return this.filter("*[id]").each(function() {
9      $("<a class='anchor'> \u00B6</a>").attr("href", "#" + this.id)
10        .attr("title", title).appendTo(this);
11    });
12  }
13  
14  $.fn.checked = function(checked) {
15    if (checked == undefined) { // getter
16      if (!this.length) return false;
17      return this.get(0).checked;
18    } else { // setter
19      return this.each(function() {
20        this.checked = checked;
21      });
22    }
23  }
24  
25  $.fn.enable = function(enabled) {
26    if (enabled == undefined) enabled = true;
27    return this.each(function() {
28      this.disabled = !enabled;
29      var label = $(this).parents("label");
30      if (!label.length && this.id) {
31        label = $("label[for='" + this.id + "']");
32      }
33      if (!enabled) {
34        label.addClass("disabled");
35      } else {
36        label.removeClass("disabled");
37      }
38    });
39  }
40  
41  $.fn.getAbsolutePos = function() {
42    return this.map(function() {
43      var left = this.offsetLeft;
44      var top = this.offsetTop;
45      var parent = this.offsetParent;
46      while (parent) {
47        left += parent.offsetLeft;
48        top += parent.offsetTop;
49        parent = parent.offsetParent;
50      }
51      return {left: left, top: top};
52    });
53  }
54  
55  $.fn.scrollToTop = function() {
56    return this.each(function() {
57      scrollTo(0, $(this).getAbsolutePos()[0].top);
58      return false;
59    });
60  }
61  
62  $.loadStyleSheet = function(href, type) {
63    type = type || "text/css";
64    $(document).ready(function() {
65      if (document.createStyleSheet) { // MSIE
66        document.createStyleSheet(href);
67      } else {
68        $("<link rel='stylesheet' type='" + type + "' href='" + href + "' />")
69          .appendTo("head");
70      }
71    });
72  }
73  
74  // Escape special HTML characters (&<>")
75  var quote = {"&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;"};
76
77  $.htmlEscape = function(value) {
78    if (typeof value != "string")
79      return value;
80    return value.replace(/[&<>"]/g, function(c) { return quote[c]; });
81  }
82  
83  function format(str, args, escape) {
84    var kwargs = args[args.length - 1];
85    return str.replace(/\${?(\w+)}?/g, function(_, k) {
86      var result;
87      if (k.length == 1 && k >= '0' && k <= '9')
88        result = args[k - '0'];
89      else
90        result = kwargs[k];
91      return escape ? escape(result) : result;
92    }); 
93  }
94
95  // Expand positional ($1 .. $9) and keyword ($name) arguments in a string.
96  // The htmlFormat() version HTML-escapes arguments prior to substitution.
97  $.format = function(str) {
98    return format(str, arguments);
99  }
100
101  $.htmlFormat = function(str) {
102    return format(str, arguments, $.htmlEscape);
103  }
104
105  $.template = $.format;    // For backward compatibility
106
107  // Used for dynamically updating the height of a textarea
108  window.resizeTextArea = function (id, rows) {
109    var textarea = $("#" + id).get(0);
110    if (!textarea || textarea.rows == undefined) return;
111    $(textarea).height("");
112    textarea.rows = rows;
113  }
114
115  // The following are defined for backwards compatibility with releases prior
116  // to Trac 0.11
117  
118  window.addEvent = function(elem, type, func) {
119    $(elem).bind(type, func);
120  }
121  window.addHeadingLinks = function(container, title) {
122    $.each(["h1", "h2", "h3", "h4", "h5", "h6"], function() {
123      $(this, container).addAnchor(title);
124    });
125  }
126  window.enableControl = function(id, enabled) {
127    $("#" + id).enable(enabled);
128  }
129  window.getAncestorByTagName = function(elem, tagName) {
130    return $(elem).parents(tagName).get(0);
131  }
132
133})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.