| <script type="text/x-red" data-template-name="export-clipboard-dialog"> | <script type="text/x-red" data-template-name="export-clipboard-dialog"> | ||||
| <div class="form-row"> | <div class="form-row"> | ||||
| <label for="node-input-export" style="display: block; width:100%;"><i class="icon-share"></i> Nodes:</label> | |||||
| <textarea readonly style="font-family: monospace; font-size: 12px; background:rgb(226, 229, 255); padding-left: 0.5em;" class="input-block-level" id="node-input-export" rows="5"></textarea> | |||||
| <label for="node-input-export" style="display: block; width:100%;"><i class="icon-share"></i> Source Code:</label> | |||||
| <textarea readonly style="font-family: monospace; font-size: 12px; background:rgb(226, 229, 255); padding-left: 0.5em;" class="input-block-level" id="node-input-export" rows="12"></textarea> | |||||
| </div> | </div> | ||||
| <div class="form-tips"> | <div class="form-tips"> | ||||
| Select the text above and copy to the clipboard with Ctrl-A Ctrl-C. | Select the text above and copy to the clipboard with Ctrl-A Ctrl-C. | ||||
| <script src="orion/built-editor.min.js"></script> | <script src="orion/built-editor.min.js"></script> | ||||
| <script src="d3.v3.min.js"></script> | <script src="d3.v3.min.js"></script> | ||||
| <script src="red/main.js"></script> | <script src="red/main.js"></script> | ||||
| <script src="red/comms.js"></script> | |||||
| <script src="red/ui/state.js"></script> | <script src="red/ui/state.js"></script> | ||||
| <script src="red/nodes.js"></script> | <script src="red/nodes.js"></script> | ||||
| <script src="red/storage.js"></script> | <script src="red/storage.js"></script> | ||||
| <script src="red/history.js"></script> | <script src="red/history.js"></script> | ||||
| <script src="red/validators.js"></script> | |||||
| <script src="red/ui/keyboard.js"></script> | <script src="red/ui/keyboard.js"></script> | ||||
| <script src="red/ui/tabs.js"></script> | <script src="red/ui/tabs.js"></script> | ||||
| <script src="red/ui/view.js"></script> | <script src="red/ui/view.js"></script> |
| /** Modified from original Node-Red source, for audio system visualization | |||||
| * vim: set ts=4: | |||||
| * Copyright 2014 IBM Corp. | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| **/ | |||||
| RED.comms = (function() { | |||||
| //var errornotification = null; | |||||
| //var subscriptions = {}; | |||||
| //var ws; | |||||
| function connectWS() { | |||||
| /* | |||||
| var path = location.hostname+":"+location.port+document.location.pathname; | |||||
| path = path+(path.slice(-1) == "/"?"":"/")+"comms"; | |||||
| path = "ws"+(document.location.protocol=="https:"?"s":"")+"://"+path; | |||||
| ws = new WebSocket(path); | |||||
| ws.onopen = function() { | |||||
| if (errornotification) { | |||||
| errornotification.close(); | |||||
| errornotification = null; | |||||
| } | |||||
| for (var t in subscriptions) { | |||||
| if (subscriptions.hasOwnProperty(t)) { | |||||
| ws.send(JSON.stringify({subscribe:t})); | |||||
| } | |||||
| } | |||||
| } | |||||
| ws.onmessage = function(event) { | |||||
| var msg = JSON.parse(event.data); | |||||
| if (msg.topic) { | |||||
| for (var t in subscriptions) { | |||||
| if (subscriptions.hasOwnProperty(t)) { | |||||
| var re = new RegExp("^"+t.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$"); | |||||
| if (re.test(msg.topic)) { | |||||
| var subscribers = subscriptions[t]; | |||||
| if (subscribers) { | |||||
| for (var i=0;i<subscribers.length;i++) { | |||||
| subscribers[i](msg.topic,msg.data); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }; | |||||
| ws.onclose = function() { | |||||
| if (errornotification == null) { | |||||
| //errornotification = RED.notify("<b>Error</b>: Lost connection to server","error",true); | |||||
| } | |||||
| setTimeout(connectWS,1000); | |||||
| } | |||||
| */ | |||||
| } | |||||
| function subscribe(topic,callback) { | |||||
| //if (subscriptions[topic] == null) { | |||||
| //subscriptions[topic] = []; | |||||
| //} | |||||
| //subscriptions[topic].push(callback); | |||||
| //if (ws && ws.readyState == 1) { | |||||
| //ws.send(JSON.stringify({subscribe:topic})); | |||||
| //} | |||||
| } | |||||
| return { | |||||
| connect: connectWS, | |||||
| subscribe: subscribe | |||||
| } | |||||
| })(); |
| } | } | ||||
| })(); | })(); | ||||
| RED.validators = { | |||||
| number: function(){return function(v) { return v!=='' && !isNaN(v);}}, | |||||
| regex: function(re){return function(v) { return re.test(v);}} | |||||
| }; |
| nns.sort(function(a,b){ return (a.x + a.y/250) - (b.x + b.y/250); }); | nns.sort(function(a,b){ return (a.x + a.y/250) - (b.x + b.y/250); }); | ||||
| //console.log(JSON.stringify(nns)); | //console.log(JSON.stringify(nns)); | ||||
| var cpp = "// GUItool: begin automatically generated code\n"; | |||||
| var cpp = "#include <Audio.h>\n#include <Wire.h>\n" | |||||
| + "#include <SPI.h>\n#include <SD.h>\n\n" | |||||
| + "// GUItool: begin automatically generated code\n"; | |||||
| // generate code for all audio processing nodes | // generate code for all audio processing nodes | ||||
| for (var i=0; i<nns.length; i++) { | for (var i=0; i<nns.length; i++) { | ||||
| var n = nns[i]; | var n = nns[i]; | ||||
| return false; | return false; | ||||
| }); | }); | ||||
| }); | }); | ||||
| $( "#dialog" ).dialog("option","title","Export nodes to clipboard").dialog( "open" ); | |||||
| $( "#dialog" ).dialog("option","title","Export to Arduino").dialog( "open" ); | |||||
| $("#node-input-export").focus(); | $("#node-input-export").focus(); | ||||
| //RED.view.dirty(false); | //RED.view.dirty(false); | ||||
| } | } | ||||
| $("#palette-search").show(); | $("#palette-search").show(); | ||||
| RED.storage.load(); | RED.storage.load(); | ||||
| RED.view.redraw(); | RED.view.redraw(); | ||||
| setTimeout(function() { | |||||
| $("#btn-deploy").removeClass("disabled").addClass("btn-danger"); | |||||
| }, 1500); | |||||
| }, "html"); | }, "html"); | ||||
| } | } | ||||
| $(function() { | $(function() { | ||||
| RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();}); | RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();}); | ||||
| loadNodes(); | loadNodes(); | ||||
| //RED.comms.connect(); | |||||
| }); | }); | ||||
| return { | return { |
| /** Modified from original Node-Red source, for audio system visualization | |||||
| * vim: set ts=4: | |||||
| * Copyright 2013 IBM Corp. | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| **/ | |||||
| RED.validators = { | |||||
| number: function(){return function(v) { return v!=='' && !isNaN(v);}}, | |||||
| regex: function(re){return function(v) { return re.test(v);}} | |||||
| }; |