]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/freedom-metal/doc/html/_static/doctools.js
Base project to replace existing Freedom Studio project using latest Freedom Studio...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_GCC / freedom-metal / doc / html / _static / doctools.js
1 /*
2  * doctools.js
3  * ~~~~~~~~~~~
4  *
5  * Sphinx JavaScript utilities for all documentation.
6  *
7  * :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
8  * :license: BSD, see LICENSE for details.
9  *
10  */
11
12 /**
13  * select a different prefix for underscore
14  */
15 $u = _.noConflict();
16
17 /**
18  * make the code below compatible with browsers without
19  * an installed firebug like debugger
20 if (!window.console || !console.firebug) {
21   var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
22     "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
23     "profile", "profileEnd"];
24   window.console = {};
25   for (var i = 0; i < names.length; ++i)
26     window.console[names[i]] = function() {};
27 }
28  */
29
30 /**
31  * small helper function to urldecode strings
32  */
33 jQuery.urldecode = function(x) {
34   return decodeURIComponent(x).replace(/\+/g, ' ');
35 };
36
37 /**
38  * small helper function to urlencode strings
39  */
40 jQuery.urlencode = encodeURIComponent;
41
42 /**
43  * This function returns the parsed url parameters of the
44  * current request. Multiple values per key are supported,
45  * it will always return arrays of strings for the value parts.
46  */
47 jQuery.getQueryParameters = function(s) {
48   if (typeof s === 'undefined')
49     s = document.location.search;
50   var parts = s.substr(s.indexOf('?') + 1).split('&');
51   var result = {};
52   for (var i = 0; i < parts.length; i++) {
53     var tmp = parts[i].split('=', 2);
54     var key = jQuery.urldecode(tmp[0]);
55     var value = jQuery.urldecode(tmp[1]);
56     if (key in result)
57       result[key].push(value);
58     else
59       result[key] = [value];
60   }
61   return result;
62 };
63
64 /**
65  * highlight a given string on a jquery object by wrapping it in
66  * span elements with the given class name.
67  */
68 jQuery.fn.highlightText = function(text, className) {
69   function highlight(node, addItems) {
70     if (node.nodeType === 3) {
71       var val = node.nodeValue;
72       var pos = val.toLowerCase().indexOf(text);
73       if (pos >= 0 &&
74           !jQuery(node.parentNode).hasClass(className) &&
75           !jQuery(node.parentNode).hasClass("nohighlight")) {
76         var span;
77         var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
78         if (isInSVG) {
79           span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
80         } else {
81           span = document.createElement("span");
82           span.className = className;
83         }
84         span.appendChild(document.createTextNode(val.substr(pos, text.length)));
85         node.parentNode.insertBefore(span, node.parentNode.insertBefore(
86           document.createTextNode(val.substr(pos + text.length)),
87           node.nextSibling));
88         node.nodeValue = val.substr(0, pos);
89         if (isInSVG) {
90           var bbox = span.getBBox();
91           var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
92           rect.x.baseVal.value = bbox.x;
93           rect.y.baseVal.value = bbox.y;
94           rect.width.baseVal.value = bbox.width;
95           rect.height.baseVal.value = bbox.height;
96           rect.setAttribute('class', className);
97           var parentOfText = node.parentNode.parentNode;
98           addItems.push({
99               "parent": node.parentNode,
100               "target": rect});
101         }
102       }
103     }
104     else if (!jQuery(node).is("button, select, textarea")) {
105       jQuery.each(node.childNodes, function() {
106         highlight(this, addItems);
107       });
108     }
109   }
110   var addItems = [];
111   var result = this.each(function() {
112     highlight(this, addItems);
113   });
114   for (var i = 0; i < addItems.length; ++i) {
115     jQuery(addItems[i].parent).before(addItems[i].target);
116   }
117   return result;
118 };
119
120 /*
121  * backward compatibility for jQuery.browser
122  * This will be supported until firefox bug is fixed.
123  */
124 if (!jQuery.browser) {
125   jQuery.uaMatch = function(ua) {
126     ua = ua.toLowerCase();
127
128     var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
129       /(webkit)[ \/]([\w.]+)/.exec(ua) ||
130       /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
131       /(msie) ([\w.]+)/.exec(ua) ||
132       ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
133       [];
134
135     return {
136       browser: match[ 1 ] || "",
137       version: match[ 2 ] || "0"
138     };
139   };
140   jQuery.browser = {};
141   jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
142 }
143
144 /**
145  * Small JavaScript module for the documentation.
146  */
147 var Documentation = {
148
149   init : function() {
150     this.fixFirefoxAnchorBug();
151     this.highlightSearchWords();
152     this.initIndexTable();
153     
154   },
155
156   /**
157    * i18n support
158    */
159   TRANSLATIONS : {},
160   PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; },
161   LOCALE : 'unknown',
162
163   // gettext and ngettext don't access this so that the functions
164   // can safely bound to a different name (_ = Documentation.gettext)
165   gettext : function(string) {
166     var translated = Documentation.TRANSLATIONS[string];
167     if (typeof translated === 'undefined')
168       return string;
169     return (typeof translated === 'string') ? translated : translated[0];
170   },
171
172   ngettext : function(singular, plural, n) {
173     var translated = Documentation.TRANSLATIONS[singular];
174     if (typeof translated === 'undefined')
175       return (n == 1) ? singular : plural;
176     return translated[Documentation.PLURALEXPR(n)];
177   },
178
179   addTranslations : function(catalog) {
180     for (var key in catalog.messages)
181       this.TRANSLATIONS[key] = catalog.messages[key];
182     this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
183     this.LOCALE = catalog.locale;
184   },
185
186   /**
187    * add context elements like header anchor links
188    */
189   addContextElements : function() {
190     $('div[id] > :header:first').each(function() {
191       $('<a class="headerlink">\u00B6</a>').
192       attr('href', '#' + this.id).
193       attr('title', _('Permalink to this headline')).
194       appendTo(this);
195     });
196     $('dt[id]').each(function() {
197       $('<a class="headerlink">\u00B6</a>').
198       attr('href', '#' + this.id).
199       attr('title', _('Permalink to this definition')).
200       appendTo(this);
201     });
202   },
203
204   /**
205    * workaround a firefox stupidity
206    * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
207    */
208   fixFirefoxAnchorBug : function() {
209     if (document.location.hash && $.browser.mozilla)
210       window.setTimeout(function() {
211         document.location.href += '';
212       }, 10);
213   },
214
215   /**
216    * highlight the search words provided in the url in the text
217    */
218   highlightSearchWords : function() {
219     var params = $.getQueryParameters();
220     var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
221     if (terms.length) {
222       var body = $('div.body');
223       if (!body.length) {
224         body = $('body');
225       }
226       window.setTimeout(function() {
227         $.each(terms, function() {
228           body.highlightText(this.toLowerCase(), 'highlighted');
229         });
230       }, 10);
231       $('<p class="highlight-link"><a href="javascript:Documentation.' +
232         'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
233           .appendTo($('#searchbox'));
234     }
235   },
236
237   /**
238    * init the domain index toggle buttons
239    */
240   initIndexTable : function() {
241     var togglers = $('img.toggler').click(function() {
242       var src = $(this).attr('src');
243       var idnum = $(this).attr('id').substr(7);
244       $('tr.cg-' + idnum).toggle();
245       if (src.substr(-9) === 'minus.png')
246         $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
247       else
248         $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
249     }).css('display', '');
250     if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
251         togglers.click();
252     }
253   },
254
255   /**
256    * helper function to hide the search marks again
257    */
258   hideSearchWords : function() {
259     $('#searchbox .highlight-link').fadeOut(300);
260     $('span.highlighted').removeClass('highlighted');
261   },
262
263   /**
264    * make the url absolute
265    */
266   makeURL : function(relativeURL) {
267     return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
268   },
269
270   /**
271    * get the current relative url
272    */
273   getCurrentURL : function() {
274     var path = document.location.pathname;
275     var parts = path.split(/\//);
276     $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
277       if (this === '..')
278         parts.pop();
279     });
280     var url = parts.join('/');
281     return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
282   },
283
284   initOnKeyListeners: function() {
285     $(document).keyup(function(event) {
286       var activeElementType = document.activeElement.tagName;
287       // don't navigate when in search box or textarea
288       if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
289         switch (event.keyCode) {
290           case 37: // left
291             var prevHref = $('link[rel="prev"]').prop('href');
292             if (prevHref) {
293               window.location.href = prevHref;
294               return false;
295             }
296           case 39: // right
297             var nextHref = $('link[rel="next"]').prop('href');
298             if (nextHref) {
299               window.location.href = nextHref;
300               return false;
301             }
302         }
303       }
304     });
305   }
306 };
307
308 // quick alias for translations
309 _ = Documentation.gettext;
310
311 $(document).ready(function() {
312   Documentation.init();
313 });