A clone of: https://github.com/nutechsoftware/alarmdecoder This is requires as they dropped support for older firmware releases w/o building in backward compatibility code, and they had previously hardcoded pyserial to a python2 only version.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

236 lines
6.5 KiB

  1. /*
  2. * doctools.js
  3. * ~~~~~~~~~~~
  4. *
  5. * Sphinx JavaScript utilities for all documentation.
  6. *
  7. * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS.
  8. * :license: BSD, see LICENSE for details.
  9. *
  10. */
  11. /**
  12. * select a different prefix for underscore
  13. */
  14. $u = _.noConflict();
  15. /**
  16. * make the code below compatible with browsers without
  17. * an installed firebug like debugger
  18. if (!window.console || !console.firebug) {
  19. var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
  20. "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
  21. "profile", "profileEnd"];
  22. window.console = {};
  23. for (var i = 0; i < names.length; ++i)
  24. window.console[names[i]] = function() {};
  25. }
  26. */
  27. /**
  28. * small helper function to urldecode strings
  29. */
  30. jQuery.urldecode = function(x) {
  31. return decodeURIComponent(x).replace(/\+/g, ' ');
  32. };
  33. /**
  34. * small helper function to urlencode strings
  35. */
  36. jQuery.urlencode = encodeURIComponent;
  37. /**
  38. * This function returns the parsed url parameters of the
  39. * current request. Multiple values per key are supported,
  40. * it will always return arrays of strings for the value parts.
  41. */
  42. jQuery.getQueryParameters = function(s) {
  43. if (typeof s == 'undefined')
  44. s = document.location.search;
  45. var parts = s.substr(s.indexOf('?') + 1).split('&');
  46. var result = {};
  47. for (var i = 0; i < parts.length; i++) {
  48. var tmp = parts[i].split('=', 2);
  49. var key = jQuery.urldecode(tmp[0]);
  50. var value = jQuery.urldecode(tmp[1]);
  51. if (key in result)
  52. result[key].push(value);
  53. else
  54. result[key] = [value];
  55. }
  56. return result;
  57. };
  58. /**
  59. * highlight a given string on a jquery object by wrapping it in
  60. * span elements with the given class name.
  61. */
  62. jQuery.fn.highlightText = function(text, className) {
  63. function highlight(node) {
  64. if (node.nodeType == 3) {
  65. var val = node.nodeValue;
  66. var pos = val.toLowerCase().indexOf(text);
  67. if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
  68. var span = document.createElement("span");
  69. span.className = className;
  70. span.appendChild(document.createTextNode(val.substr(pos, text.length)));
  71. node.parentNode.insertBefore(span, node.parentNode.insertBefore(
  72. document.createTextNode(val.substr(pos + text.length)),
  73. node.nextSibling));
  74. node.nodeValue = val.substr(0, pos);
  75. }
  76. }
  77. else if (!jQuery(node).is("button, select, textarea")) {
  78. jQuery.each(node.childNodes, function() {
  79. highlight(this);
  80. });
  81. }
  82. }
  83. return this.each(function() {
  84. highlight(this);
  85. });
  86. };
  87. /**
  88. * Small JavaScript module for the documentation.
  89. */
  90. var Documentation = {
  91. init : function() {
  92. this.fixFirefoxAnchorBug();
  93. this.highlightSearchWords();
  94. this.initIndexTable();
  95. },
  96. /**
  97. * i18n support
  98. */
  99. TRANSLATIONS : {},
  100. PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
  101. LOCALE : 'unknown',
  102. // gettext and ngettext don't access this so that the functions
  103. // can safely bound to a different name (_ = Documentation.gettext)
  104. gettext : function(string) {
  105. var translated = Documentation.TRANSLATIONS[string];
  106. if (typeof translated == 'undefined')
  107. return string;
  108. return (typeof translated == 'string') ? translated : translated[0];
  109. },
  110. ngettext : function(singular, plural, n) {
  111. var translated = Documentation.TRANSLATIONS[singular];
  112. if (typeof translated == 'undefined')
  113. return (n == 1) ? singular : plural;
  114. return translated[Documentation.PLURALEXPR(n)];
  115. },
  116. addTranslations : function(catalog) {
  117. for (var key in catalog.messages)
  118. this.TRANSLATIONS[key] = catalog.messages[key];
  119. this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
  120. this.LOCALE = catalog.locale;
  121. },
  122. /**
  123. * add context elements like header anchor links
  124. */
  125. addContextElements : function() {
  126. $('div[id] > :header:first').each(function() {
  127. $('<a class="headerlink">\u00B6</a>').
  128. attr('href', '#' + this.id).
  129. attr('title', _('Permalink to this headline')).
  130. appendTo(this);
  131. });
  132. $('dt[id]').each(function() {
  133. $('<a class="headerlink">\u00B6</a>').
  134. attr('href', '#' + this.id).
  135. attr('title', _('Permalink to this definition')).
  136. appendTo(this);
  137. });
  138. },
  139. /**
  140. * workaround a firefox stupidity
  141. */
  142. fixFirefoxAnchorBug : function() {
  143. if (document.location.hash && $.browser.mozilla)
  144. window.setTimeout(function() {
  145. document.location.href += '';
  146. }, 10);
  147. },
  148. /**
  149. * highlight the search words provided in the url in the text
  150. */
  151. highlightSearchWords : function() {
  152. var params = $.getQueryParameters();
  153. var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
  154. if (terms.length) {
  155. var body = $('div.body');
  156. window.setTimeout(function() {
  157. $.each(terms, function() {
  158. body.highlightText(this.toLowerCase(), 'highlighted');
  159. });
  160. }, 10);
  161. $('<p class="highlight-link"><a href="javascript:Documentation.' +
  162. 'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
  163. .appendTo($('#searchbox'));
  164. }
  165. },
  166. /**
  167. * init the domain index toggle buttons
  168. */
  169. initIndexTable : function() {
  170. var togglers = $('img.toggler').click(function() {
  171. var src = $(this).attr('src');
  172. var idnum = $(this).attr('id').substr(7);
  173. $('tr.cg-' + idnum).toggle();
  174. if (src.substr(-9) == 'minus.png')
  175. $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
  176. else
  177. $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
  178. }).css('display', '');
  179. if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
  180. togglers.click();
  181. }
  182. },
  183. /**
  184. * helper function to hide the search marks again
  185. */
  186. hideSearchWords : function() {
  187. $('#searchbox .highlight-link').fadeOut(300);
  188. $('span.highlighted').removeClass('highlighted');
  189. },
  190. /**
  191. * make the url absolute
  192. */
  193. makeURL : function(relativeURL) {
  194. return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
  195. },
  196. /**
  197. * get the current relative url
  198. */
  199. getCurrentURL : function() {
  200. var path = document.location.pathname;
  201. var parts = path.split(/\//);
  202. $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
  203. if (this == '..')
  204. parts.pop();
  205. });
  206. var url = parts.join('/');
  207. return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
  208. }
  209. };
  210. // quick alias for translations
  211. _ = Documentation.gettext;
  212. $(document).ready(function() {
  213. Documentation.init();
  214. });