7 if (!window.console || !
console.firebug) {
8 var names = [
"log",
"debug",
"info",
"warn",
"error",
"assert",
"dir",
"dirxml",
9 "group",
"groupEnd",
"time",
"timeEnd",
"count",
"trace",
"profile",
"profileEnd"];
11 for (var i = 0; i < names.length; ++i)
12 window.console[names[i]] =
function() {}
18 jQuery.urldecode =
function(
x) {
19 return decodeURIComponent(
x).replace(/\+/g,
' ');
25 jQuery.urlencode = encodeURIComponent;
32 jQuery.getQueryParameters =
function(s) {
33 if (typeof s ==
'undefined')
34 s = document.location.search;
35 var parts = s.substr(s.indexOf(
'?') + 1).split(
'&');
37 for (var i = 0; i < parts.length; i++) {
38 var tmp = parts[i].split(
'=', 2);
39 var key = jQuery.urldecode(tmp[0]);
40 var value = jQuery.urldecode(tmp[1]);
42 result[key].push(value);
44 result[key] = [value];
53 jQuery.contains =
function(arr, item) {
54 for (var i = 0; i < arr.length; i++) {
65 jQuery.fn.highlightText =
function(text, className) {
66 function highlight(node) {
67 if (node.nodeType == 3) {
68 var val = node.nodeValue;
69 var pos = val.toLowerCase().indexOf(text);
70 if (pos >= 0 && !jQuery.className.has(node.parentNode, className)) {
71 var span = document.createElement(
"span");
72 span.className = className;
73 span.appendChild(document.createTextNode(val.substr(pos, text.length)));
74 node.parentNode.insertBefore(span, node.parentNode.insertBefore(
75 document.createTextNode(val.substr(pos + text.length)),
77 node.nodeValue = val.substr(0, pos);
80 else if (!jQuery(node).is(
"button, select, textarea")) {
81 jQuery.each(node.childNodes,
function() {
86 return this.each(
function() {
97 this.fixFirefoxAnchorBug();
98 this.highlightSearchWords();
106 PLURAL_EXPR :
function(n) {
return n == 1 ? 0 : 1; },
111 gettext :
function(string) {
112 var translated = Documentation.TRANSLATIONS[string];
113 if (typeof translated ==
'undefined')
115 return (typeof translated ==
'string') ? translated : translated[0];
118 ngettext :
function(singular, plural, n) {
119 var translated = Documentation.TRANSLATIONS[singular];
120 if (typeof translated ==
'undefined')
121 return (n == 1) ? singular : plural;
122 return translated[Documentation.PLURALEXPR(n)];
125 addTranslations :
function(catalog) {
126 for (var key in catalog.messages)
127 this.TRANSLATIONS[key] = catalog.messages[key];
128 this.PLURAL_EXPR =
new Function(
'n',
'return +(' + catalog.plural_expr +
')');
129 this.LOCALE = catalog.locale;
135 addContextElements :
function() {
136 $(
'div[id] > :header:first').each(
function() {
137 $(
'<a class="headerlink">\u00B6</a>').
138 attr(
'href',
'#' + this.
id).
139 attr(
'title', _(
'Permalink to this headline')).
142 $(
'dt[id]').each(
function() {
143 $(
'<a class="headerlink">\u00B6</a>').
144 attr(
'href',
'#' + this.
id).
145 attr(
'title', _(
'Permalink to this definition')).
153 fixFirefoxAnchorBug :
function() {
154 if (document.location.hash && $.browser.mozilla)
155 window.setTimeout(
function() {
156 document.location.href +=
'';
163 highlightSearchWords :
function() {
164 var params = $.getQueryParameters();
165 var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
167 var body = $(
'div.body');
168 window.setTimeout(
function() {
169 $.each(terms,
function() {
170 body.highlightText(this.toLowerCase(),
'highlight');
173 $(
'<li class="highlight-link"><a href="javascript:Documentation.' +
174 'hideSearchWords()">' + _(
'Hide Search Matches') +
'</a></li>')
175 .appendTo($(
'.sidebar .this-page-menu'));
182 initModIndex :
function() {
183 var togglers = $(
'img.toggler').click(
function() {
184 var src = $(
this).attr(
'src');
185 var idnum = $(
this).attr(
'id').substr(7);
186 console.log($(
'tr.cg-' + idnum).toggle());
187 if (src.substr(-9) ==
'minus.png')
188 $(
this).attr(
'src', src.substr(0, src.length-9) +
'plus.png');
190 $(
this).attr(
'src', src.substr(0, src.length-8) +
'minus.png');
191 }).css(
'display',
'');
192 if (DOCUMENTATION_OPTIONS.COLLAPSE_MODINDEX) {
200 hideSearchWords :
function() {
201 $(
'.sidebar .this-page-menu li.highlight-link').fadeOut(300);
202 $(
'span.highlight').removeClass(
'highlight');
208 makeURL :
function(relativeURL) {
209 return DOCUMENTATION_OPTIONS.URL_ROOT +
'/' + relativeURL;
215 getCurrentURL :
function() {
216 var path = document.location.pathname;
217 var parts = path.split(/\
218 $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\
222 var url = parts.join(
'/');
223 return path.substring(url.lastIndexOf(
'/') + 1, path.length - 1);
228 _ = Documentation.gettext;
230 $(document).ready(
function() {
231 Documentation.init();
The namespace console contains no service. It is only used to launch a main loop for console applicat...