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.

пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /** Modified from original Node-Red source, for audio system visualization
  2. * vim: set ts=4:
  3. * Copyright 2013 IBM Corp.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. **/
  17. RED.sidebar.info = (function() {
  18. var content = document.createElement("div");
  19. content.id = "tab-info";
  20. content.style.paddingTop = "4px";
  21. content.style.paddingLeft = "4px";
  22. content.style.paddingRight = "4px";
  23. RED.sidebar.addTab("info",content);
  24. $("#tab-info").html("<p></p><p>Special thanks to Nicholas O'Leary, Dave Conway-Jones and IBM.</p><p>Without their work on the open source <a href=\"http://nodered.org/\" target=\"_blank\">Node-RED</a> project, this GUI front-end for the Teensy Audio Library would not have been possible!</p>");
  25. function jsonFilter(key,value) {
  26. if (key === "") {
  27. return value;
  28. }
  29. var t = typeof value;
  30. if ($.isArray(value)) {
  31. return "[array:"+value.length+"]";
  32. } else if (t === "object") {
  33. return "[object]"
  34. } else if (t === "string") {
  35. if (value.length > 30) {
  36. return value.substring(0,30)+" ...";
  37. }
  38. }
  39. return value;
  40. }
  41. function refresh(node) {
  42. var table = '<table class="node-info"><tbody>';
  43. table += "<tr><td>Type</td><td>&nbsp;"+node.type+"</td></tr>";
  44. table += "<tr><td>ID</td><td>&nbsp;"+node.id+"</td></tr>";
  45. table += '<tr class="blank"><td colspan="2">&nbsp;Properties</td></tr>';
  46. for (var n in node._def.defaults) {
  47. if (node._def.defaults.hasOwnProperty(n)) {
  48. var val = node[n]||"";
  49. var type = typeof val;
  50. if (type === "string") {
  51. if (val.length > 30) {
  52. val = val.substring(0,30)+" ...";
  53. }
  54. val = val.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
  55. } else if (type === "number") {
  56. val = val.toString();
  57. } else if ($.isArray(val)) {
  58. val = "[<br/>";
  59. for (var i=0;i<Math.min(node[n].length,10);i++) {
  60. var vv = JSON.stringify(node[n][i],jsonFilter," ").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
  61. val += "&nbsp;"+i+": "+vv+"<br/>";
  62. }
  63. if (node[n].length > 10) {
  64. val += "&nbsp;... "+node[n].length+" items<br/>";
  65. }
  66. val += "]";
  67. } else {
  68. val = JSON.stringify(val,jsonFilter," ");
  69. val = val.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
  70. }
  71. table += "<tr><td>&nbsp;"+n+"</td><td>"+val+"</td></tr>";
  72. }
  73. }
  74. table += "</tbody></table><br/>";
  75. table += '<div class="node-help">'+($("script[data-help-name|='"+node.type+"']").html()||"")+"</div>";
  76. $("#tab-info").html(table);
  77. }
  78. return {
  79. refresh:refresh,
  80. clear: function() {
  81. $("#tab-info").html("");
  82. }
  83. }
  84. })();