PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

3 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*
  2. @licstart The following is the entire license notice for the
  3. JavaScript code in this file.
  4. Copyright (C) 1997-2019 by Dimitri van Heesch
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of version 2 of the GNU General Public License as
  7. published by the Free Software Foundation.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. @licend The above is the entire license notice
  16. for the JavaScript code in this file
  17. */
  18. var navTreeSubIndices = new Array();
  19. var arrowDown = '▼';
  20. var arrowRight = '►';
  21. function getData(varName)
  22. {
  23. var i = varName.lastIndexOf('/');
  24. var n = i>=0 ? varName.substring(i+1) : varName;
  25. return eval(n.replace(/\-/g,'_'));
  26. }
  27. function stripPath(uri)
  28. {
  29. return uri.substring(uri.lastIndexOf('/')+1);
  30. }
  31. function stripPath2(uri)
  32. {
  33. var i = uri.lastIndexOf('/');
  34. var s = uri.substring(i+1);
  35. var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
  36. return m ? uri.substring(i-6) : s;
  37. }
  38. function hashValue()
  39. {
  40. return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,'');
  41. }
  42. function hashUrl()
  43. {
  44. return '#'+hashValue();
  45. }
  46. function pathName()
  47. {
  48. return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, '');
  49. }
  50. function localStorageSupported()
  51. {
  52. try {
  53. return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem;
  54. }
  55. catch(e) {
  56. return false;
  57. }
  58. }
  59. function storeLink(link)
  60. {
  61. if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
  62. window.localStorage.setItem('navpath',link);
  63. }
  64. }
  65. function deleteLink()
  66. {
  67. if (localStorageSupported()) {
  68. window.localStorage.setItem('navpath','');
  69. }
  70. }
  71. function cachedLink()
  72. {
  73. if (localStorageSupported()) {
  74. return window.localStorage.getItem('navpath');
  75. } else {
  76. return '';
  77. }
  78. }
  79. function getScript(scriptName,func,show)
  80. {
  81. var head = document.getElementsByTagName("head")[0];
  82. var script = document.createElement('script');
  83. script.id = scriptName;
  84. script.type = 'text/javascript';
  85. script.onload = func;
  86. script.src = scriptName+'.js';
  87. head.appendChild(script);
  88. }
  89. function createIndent(o,domNode,node,level)
  90. {
  91. var level=-1;
  92. var n = node;
  93. while (n.parentNode) { level++; n=n.parentNode; }
  94. if (node.childrenData) {
  95. var imgNode = document.createElement("span");
  96. imgNode.className = 'arrow';
  97. imgNode.style.paddingLeft=(16*level).toString()+'px';
  98. imgNode.innerHTML=arrowRight;
  99. node.plus_img = imgNode;
  100. node.expandToggle = document.createElement("a");
  101. node.expandToggle.href = "javascript:void(0)";
  102. node.expandToggle.onclick = function() {
  103. if (node.expanded) {
  104. $(node.getChildrenUL()).slideUp("fast");
  105. node.plus_img.innerHTML=arrowRight;
  106. node.expanded = false;
  107. } else {
  108. expandNode(o, node, false, false);
  109. }
  110. }
  111. node.expandToggle.appendChild(imgNode);
  112. domNode.appendChild(node.expandToggle);
  113. } else {
  114. var span = document.createElement("span");
  115. span.className = 'arrow';
  116. span.style.width = 16*(level+1)+'px';
  117. span.innerHTML = ' ';
  118. domNode.appendChild(span);
  119. }
  120. }
  121. var animationInProgress = false;
  122. function gotoAnchor(anchor,aname,updateLocation)
  123. {
  124. var pos, docContent = $('#doc-content');
  125. var ancParent = $(anchor.parent());
  126. if (ancParent.hasClass('memItemLeft') ||
  127. ancParent.hasClass('memtitle') ||
  128. ancParent.hasClass('fieldname') ||
  129. ancParent.hasClass('fieldtype') ||
  130. ancParent.is(':header'))
  131. {
  132. pos = ancParent.position().top;
  133. } else if (anchor.position()) {
  134. pos = anchor.position().top;
  135. }
  136. if (pos) {
  137. var dist = Math.abs(Math.min(
  138. pos-docContent.offset().top,
  139. docContent[0].scrollHeight-
  140. docContent.height()-docContent.scrollTop()));
  141. animationInProgress=true;
  142. docContent.animate({
  143. scrollTop: pos + docContent.scrollTop() - docContent.offset().top
  144. },Math.max(50,Math.min(500,dist)),function(){
  145. if (updateLocation) window.location.href=aname;
  146. animationInProgress=false;
  147. });
  148. }
  149. }
  150. function newNode(o, po, text, link, childrenData, lastNode)
  151. {
  152. var node = new Object();
  153. node.children = Array();
  154. node.childrenData = childrenData;
  155. node.depth = po.depth + 1;
  156. node.relpath = po.relpath;
  157. node.isLast = lastNode;
  158. node.li = document.createElement("li");
  159. po.getChildrenUL().appendChild(node.li);
  160. node.parentNode = po;
  161. node.itemDiv = document.createElement("div");
  162. node.itemDiv.className = "item";
  163. node.labelSpan = document.createElement("span");
  164. node.labelSpan.className = "label";
  165. createIndent(o,node.itemDiv,node,0);
  166. node.itemDiv.appendChild(node.labelSpan);
  167. node.li.appendChild(node.itemDiv);
  168. var a = document.createElement("a");
  169. node.labelSpan.appendChild(a);
  170. node.label = document.createTextNode(text);
  171. node.expanded = false;
  172. a.appendChild(node.label);
  173. if (link) {
  174. var url;
  175. if (link.substring(0,1)=='^') {
  176. url = link.substring(1);
  177. link = url;
  178. } else {
  179. url = node.relpath+link;
  180. }
  181. a.className = stripPath(link.replace('#',':'));
  182. if (link.indexOf('#')!=-1) {
  183. var aname = '#'+link.split('#')[1];
  184. var srcPage = stripPath(pathName());
  185. var targetPage = stripPath(link.split('#')[0]);
  186. a.href = srcPage!=targetPage ? url : "javascript:void(0)";
  187. a.onclick = function(){
  188. storeLink(link);
  189. if (!$(a).parent().parent().hasClass('selected'))
  190. {
  191. $('.item').removeClass('selected');
  192. $('.item').removeAttr('id');
  193. $(a).parent().parent().addClass('selected');
  194. $(a).parent().parent().attr('id','selected');
  195. }
  196. var anchor = $(aname);
  197. gotoAnchor(anchor,aname,true);
  198. };
  199. } else {
  200. a.href = url;
  201. a.onclick = function() { storeLink(link); }
  202. }
  203. } else {
  204. if (childrenData != null)
  205. {
  206. a.className = "nolink";
  207. a.href = "javascript:void(0)";
  208. a.onclick = node.expandToggle.onclick;
  209. }
  210. }
  211. node.childrenUL = null;
  212. node.getChildrenUL = function() {
  213. if (!node.childrenUL) {
  214. node.childrenUL = document.createElement("ul");
  215. node.childrenUL.className = "children_ul";
  216. node.childrenUL.style.display = "none";
  217. node.li.appendChild(node.childrenUL);
  218. }
  219. return node.childrenUL;
  220. };
  221. return node;
  222. }
  223. function showRoot()
  224. {
  225. var headerHeight = $("#top").height();
  226. var footerHeight = $("#nav-path").height();
  227. var windowHeight = $(window).height() - headerHeight - footerHeight;
  228. (function (){ // retry until we can scroll to the selected item
  229. try {
  230. var navtree=$('#nav-tree');
  231. navtree.scrollTo('#selected',100,{offset:-windowHeight/2});
  232. } catch (err) {
  233. setTimeout(arguments.callee, 0);
  234. }
  235. })();
  236. }
  237. function expandNode(o, node, imm, showRoot)
  238. {
  239. if (node.childrenData && !node.expanded) {
  240. if (typeof(node.childrenData)==='string') {
  241. var varName = node.childrenData;
  242. getScript(node.relpath+varName,function(){
  243. node.childrenData = getData(varName);
  244. expandNode(o, node, imm, showRoot);
  245. }, showRoot);
  246. } else {
  247. if (!node.childrenVisited) {
  248. getNode(o, node);
  249. }
  250. $(node.getChildrenUL()).slideDown("fast");
  251. node.plus_img.innerHTML = arrowDown;
  252. node.expanded = true;
  253. }
  254. }
  255. }
  256. function glowEffect(n,duration)
  257. {
  258. n.addClass('glow').delay(duration).queue(function(next){
  259. $(this).removeClass('glow');next();
  260. });
  261. }
  262. function highlightAnchor()
  263. {
  264. var aname = hashUrl();
  265. var anchor = $(aname);
  266. if (anchor.parent().attr('class')=='memItemLeft'){
  267. var rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
  268. glowEffect(rows.children(),300); // member without details
  269. } else if (anchor.parent().attr('class')=='fieldname'){
  270. glowEffect(anchor.parent().parent(),1000); // enum value
  271. } else if (anchor.parent().attr('class')=='fieldtype'){
  272. glowEffect(anchor.parent().parent(),1000); // struct field
  273. } else if (anchor.parent().is(":header")) {
  274. glowEffect(anchor.parent(),1000); // section header
  275. } else {
  276. glowEffect(anchor.next(),1000); // normal member
  277. }
  278. }
  279. function selectAndHighlight(hash,n)
  280. {
  281. var a;
  282. if (hash) {
  283. var link=stripPath(pathName())+':'+hash.substring(1);
  284. a=$('.item a[class$="'+link+'"]');
  285. }
  286. if (a && a.length) {
  287. a.parent().parent().addClass('selected');
  288. a.parent().parent().attr('id','selected');
  289. highlightAnchor();
  290. } else if (n) {
  291. $(n.itemDiv).addClass('selected');
  292. $(n.itemDiv).attr('id','selected');
  293. }
  294. if ($('#nav-tree-contents .item:first').hasClass('selected')) {
  295. $('#nav-sync').css('top','30px');
  296. } else {
  297. $('#nav-sync').css('top','5px');
  298. }
  299. showRoot();
  300. }
  301. function showNode(o, node, index, hash)
  302. {
  303. if (node && node.childrenData) {
  304. if (typeof(node.childrenData)==='string') {
  305. var varName = node.childrenData;
  306. getScript(node.relpath+varName,function(){
  307. node.childrenData = getData(varName);
  308. showNode(o,node,index,hash);
  309. },true);
  310. } else {
  311. if (!node.childrenVisited) {
  312. getNode(o, node);
  313. }
  314. $(node.getChildrenUL()).css({'display':'block'});
  315. node.plus_img.innerHTML = arrowDown;
  316. node.expanded = true;
  317. var n = node.children[o.breadcrumbs[index]];
  318. if (index+1<o.breadcrumbs.length) {
  319. showNode(o,n,index+1,hash);
  320. } else {
  321. if (typeof(n.childrenData)==='string') {
  322. var varName = n.childrenData;
  323. getScript(n.relpath+varName,function(){
  324. n.childrenData = getData(varName);
  325. node.expanded=false;
  326. showNode(o,node,index,hash); // retry with child node expanded
  327. },true);
  328. } else {
  329. var rootBase = stripPath(o.toroot.replace(/\..+$/, ''));
  330. if (rootBase=="index" || rootBase=="pages" || rootBase=="search") {
  331. expandNode(o, n, true, true);
  332. }
  333. selectAndHighlight(hash,n);
  334. }
  335. }
  336. }
  337. } else {
  338. selectAndHighlight(hash);
  339. }
  340. }
  341. function removeToInsertLater(element) {
  342. var parentNode = element.parentNode;
  343. var nextSibling = element.nextSibling;
  344. parentNode.removeChild(element);
  345. return function() {
  346. if (nextSibling) {
  347. parentNode.insertBefore(element, nextSibling);
  348. } else {
  349. parentNode.appendChild(element);
  350. }
  351. };
  352. }
  353. function getNode(o, po)
  354. {
  355. var insertFunction = removeToInsertLater(po.li);
  356. po.childrenVisited = true;
  357. var l = po.childrenData.length-1;
  358. for (var i in po.childrenData) {
  359. var nodeData = po.childrenData[i];
  360. po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
  361. i==l);
  362. }
  363. insertFunction();
  364. }
  365. function gotoNode(o,subIndex,root,hash,relpath)
  366. {
  367. var nti = navTreeSubIndices[subIndex][root+hash];
  368. o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
  369. if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
  370. navTo(o,NAVTREE[0][1],"",relpath);
  371. $('.item').removeClass('selected');
  372. $('.item').removeAttr('id');
  373. }
  374. if (o.breadcrumbs) {
  375. o.breadcrumbs.unshift(0); // add 0 for root node
  376. showNode(o, o.node, 0, hash);
  377. }
  378. }
  379. function navTo(o,root,hash,relpath)
  380. {
  381. var link = cachedLink();
  382. if (link) {
  383. var parts = link.split('#');
  384. root = parts[0];
  385. if (parts.length>1) hash = '#'+parts[1].replace(/[^\w\-]/g,'');
  386. else hash='';
  387. }
  388. if (hash.match(/^#l\d+$/)) {
  389. var anchor=$('a[name='+hash.substring(1)+']');
  390. glowEffect(anchor.parent(),1000); // line number
  391. hash=''; // strip line number anchors
  392. }
  393. var url=root+hash;
  394. var i=-1;
  395. while (NAVTREEINDEX[i+1]<=url) i++;
  396. if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
  397. if (navTreeSubIndices[i]) {
  398. gotoNode(o,i,root,hash,relpath)
  399. } else {
  400. getScript(relpath+'navtreeindex'+i,function(){
  401. navTreeSubIndices[i] = eval('NAVTREEINDEX'+i);
  402. if (navTreeSubIndices[i]) {
  403. gotoNode(o,i,root,hash,relpath);
  404. }
  405. },true);
  406. }
  407. }
  408. function showSyncOff(n,relpath)
  409. {
  410. n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
  411. }
  412. function showSyncOn(n,relpath)
  413. {
  414. n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
  415. }
  416. function toggleSyncButton(relpath)
  417. {
  418. var navSync = $('#nav-sync');
  419. if (navSync.hasClass('sync')) {
  420. navSync.removeClass('sync');
  421. showSyncOff(navSync,relpath);
  422. storeLink(stripPath2(pathName())+hashUrl());
  423. } else {
  424. navSync.addClass('sync');
  425. showSyncOn(navSync,relpath);
  426. deleteLink();
  427. }
  428. }
  429. var loadTriggered = false;
  430. var readyTriggered = false;
  431. var loadObject,loadToRoot,loadUrl,loadRelPath;
  432. $(window).on('load',function(){
  433. if (readyTriggered) { // ready first
  434. navTo(loadObject,loadToRoot,loadUrl,loadRelPath);
  435. showRoot();
  436. }
  437. loadTriggered=true;
  438. });
  439. function initNavTree(toroot,relpath)
  440. {
  441. var o = new Object();
  442. o.toroot = toroot;
  443. o.node = new Object();
  444. o.node.li = document.getElementById("nav-tree-contents");
  445. o.node.childrenData = NAVTREE;
  446. o.node.children = new Array();
  447. o.node.childrenUL = document.createElement("ul");
  448. o.node.getChildrenUL = function() { return o.node.childrenUL; };
  449. o.node.li.appendChild(o.node.childrenUL);
  450. o.node.depth = 0;
  451. o.node.relpath = relpath;
  452. o.node.expanded = false;
  453. o.node.isLast = true;
  454. o.node.plus_img = document.createElement("span");
  455. o.node.plus_img.className = 'arrow';
  456. o.node.plus_img.innerHTML = arrowRight;
  457. if (localStorageSupported()) {
  458. var navSync = $('#nav-sync');
  459. if (cachedLink()) {
  460. showSyncOff(navSync,relpath);
  461. navSync.removeClass('sync');
  462. } else {
  463. showSyncOn(navSync,relpath);
  464. }
  465. navSync.click(function(){ toggleSyncButton(relpath); });
  466. }
  467. if (loadTriggered) { // load before ready
  468. navTo(o,toroot,hashUrl(),relpath);
  469. showRoot();
  470. } else { // ready before load
  471. loadObject = o;
  472. loadToRoot = toroot;
  473. loadUrl = hashUrl();
  474. loadRelPath = relpath;
  475. readyTriggered=true;
  476. }
  477. $(window).bind('hashchange', function(){
  478. if (window.location.hash && window.location.hash.length>1){
  479. var a;
  480. if ($(location).attr('hash')){
  481. var clslink=stripPath(pathName())+':'+hashValue();
  482. a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
  483. }
  484. if (a==null || !$(a).parent().parent().hasClass('selected')){
  485. $('.item').removeClass('selected');
  486. $('.item').removeAttr('id');
  487. }
  488. var link=stripPath2(pathName());
  489. navTo(o,link,hashUrl(),relpath);
  490. } else if (!animationInProgress) {
  491. $('#doc-content').scrollTop(0);
  492. $('.item').removeClass('selected');
  493. $('.item').removeAttr('id');
  494. navTo(o,toroot,hashUrl(),relpath);
  495. }
  496. })
  497. }
  498. /* @license-end */