Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

111 linhas
4.1KB

  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("<h3>Welcome</h3><p>The Audio System Design Tool lets you easily draw a system to process 16 bit, 44.1 kHz streaming audio while your Arduino sketch also runs.</p><p>Export will generate code to copy into the Arduino editor, to implement your system.</p><p>Most objects provide simple functions you can call from setup() or loop() to control your audio project!</p><h3>Offline Use</h3><p>This tool does not use a server. A stand-alone copy is provided with the Teensy Audio Library, in the gui folder.</p><h3>Credits</h3><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 graphical design tool 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. this.setHelpContent(table, node.type);
  76. }
  77. function setHelpContent(prefix, key) {
  78. // server test switched off - test purposes only
  79. var patt = new RegExp(/^[http|https]/);
  80. var server = false && patt.test(location.protocol);
  81. prefix = prefix == "" ? "<h3>" + key + "</h3>" : prefix;
  82. if (!server) {
  83. data = $("script[data-help-name|='" + key + "']").html();
  84. $("#tab-info").html(prefix + '<div class="node-help">' + data + '</div>');
  85. } else {
  86. $.get( "resources/help/" + key + ".html", function( data ) {
  87. $("#tab-info").html(prefix + '<h2>' + key + '</h2><div class="node-help">' + data + '</div>');
  88. }).fail(function () {
  89. $("#tab-info").html(prefix);
  90. });
  91. }
  92. }
  93. return {
  94. refresh:refresh,
  95. clear: function() {
  96. $("#tab-info").html("");
  97. },
  98. setHelpContent: setHelpContent
  99. }
  100. })();